Merge "Fix "glance add" parsing of "copy_from" option."
This commit is contained in:
@@ -122,7 +122,7 @@ def do_add(gc, args):
|
|||||||
}
|
}
|
||||||
|
|
||||||
#NOTE(bcwaldon): Use certain properties only if they are explicitly set
|
#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:
|
for field in optional:
|
||||||
if field in fields:
|
if field in fields:
|
||||||
image_meta[field] = fields.pop(field)
|
image_meta[field] = fields.pop(field)
|
||||||
@@ -134,22 +134,15 @@ def do_add(gc, args):
|
|||||||
print 'Found non-settable field %s. Removing.' % field
|
print 'Found non-settable field %s. Removing.' % field
|
||||||
fields.pop(field)
|
fields.pop(field)
|
||||||
|
|
||||||
def _external_source(fields, image_data):
|
# We need either a location or image data/stream to add...
|
||||||
source = None
|
image_data = None
|
||||||
if 'location' in fields.keys():
|
if 'location' in fields.keys():
|
||||||
source = fields.pop('location')
|
image_meta['location'] = fields.pop('location')
|
||||||
image_meta['location'] = source
|
|
||||||
if 'checksum' in fields.keys():
|
if 'checksum' in fields.keys():
|
||||||
image_meta['checksum'] = fields.pop('checksum')
|
image_meta['checksum'] = fields.pop('checksum')
|
||||||
elif 'copy_from' in fields.keys():
|
elif 'copy_from' in fields.keys():
|
||||||
source = fields.pop('copy_from')
|
image_meta['copy_from'] = fields.pop('copy_from')
|
||||||
image_meta['copy_from'] = source
|
else:
|
||||||
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:
|
|
||||||
# Grab the image data stream from stdin or redirect,
|
# Grab the image data stream from stdin or redirect,
|
||||||
# otherwise error out
|
# otherwise error out
|
||||||
image_data = sys.stdin
|
image_data = sys.stdin
|
||||||
|
Reference in New Issue
Block a user