Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
31618e2a
Commit
31618e2a
authored
Jun 27, 2013
by
Stavros Sachtouris
Browse files
Parse publicURL to fix astakos init, pretty quotas
Refs: #3632
parent
556e6916
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/snf-astakos.py
View file @
31618e2a
...
...
@@ -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
()
...
...
kamaki/cli/utils.py
View file @
31618e2a
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment