Skip to content

Commit e354d17

Browse files
committed
" 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
1 parent 7039cd3 commit e354d17

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ def _prep_server_detail(compute_client, server):
161161
return info
162162

163163

164+
def _prep_image_detail(image_client, image_id):
165+
"""Prepare the detailed image dict for printing
166+
167+
:param image_client: an image client instance
168+
:param image_id: id of image created
169+
:rtype: a dict of image details
170+
"""
171+
172+
info = utils.find_resource(
173+
image_client.images,
174+
image_id,
175+
)
176+
# Glance client V2 doesn't have _info attribute
177+
# The following condition deals with it.
178+
return getattr(info, "_info", info)
179+
180+
164181
def _show_progress(progress):
165182
if progress:
166183
sys.stdout.write('\rProgress: %s' % progress)
@@ -622,12 +639,9 @@ def take_action(self, parsed_args):
622639
sys.stdout.write(_('\nError creating server snapshot'))
623640
raise SystemExit
624641

625-
image = utils.find_resource(
626-
image_client.images,
627-
image_id,
628-
)
642+
image = _prep_image_detail(image_client, image_id)
629643

630-
return zip(*sorted(six.iteritems(image._info)))
644+
return zip(*sorted(six.iteritems(image)))
631645

632646

633647
class DeleteServer(command.Command):

0 commit comments

Comments
 (0)