From e354d17d2c7603e7f4b9e5ba4abf474dc709be9f Mon Sep 17 00:00:00 2001 From: Mohan Muppidi Date: Tue, 1 Mar 2016 07:13:09 +0000 Subject: [PATCH] " openstack server image create " doesn't print proper info After creating a snapshot of a running instance, a print out similar to server create is expected, but it prints out something like "_info" which is nothing related to created image. _prep_image_detail method is added to /compute/v2/server.py to enable the priting, while running the test properly. Change-Id: I4b06be959768bcdaafd9aa8df497490958bee649 Closes-Bug:1551586 --- openstackclient/compute/v2/server.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index ca239c5195..ad399d7857 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -161,6 +161,23 @@ def _prep_server_detail(compute_client, server): return info +def _prep_image_detail(image_client, image_id): + """Prepare the detailed image dict for printing + + :param image_client: an image client instance + :param image_id: id of image created + :rtype: a dict of image details + """ + + info = utils.find_resource( + image_client.images, + image_id, + ) + # Glance client V2 doesn't have _info attribute + # The following condition deals with it. + return getattr(info, "_info", info) + + def _show_progress(progress): if progress: sys.stdout.write('\rProgress: %s' % progress) @@ -622,12 +639,9 @@ class CreateServerImage(command.ShowOne): sys.stdout.write(_('\nError creating server snapshot')) raise SystemExit - image = utils.find_resource( - image_client.images, - image_id, - ) + image = _prep_image_detail(image_client, image_id) - return zip(*sorted(six.iteritems(image._info))) + return zip(*sorted(six.iteritems(image))) class DeleteServer(command.Command):