diff options
author | eddie-sheffield <eddie.sheffield@rackspace.com> | 2013-08-19 17:27:07 -0400 |
---|---|---|
committer | eddie-sheffield <eddie.sheffield@rackspace.com> | 2013-10-02 13:22:55 -0400 |
commit | 32d9c42816b608220ae5692e573142dab6534604 (patch) | |
tree | 45ea0aaa339e0ce61662b7128c2f9c0d2c5357d8 /glanceclient/v1/shell.py | |
parent | 7a4a8a0979fd76203f0cb81622a7f06ee42bb615 (diff) | |
download | python-glanceclient-32d9c42816b608220ae5692e573142dab6534604.tar.gz |
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
Diffstat (limited to 'glanceclient/v1/shell.py')
-rw-r--r-- | glanceclient/v1/shell.py | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py index 31458da..abd8c87 100644 --- a/glanceclient/v1/shell.py +++ b/glanceclient/v1/shell.py @@ -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.') |