Revision 31618e2a kamaki/cli/commands/snf-astakos.py
b/kamaki/cli/commands/snf-astakos.py | ||
---|---|---|
38 | 38 |
from kamaki.cli.commands import ( |
39 | 39 |
_command_init, errors, _optional_json, addLogSettings) |
40 | 40 |
from kamaki.cli.command_tree import CommandTree |
41 |
from kamaki.cli.utils import print_dict |
|
41 |
from kamaki.cli.utils import print_dict, format_size
|
|
42 | 42 |
from kamaki.cli.argument import FlagArgument, ValueArgument |
43 | 43 |
from kamaki.cli.logger import get_logger |
44 | 44 |
|
... | ... | |
63 | 63 |
astakos_endpoints = self.auth_base.get_service_endpoints( |
64 | 64 |
self._custom_type('astakos') or 'identity', |
65 | 65 |
self._custom_version('astakos') or '') |
66 |
base_url = astakos_endpoints['publicURL'] |
|
66 |
base_url = astakos_endpoints['SNF:uiURL'] |
|
67 |
base_url = ''.join(base_url.split('/ui')) |
|
67 | 68 |
else: |
68 | 69 |
base_url = self._custom_url('astakos') |
69 | 70 |
if not base_url: |
... | ... | |
142 | 143 |
class astakos_quotas(_astakos_init, _optional_json): |
143 | 144 |
"""Get user (or service) quotas""" |
144 | 145 |
|
146 |
@staticmethod |
|
147 |
def _print_with_format(d): |
|
148 |
""" Print d with size formating when needed |
|
149 |
:param d: (dict) {system: {<service>: {usage: ..., limit: ..., }, ...}} |
|
150 |
""" |
|
151 |
newd = dict() |
|
152 |
for k, service in d['system'].items(): |
|
153 |
newd[k] = dict(service) |
|
154 |
for term in ('usage', 'limit'): |
|
155 |
if term in service: |
|
156 |
newd[k][term] = format_size(service[term]) |
|
157 |
print_dict(newd) |
|
158 |
|
|
145 | 159 |
def _run(self): |
146 |
self._print(self.client.get_quotas(self.token), print_dict) |
|
160 |
self._print( |
|
161 |
self.client.get_quotas(self.token), self._print_with_format) |
|
147 | 162 |
|
148 | 163 |
def main(self): |
149 | 164 |
super(self.__class__, self)._run() |
Also available in: Unified diff