Revision a53ec93b snf-astakos-app/astakos/im/management/commands/_common.py
b/snf-astakos-app/astakos/im/management/commands/_common.py | ||
---|---|---|
197 | 197 |
return units.show(number, unit, style) |
198 | 198 |
|
199 | 199 |
|
200 |
def collect_holder_quotas(holder_quotas, h_initial, style=None):
|
|
200 |
def collect_holder_quotas(holder_quotas, style=None): |
|
201 | 201 |
print_data = [] |
202 | 202 |
for source, source_quotas in holder_quotas.iteritems(): |
203 |
try: |
|
204 |
s_initial = h_initial[source] |
|
205 |
except KeyError: |
|
206 |
continue |
|
207 | 203 |
for resource, values in source_quotas.iteritems(): |
208 |
try: |
|
209 |
initial = s_initial[resource] |
|
210 |
except KeyError: |
|
211 |
continue |
|
212 |
initial = show_resource_value(initial, resource, style) |
|
213 | 204 |
limit = show_resource_value(values['limit'], resource, style) |
214 | 205 |
usage = show_resource_value(values['usage'], resource, style) |
215 |
fields = (source, resource, initial, limit, usage)
|
|
206 |
fields = (source, resource, limit, usage) |
|
216 | 207 |
print_data.append(fields) |
217 | 208 |
return print_data |
218 | 209 |
|
219 | 210 |
|
220 |
def show_user_quotas(holder_quotas, h_initial, style=None):
|
|
221 |
labels = ('source', 'resource', 'base_quota', 'total_quota', 'usage')
|
|
222 |
print_data = collect_holder_quotas(holder_quotas, h_initial, style=style)
|
|
211 |
def show_user_quotas(holder_quotas, style=None): |
|
212 |
labels = ('source', 'resource', 'limit', 'usage')
|
|
213 |
print_data = collect_holder_quotas(holder_quotas, style=style) |
|
223 | 214 |
return print_data, labels |
224 | 215 |
|
225 | 216 |
|
226 |
def show_quotas(qh_quotas, astakos_initial, info=None, style=None): |
|
227 |
labels = ('user', 'source', 'resource', 'base_quota', 'total_quota', |
|
228 |
'usage') |
|
217 |
def show_quotas(qh_quotas, info=None, style=None): |
|
218 |
labels = ('holder', 'source', 'resource', 'limit', 'usage') |
|
229 | 219 |
if info is not None: |
230 | 220 |
labels = ('displayname',) + labels |
231 | 221 |
|
232 | 222 |
print_data = [] |
233 | 223 |
for holder, holder_quotas in qh_quotas.iteritems(): |
234 |
h_initial = astakos_initial.get(holder) |
|
235 |
if h_initial is None: |
|
236 |
continue |
|
237 |
|
|
238 | 224 |
if info is not None: |
239 | 225 |
email = info.get(holder, "") |
240 | 226 |
|
241 |
h_data = collect_holder_quotas(holder_quotas, h_initial, style=style)
|
|
227 |
h_data = collect_holder_quotas(holder_quotas, style=style) |
|
242 | 228 |
if info is not None: |
243 | 229 |
h_data = [(email, holder) + fields for fields in h_data] |
244 | 230 |
else: |
Also available in: Unified diff