Commit 31618e2a authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Parse publicURL to fix astakos init, pretty quotas

Refs: #3632
parent 556e6916
......@@ -38,7 +38,7 @@ from kamaki.cli.errors import CLIBaseUrlError
from kamaki.cli.commands import (
_command_init, errors, _optional_json, addLogSettings)
from kamaki.cli.command_tree import CommandTree
from kamaki.cli.utils import print_dict
from kamaki.cli.utils import print_dict, format_size
from kamaki.cli.argument import FlagArgument, ValueArgument
from kamaki.cli.logger import get_logger
......@@ -63,7 +63,8 @@ class _astakos_init(_command_init):
astakos_endpoints = self.auth_base.get_service_endpoints(
self._custom_type('astakos') or 'identity',
self._custom_version('astakos') or '')
base_url = astakos_endpoints['publicURL']
base_url = astakos_endpoints['SNF:uiURL']
base_url = ''.join(base_url.split('/ui'))
else:
base_url = self._custom_url('astakos')
if not base_url:
......@@ -142,8 +143,22 @@ class astakos_uuid(_astakos_init, _optional_json):
class astakos_quotas(_astakos_init, _optional_json):
"""Get user (or service) quotas"""
@staticmethod
def _print_with_format(d):
""" Print d with size formating when needed
:param d: (dict) {system: {<service>: {usage: ..., limit: ..., }, ...}}
"""
newd = dict()
for k, service in d['system'].items():
newd[k] = dict(service)
for term in ('usage', 'limit'):
if term in service:
newd[k][term] = format_size(service[term])
print_dict(newd)
def _run(self):
self._print(self.client.get_quotas(self.token), print_dict)
self._print(
self.client.get_quotas(self.token), self._print_with_format)
def main(self):
super(self.__class__, self)._run()
......
......@@ -262,6 +262,12 @@ def print_items(
"""
if not items:
return
elif not (
isinstance(items, dict) or isinstance(
items, list) or isinstance(items, dict)):
print '%s' % items
return
try:
page_size = int(page_size) if int(page_size) > 0 else len(items)
except:
......
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