Revision 14a58548 snf-astakos-app/astakos/im/endpoints/qh.py
b/snf-astakos-app/astakos/im/endpoints/qh.py | ||
---|---|---|
99 | 99 |
|
100 | 100 |
def quota_limits_per_user_from_get(lst): |
101 | 101 |
quotas = {} |
102 |
for holder, resource, q, c, il, el, imp, exp, ret, rel, flags in lst:
|
|
102 |
for holder, resource, q, c, imp, exp, ret, rel, flags in lst: |
|
103 | 103 |
userquotas = quotas.get(holder, {}) |
104 | 104 |
userquotas[resource] = QuotaValues(quantity=q, capacity=c, |
105 |
import_limit=il, export_limit=el)
|
|
105 |
) |
|
106 | 106 |
quotas[holder] = userquotas |
107 | 107 |
return quotas |
108 | 108 |
|
... | ... | |
110 | 110 |
def quotas_per_user_from_get(lst): |
111 | 111 |
limits = {} |
112 | 112 |
counters = {} |
113 |
for holder, resource, q, c, il, el, imp, exp, ret, rel, flags in lst:
|
|
113 |
for holder, resource, q, c, imp, exp, ret, rel, flags in lst: |
|
114 | 114 |
userlimits = limits.get(holder, {}) |
115 | 115 |
userlimits[resource] = QuotaValues(quantity=q, capacity=c, |
116 |
import_limit=il, export_limit=el)
|
|
116 |
) |
|
117 | 117 |
limits[holder] = userlimits |
118 | 118 |
|
119 | 119 |
usercounters = counters.get(holder, {}) |
... | ... | |
154 | 154 |
'resource', |
155 | 155 |
'quantity', |
156 | 156 |
'capacity', |
157 |
'import_limit', |
|
158 |
'export_limit', |
|
159 | 157 |
'flags')) |
160 | 158 |
|
161 | 159 |
QuotaLimits = namedtuple('QuotaLimits', ('holder', |
162 | 160 |
'resource', |
163 | 161 |
'capacity', |
164 |
'import_limit', |
|
165 |
'export_limit')) |
|
162 |
)) |
|
166 | 163 |
|
167 | 164 |
QuotaCounters = namedtuple('QuotaCounters', ('imported', |
168 | 165 |
'exported', |
... | ... | |
172 | 169 |
|
173 | 170 |
class QuotaValues(namedtuple('QuotaValues', ('quantity', |
174 | 171 |
'capacity', |
175 |
'import_limit', |
|
176 |
'export_limit'))): |
|
172 |
))): |
|
177 | 173 |
__slots__ = () |
178 | 174 |
|
179 | 175 |
def __dir__(self): |
180 |
return ['quantity', 'capacity', 'import_limit', 'export_limit']
|
|
176 |
return ['quantity', 'capacity'] |
|
181 | 177 |
|
182 | 178 |
def __str__(self): |
183 | 179 |
return '\t'.join(['%s=%s' % (f, strbigdec(getattr(self, f))) |
... | ... | |
188 | 184 |
return QuotaValues( |
189 | 185 |
quantity = q1.quantity + q2.quantity, |
190 | 186 |
capacity = q1.capacity + q2.capacity, |
191 |
import_limit = q1.import_limit + q2.import_limit, |
|
192 |
export_limit = q1.export_limit + q2.export_limit) |
|
187 |
) |
|
193 | 188 |
|
194 | 189 |
|
195 | 190 |
def register_quotas(quotas): |
... | ... | |
205 | 200 |
resource=resource, |
206 | 201 |
quantity=q.quantity, |
207 | 202 |
capacity=q.capacity, |
208 |
import_limit=q.import_limit, |
|
209 |
export_limit=q.export_limit, |
|
210 | 203 |
flags=0)) |
211 | 204 |
return set_quota(payload) |
212 | 205 |
|
... | ... | |
224 | 217 |
resource=resource, |
225 | 218 |
quantity=q.quantity, |
226 | 219 |
capacity=q.capacity, |
227 |
import_limit=q.import_limit, |
|
228 |
export_limit=q.export_limit, |
|
229 | 220 |
flags=0)) |
230 | 221 |
return set_quota(payload) |
231 | 222 |
|
... | ... | |
237 | 228 |
resource=resource, |
238 | 229 |
quantity=QH_PRACTICALLY_INFINITE, |
239 | 230 |
capacity=QH_PRACTICALLY_INFINITE, |
240 |
import_limit=QH_PRACTICALLY_INFINITE, |
|
241 |
export_limit=QH_PRACTICALLY_INFINITE, |
|
242 | 231 |
flags=0) for resource in resources) |
243 | 232 |
return set_quota(payload) |
244 | 233 |
|
... | ... | |
254 | 243 |
|
255 | 244 |
for ql in sub_list: |
256 | 245 |
args = (ql.holder, ql.resource, |
257 |
0, ql.capacity, ql.import_limit, ql.export_limit)
|
|
246 |
0, ql.capacity) |
|
258 | 247 |
sub_append(args) |
259 | 248 |
|
260 | 249 |
for ql in add_list: |
261 | 250 |
args = (ql.holder, ql.resource, |
262 |
0, ql.capacity, ql.import_limit, ql.export_limit)
|
|
251 |
0, ql.capacity) |
|
263 | 252 |
add_append(args) |
264 | 253 |
|
265 | 254 |
result = c.add_quota(context=context, |
Also available in: Unified diff