diff options
| author | NiallBunting <niall.bunting@hp.com> | 2015-09-18 15:21:59 +0000 |
|---|---|---|
| committer | NiallBunting <niall.bunting@hp.com> | 2015-09-18 15:29:47 +0000 |
| commit | 1afd8f62cd5b59c9bd3042af6dbc4ba94717c023 (patch) | |
| tree | 2f9c6d8e363e45244487824aa7058892f7d8f46c /openstackclient | |
| parent | 817ab3ec0ea5a74aeda12850f39a56f332e9558b (diff) | |
| download | python-openstackclient-1afd8f62cd5b59c9bd3042af6dbc4ba94717c023.tar.gz | |
Image fix bug with --volume
Currently after calling the cinderclient to create an image from a volume,
it also then tries to create another image. This fails as the keyword
volume is unexpected. This add checks so the image is not created in
this case. Allowing --volume to not throw an error when it has worked.
Change-Id: I67e650eb0b8c331d86515e3e326c39a5d6dad5e1
Closes-Bug: 1497221
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/image/v1/image.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py index 68c81cd5..81d384f7 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -213,6 +213,8 @@ class CreateImage(show.ShowOne): if parsed_args.private: kwargs['is_public'] = False + info = {} + if not parsed_args.location and not parsed_args.copy_from: if parsed_args.volume: volume_client = self.app.client_manager.volume @@ -241,18 +243,18 @@ class CreateImage(show.ShowOne): # do a chunked transfer kwargs["data"] = sys.stdin - # Wrap the call to catch exceptions in order to close files - try: - image = image_client.images.create(**kwargs) - finally: - # Clean up open files - make sure data isn't a string - if ('data' in kwargs and hasattr(kwargs['data'], 'close') and - kwargs['data'] != sys.stdin): - kwargs['data'].close() - - info = {} - info.update(image._info) - info['properties'] = utils.format_dict(info.get('properties', {})) + if not parsed_args.volume: + # Wrap the call to catch exceptions in order to close files + try: + image = image_client.images.create(**kwargs) + finally: + # Clean up open files - make sure data isn't a string + if ('data' in kwargs and hasattr(kwargs['data'], 'close') and + kwargs['data'] != sys.stdin): + kwargs['data'].close() + + info.update(image._info) + info['properties'] = utils.format_dict(info.get('properties', {})) return zip(*sorted(six.iteritems(info))) |
