diff options
| author | Badhmapriya Boopalan <Badhmapriya.Boopalan@cognizant.com> | 2016-11-15 19:55:46 +0000 |
|---|---|---|
| committer | Steve Martinelli <s.martinelli@gmail.com> | 2017-01-11 02:09:02 +0000 |
| commit | 6962cc963e6e17e709524ecf6a395e2d0c8b8370 (patch) | |
| tree | 768386a18e543cff9fb36e727550b2b8a7b4df46 /openstackclient/image | |
| parent | 5bf5de6f45a9a96768de9aafdb8cd1bb390389aa (diff) | |
| download | python-openstackclient-6962cc963e6e17e709524ecf6a395e2d0c8b8370.tar.gz | |
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
Diffstat (limited to 'openstackclient/image')
| -rw-r--r-- | openstackclient/image/v1/image.py | 9 | ||||
| -rw-r--r-- | openstackclient/image/v2/image.py | 8 |
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))) |
