From fdbbb1076e2ce7c22bc71ba9b49020ce1e79603a Mon Sep 17 00:00:00 2001 From: Seif Lotfy Date: Sun, 14 Jul 2013 21:31:32 +0000 Subject: [PATCH] Add print to the upload-to-image command Change-Id: I4f7fa6f943fce8151ebd609f35c4717f868a5dfb --- cinderclient/v1/shell.py | 12 ++++++++---- cinderclient/v1/volumes.py | 4 ++-- cinderclient/v2/shell.py | 12 ++++++++---- cinderclient/v2/volumes.py | 4 ++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index eeb30ba11..395cc72de 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -86,6 +86,10 @@ def _print_volume_snapshot(snapshot): utils.print_dict(snapshot._info) +def _print_volume_image(image): + utils.print_dict(image[1]['os-volume_upload_image']) + + def _translate_keys(collection, convert): for item in collection: keys = list(item.__dict__.keys()) @@ -683,10 +687,10 @@ def _find_volume_type(cs, vtype): def do_upload_to_image(cs, args): """Upload volume to image service as image.""" volume = _find_volume(cs, args.volume_id) - volume.upload_to_image(args.force, - args.image_name, - args.container_format, - args.disk_format) + _print_volume_image(volume.upload_to_image(args.force, + args.image_name, + args.container_format, + args.disk_format)) @utils.arg('volume', metavar='', diff --git a/cinderclient/v1/volumes.py b/cinderclient/v1/volumes.py index 5f6c56659..9c870cb30 100644 --- a/cinderclient/v1/volumes.py +++ b/cinderclient/v1/volumes.py @@ -91,8 +91,8 @@ class Volume(base.Resource): def upload_to_image(self, force, image_name, container_format, disk_format): """Upload a volume to image service as an image.""" - self.manager.upload_to_image(self, force, image_name, container_format, - disk_format) + return self.manager.upload_to_image(self, force, image_name, + container_format, disk_format) def force_delete(self): """Delete the specified volume ignoring its current state. diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 98883d6ba..f40076074 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -80,6 +80,10 @@ def _print_volume_snapshot(snapshot): utils.print_dict(snapshot._info) +def _print_volume_image(image): + utils.print_dict(image[1]['os-volume_upload_image']) + + def _translate_keys(collection, convert): for item in collection: keys = list(item.__dict__.keys()) @@ -759,10 +763,10 @@ def _find_volume_type(cs, vtype): def do_upload_to_image(cs, args): """Upload volume to image service as image.""" volume = _find_volume(cs, args.volume_id) - volume.upload_to_image(args.force, - args.image_name, - args.container_format, - args.disk_format) + _print_volume_image(volume.upload_to_image(args.force, + args.image_name, + args.container_format, + args.disk_format)) @utils.arg('volume', metavar='', diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py index 273668f98..14535afc9 100644 --- a/cinderclient/v2/volumes.py +++ b/cinderclient/v2/volumes.py @@ -90,8 +90,8 @@ class Volume(base.Resource): def upload_to_image(self, force, image_name, container_format, disk_format): """Upload a volume to image service as an image.""" - self.manager.upload_to_image(self, force, image_name, container_format, - disk_format) + return self.manager.upload_to_image(self, force, image_name, + container_format, disk_format) def force_delete(self): """Delete the specified volume ignoring its current state.