From c98432a6d4d13f44eb00720a67153715d81a5d78 Mon Sep 17 00:00:00 2001 From: Jakub Ruzicka Date: Thu, 11 Apr 2013 14:38:35 +0200 Subject: [PATCH] Fix "glance add" parsing of "copy_from" option. copy_from was ignored which resulted in "glance add" attempting to read from stdout. Fixes bug 1167899 Change-Id: I57fd85f7bb655bef69222d4fdf6b8274088ca827 --- glanceclient/v1/legacy_shell.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/glanceclient/v1/legacy_shell.py b/glanceclient/v1/legacy_shell.py index 99a18139..5c43a997 100644 --- a/glanceclient/v1/legacy_shell.py +++ b/glanceclient/v1/legacy_shell.py @@ -122,7 +122,7 @@ def do_add(gc, args): } #NOTE(bcwaldon): Use certain properties only if they are explicitly set - optional = ['id', 'name', 'disk_format', 'container_format', 'copy_from'] + optional = ['id', 'name', 'disk_format', 'container_format'] for field in optional: if field in fields: image_meta[field] = fields.pop(field) @@ -134,22 +134,15 @@ def do_add(gc, args): print 'Found non-settable field %s. Removing.' % field fields.pop(field) - def _external_source(fields, image_data): - source = None - if 'location' in fields.keys(): - source = fields.pop('location') - image_meta['location'] = source - if 'checksum' in fields.keys(): - image_meta['checksum'] = fields.pop('checksum') - elif 'copy_from' in fields.keys(): - source = fields.pop('copy_from') - image_meta['copy_from'] = source - return source - # We need either a location or image data/stream to add... - location = _external_source(fields, image_meta) image_data = None - if not location: + if 'location' in fields.keys(): + image_meta['location'] = fields.pop('location') + if 'checksum' in fields.keys(): + image_meta['checksum'] = fields.pop('checksum') + elif 'copy_from' in fields.keys(): + image_meta['copy_from'] = fields.pop('copy_from') + else: # Grab the image data stream from stdin or redirect, # otherwise error out image_data = sys.stdin