From 6962cc963e6e17e709524ecf6a395e2d0c8b8370 Mon Sep 17 00:00:00 2001 From: Badhmapriya Boopalan Date: Tue, 15 Nov 2016 19:55:46 +0000 Subject: To display image size in human friendly format Include option '--human-readable' to 'image show' command. This option displays image size in human readable format (such as K, M, G, T,..) Related Commit: I0ef74c2ec978483fe49156c88acf5c369a8fa5c2 Closes-Bug: #1640086 Change-Id: I28cd5702925d51303d0607ed8dccf12c56434682 --- openstackclient/image/v2/image.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'openstackclient/image/v2') 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 @@ -848,6 +848,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="", @@ -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))) -- cgit v1.2.1