Commit c315efc0 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Move helper function from qh to quotas.py

parent 83dfe64a
......@@ -103,8 +103,19 @@ def get_service_quotas(service, users=None):
return transform_data(counters)
def _level_quota_dict(quotas):
lst = []
for holder, holder_quota in quotas.iteritems():
for source, source_quota in holder_quota.iteritems():
for resource, limit in source_quota.iteritems():
key = (holder, source, resource)
lst.append((key, limit))
return lst
def set_user_quota(quotas):
qh.set_holder_quota(quotas)
q = _level_quota_dict(quotas)
qh.set_quota(q)
def get_default_quota():
......
......@@ -106,19 +106,6 @@ class QuotaholderDjangoDBCallpoint(object):
'quantity': quantity,
}
def set_holder_quota(self, quotas):
q = self._level_quota_dict(quotas)
self.set_quota(q)
def _level_quota_dict(self, quotas):
lst = []
for holder, holder_quota in quotas.iteritems():
for source, source_quota in holder_quota.iteritems():
for resource, limit in source_quota.iteritems():
key = (holder, source, resource)
lst.append((key, limit))
return lst
def set_quota(self, quotas):
holding_keys = [key for (key, limit) in quotas]
holdings = self._get_holdings_for_update(holding_keys)
......
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