Add CLI for V2 image create, update, and upload
Provides command line support for image-create, image-update, and image-upload using the Glance V2 API. This includes building help text for create and update based on the image jsonschema as fetched from the server. Also fixes bug caused by default warlock patch generation not matching what Glance expects when updating a core property which had not originally been set when the image was created. Related to bp glance-client-v2 Change-Id: I841f9e3d05802f4b794cb6f4849abe03ff0324d9
This commit is contained in:
@@ -15,14 +15,8 @@
|
||||
|
||||
import argparse
|
||||
import copy
|
||||
import os
|
||||
import sys
|
||||
|
||||
if os.name == 'nt':
|
||||
import msvcrt
|
||||
else:
|
||||
msvcrt = None
|
||||
|
||||
from glanceclient import exc
|
||||
from glanceclient.common import utils
|
||||
from glanceclient.common import progressbar
|
||||
@@ -125,30 +119,7 @@ def _image_show(image, human_readable=False):
|
||||
|
||||
def _set_data_field(fields, args):
|
||||
if 'location' not in fields and 'copy_from' not in fields:
|
||||
if args.file:
|
||||
fields['data'] = open(args.file, 'rb')
|
||||
else:
|
||||
# distinguish cases where:
|
||||
# (1) stdin is not valid (as in cron jobs):
|
||||
# glance ... <&-
|
||||
# (2) image data is provided through standard input:
|
||||
# glance ... < /tmp/file or cat /tmp/file | glance ...
|
||||
# (3) no image data provided:
|
||||
# glance ...
|
||||
try:
|
||||
os.fstat(0)
|
||||
except OSError:
|
||||
# (1) stdin is not valid (closed...)
|
||||
fields['data'] = None
|
||||
return
|
||||
if not sys.stdin.isatty():
|
||||
# (2) image data is provided through standard input
|
||||
if msvcrt:
|
||||
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
|
||||
fields['data'] = sys.stdin
|
||||
else:
|
||||
# (3) no image data provided
|
||||
fields['data'] = None
|
||||
fields['data'] = utils.get_data_file(args)
|
||||
|
||||
|
||||
@utils.arg('image', metavar='<IMAGE>', help='Name or ID of image to describe.')
|
||||
|
||||
Reference in New Issue
Block a user