summaryrefslogtreecommitdiff
path: root/openstackclient/image
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/image')
-rw-r--r--openstackclient/image/v1/image.py9
-rw-r--r--openstackclient/image/v2/image.py8
2 files changed, 17 insertions, 0 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py
index cf389d17..48c90eb0 100644
--- a/openstackclient/image/v1/image.py
+++ b/openstackclient/image/v1/image.py
@@ -707,6 +707,12 @@ class ShowImage(command.ShowOne):
def get_parser(self, prog_name):
parser = super(ShowImage, self).get_parser(prog_name)
parser.add_argument(
+ "--human-readable",
+ default=False,
+ action='store_true',
+ help=_("Print image size in a human-friendly format."),
+ )
+ parser.add_argument(
"image",
metavar="<image>",
help=_("Image to display (name or ID)"),
@@ -722,5 +728,8 @@ class ShowImage(command.ShowOne):
info = {}
info.update(image._info)
+ if parsed_args.human_readable:
+ if 'size' in info:
+ info['size'] = utils.format_size(info['size'])
info['properties'] = utils.format_dict(info.get('properties', {}))
return zip(*sorted(six.iteritems(info)))
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py
index 657277c0..cb3537b6 100644
--- a/openstackclient/image/v2/image.py
+++ b/openstackclient/image/v2/image.py
@@ -849,6 +849,12 @@ class ShowImage(command.ShowOne):
def get_parser(self, prog_name):
parser = super(ShowImage, self).get_parser(prog_name)
parser.add_argument(
+ "--human-readable",
+ default=False,
+ action='store_true',
+ help=_("Print image size in a human-friendly format."),
+ )
+ parser.add_argument(
"image",
metavar="<image>",
help=_("Image to display (name or ID)"),
@@ -861,6 +867,8 @@ class ShowImage(command.ShowOne):
image_client.images,
parsed_args.image,
)
+ if parsed_args.human_readable:
+ image['size'] = utils.format_size(image['size'])
info = _format_image(image)
return zip(*sorted(six.iteritems(info)))