36 |
36 |
from django.db import transaction
|
37 |
37 |
|
38 |
38 |
from astakos.im.models import sync_all_users, sync_projects
|
|
39 |
from astakos.im.functions import get_user_by_uuid
|
39 |
40 |
|
40 |
41 |
import logging
|
41 |
42 |
logger = logging.getLogger(__name__)
|
... | ... | |
64 |
65 |
log = sync_all_users(sync=sync)
|
65 |
66 |
existing, nonexisting, registered_quotas, astakos_quotas = log
|
66 |
67 |
|
67 |
|
self.stdout.write("User registered in quotaholder:\n")
|
68 |
|
self.stdout.write("%s\n\n" % (existing))
|
69 |
|
self.stdout.write("User not registered in quotaholder:\n")
|
70 |
|
self.stdout.write("%s\n\n" % (nonexisting))
|
71 |
|
self.stdout.write("Quotas according to quotaholder:\n")
|
72 |
|
self.stdout.write("%s\n\n" % (registered_quotas))
|
73 |
|
self.stdout.write("Quotas according to astakos:\n")
|
74 |
|
self.stdout.write("%s\n" % (astakos_quotas))
|
|
68 |
if nonexisting:
|
|
69 |
self.stdout.write("User not registered in quotaholder:\n")
|
|
70 |
for user in nonexisting:
|
|
71 |
self.stdout.write("%s\n" % (user))
|
|
72 |
self.stdout.write("\n")
|
|
73 |
|
|
74 |
diffs = 0
|
|
75 |
for holder, local in astakos_quotas.iteritems():
|
|
76 |
registered = registered_quotas.pop(holder, None)
|
|
77 |
if registered is None:
|
|
78 |
diffs += 1
|
|
79 |
self.stdout.write("No quotas for %s in quotaholder.\n\n" %
|
|
80 |
(get_user_by_uuid(holder)))
|
|
81 |
elif local != registered:
|
|
82 |
diffs += 1
|
|
83 |
self.stdout.write("Quotas differ for %s:\n" % (get_user_by_uuid(holder)))
|
|
84 |
self.stdout.write("Quotas according to quotaholder:\n")
|
|
85 |
self.stdout.write("%s\n" % (registered))
|
|
86 |
self.stdout.write("Quotas according to astakos:\n")
|
|
87 |
self.stdout.write("%s\n\n" % (local))
|
|
88 |
|
|
89 |
if diffs:
|
|
90 |
self.stdout.write("Quotas differ for %d users.\n" % (diffs))
|
75 |
91 |
except BaseException, e:
|
76 |
92 |
logger.exception(e)
|
77 |
93 |
raise CommandError("Syncing failed.")
|