diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-06-01 17:48:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-06-01 17:48:11 +0000 |
| commit | 3707717f8f36160994b11097924e9d2d1a60edff (patch) | |
| tree | d474d5d553002852824d942173560ae6c340879c /openstackclient/image | |
| parent | d034b980ab03bbd50d31ef8bd439bc80a91a7d77 (diff) | |
| parent | 6962cc963e6e17e709524ecf6a395e2d0c8b8370 (diff) | |
| download | python-openstackclient-3707717f8f36160994b11097924e9d2d1a60edff.tar.gz | |
Merge "To display image size in human friendly format"
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 60d61709..b92da8ce 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -714,6 +714,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)"), @@ -729,5 +735,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 766de4de..ad21cbd7 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -906,6 +906,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)"), @@ -918,6 +924,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))) |
