Revision 94ad2d07
b/snf-cyclades-app/synnefo/quotas/util.py | ||
---|---|---|
79 | 79 |
If the entity for the user does not exist in quotaholder, no holding |
80 | 80 |
is returned. |
81 | 81 |
""" |
82 |
users = filter(lambda u: not u is None, users) |
|
82 | 83 |
holdings = {} |
83 | 84 |
with get_quota_holder() as qh: |
84 |
for user in users:
|
|
85 |
try:
|
|
86 |
(qh_holdings, _) = \
|
|
87 |
qh.list_holdings(context={}, list_holdings=[(user, "1")])
|
|
88 |
if not qh_holdings:
|
|
89 |
continue
|
|
90 |
qh_holdings = qh_holdings[0]
|
|
91 |
qh_holdings = filter(lambda x: x[1].startswith("cyclades."),
|
|
92 |
qh_holdings)
|
|
93 |
holdings[user] = dict(map(decode_holding, qh_holdings))
|
|
94 |
except NoEntityError:
|
|
95 |
pass
|
|
85 |
list_holdings = [(user, "1") for user in users]
|
|
86 |
(qh_holdings, rejected) = qh.list_holdings(context={},
|
|
87 |
list_holdings=list_holdings)
|
|
88 |
found_users = filter(lambda u: not u in rejected, users)
|
|
89 |
for user, user_holdings in zip(found_users, qh_holdings):
|
|
90 |
if not user_holdings:
|
|
91 |
continue
|
|
92 |
for h in user_holdings:
|
|
93 |
assert(h[0] == user)
|
|
94 |
user_holdings = filter(lambda x: x[1].startswith("cyclades."),
|
|
95 |
user_holdings)
|
|
96 |
holdings[user] = dict(map(decode_holding, user_holdings))
|
|
96 | 97 |
return holdings |
97 | 98 |
|
98 | 99 |
|
Also available in: Unified diff