glance image-show now have --human-readable option

Added option '--human-readable' to image-show cli which allows users
to display image size in human-readable format.

Change-Id: Ic3452ce4560d3cf90fa7f59f98e5ff42e804f8c9
Closes-Bug: #1434381
This commit is contained in:
yatin karel
2015-03-22 16:52:34 +05:30
parent 26280ed58b
commit c149a94ee1
3 changed files with 29 additions and 4 deletions
+3 -1
View File
@@ -372,10 +372,12 @@ def strip_version(endpoint):
return endpoint, version
def print_image(image_obj, max_col_width=None):
def print_image(image_obj, human_readable=False, max_col_width=None):
ignore = ['self', 'access', 'file', 'schema']
image = dict([item for item in six.iteritems(image_obj)
if item[0] not in ignore])
if human_readable:
image['size'] = make_size_human_readable(image['size'])
if str(max_col_width).isdigit():
print_dict(image, max_column_width=max_col_width)
else: