Commit a5dc77a5 authored by Christos Stavrakakis's avatar Christos Stavrakakis

reconcile-resources: check that user exists in QH

Do not consider 0 usage for users and resources that are not included in
Quotaholder resources list, since Quotaholder returns zero usage for all
users and all resources. If a user/resource does not belong to QH
respond then it can not be an Astakos user.

Refs #3606 #3491 #3661
parent a0edc493
......@@ -78,16 +78,31 @@ class Command(BaseCommand):
# Remove 'None' user
users.discard(None)
if userid and userid not in users:
write("User '%s' does not exist in Quotaholder!", userid)
return
unsynced = []
for user in users:
db = db_holdings.get(user, {})
qh_all = qh_holdings.get(user, {})
try:
qh_all = qh_holdings[user]
except KeyError:
write("User '%s' does not exist in Quotaholder!\n" %
user)
continue
# Assuming only one source
qh = qh_all.get(quotas.DEFAULT_SOURCE, {})
qh = transform_quotas(qh)
for resource in quotas.RESOURCES:
db_value = db.pop(resource, 0)
qh_value, _, qh_pending = qh.pop(resource, (0, 0))
try:
qh_value, _, qh_pending = qh[resource]
except KeyError:
write("Resource '%s' does not exist in Quotaholder"
" for user '%s'!\n" % (resource, user))
continue
if qh_pending:
write("Pending commission. User '%s', resource '%s'.\n" %
(user, resource))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment