Skip to content

Commit e926998

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Image fix bug with --volume"
2 parents a76164f + 1afd8f6 commit e926998

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

openstackclient/image/v1/image.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def take_action(self, parsed_args):
213213
if parsed_args.private:
214214
kwargs['is_public'] = False
215215

216+
info = {}
217+
216218
if not parsed_args.location and not parsed_args.copy_from:
217219
if parsed_args.volume:
218220
volume_client = self.app.client_manager.volume
@@ -241,18 +243,18 @@ def take_action(self, parsed_args):
241243
# do a chunked transfer
242244
kwargs["data"] = sys.stdin
243245

244-
# Wrap the call to catch exceptions in order to close files
245-
try:
246-
image = image_client.images.create(**kwargs)
247-
finally:
248-
# Clean up open files - make sure data isn't a string
249-
if ('data' in kwargs and hasattr(kwargs['data'], 'close') and
250-
kwargs['data'] != sys.stdin):
251-
kwargs['data'].close()
252-
253-
info = {}
254-
info.update(image._info)
255-
info['properties'] = utils.format_dict(info.get('properties', {}))
246+
if not parsed_args.volume:
247+
# Wrap the call to catch exceptions in order to close files
248+
try:
249+
image = image_client.images.create(**kwargs)
250+
finally:
251+
# Clean up open files - make sure data isn't a string
252+
if ('data' in kwargs and hasattr(kwargs['data'], 'close') and
253+
kwargs['data'] != sys.stdin):
254+
kwargs['data'].close()
255+
256+
info.update(image._info)
257+
info['properties'] = utils.format_dict(info.get('properties', {}))
256258
return zip(*sorted(six.iteritems(info)))
257259

258260

0 commit comments

Comments
 (0)