diff options
author | Zuul <zuul@review.opendev.org> | 2022-08-30 14:57:55 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-08-30 14:57:55 +0000 |
commit | f2999ce752e111d93a74c73cae5cccfceb4467c2 (patch) | |
tree | 28e183bf4b754028144f467468b8f1d99db39324 /glanceclient/v2/shell.py | |
parent | 219568c2a4b21c26ca4c160a7cf4d71cae524255 (diff) | |
parent | 92cd70a2240dd5106ebfffecd6007942e898903a (diff) | |
download | python-glanceclient-f2999ce752e111d93a74c73cae5cccfceb4467c2.tar.gz |
Merge "Add support for glance-download import method"4.1.0
Diffstat (limited to 'glanceclient/v2/shell.py')
-rw-r--r-- | glanceclient/v2/shell.py | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 84e3639..773c198 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -148,6 +148,14 @@ def do_image_create(gc, args): 'record if no import-method and no data is supplied')) @utils.arg('--uri', metavar='<IMAGE_URL>', default=None, help=_('URI to download the external image.')) +@utils.arg('--remote-region', metavar='<GLANCE_REGION>', default=None, + help=_('REMOTE_GLANCE_REGION to download the image.')) +@utils.arg('--remote-image-id', metavar='<REMOTE_IMAGE_ID>', default=None, + help=_('The IMAGE ID of the image of remote glance, which needs' + 'to be imported with glance-download')) +@utils.arg('--remote-service-interface', metavar='<REMOTE_SERVICE_INTERFACE>', + default='public', + help=_('The Remote Glance Service Interface for glance-download')) @utils.arg('--store', metavar='<STORE>', default=utils.env('OS_IMAGE_STORE', default=None), help='Backend store to upload image to.') @@ -293,6 +301,22 @@ def do_image_create_via_import(gc, args): utils.exit("You cannot pass data via stdin with the web-download " "import method.") + if args.import_method == 'glance-download': + if not (args.remote_region and args.remote_image_id): + utils.exit("REMOTE GlANCE REGION and REMOTE IMAGE ID are " + "required for glance-download import method. " + "Please use --remote-region <region> and " + "--remote-image-id <remote-image-id>.") + if args.uri: + utils.exit("You cannot specify a --uri with the glance-download " + "import method.") + if file_name: + utils.exit("You cannot specify a --file with the glance-download " + "import method.") + if using_stdin: + utils.exit("You cannot pass data via stdin with the " + "glance-download import method.") + # process image = gc.images.create(**fields) try: @@ -726,6 +750,14 @@ def do_image_stage(gc, args): '"image-stage".')) @utils.arg('--uri', metavar='<IMAGE_URL>', default=None, help=_('URI to download the external image.')) +@utils.arg('--remote-region', metavar='<REMOTE_GLANCE_REGION>', default=None, + help=_('REMOTE GLANCE REGION to download the image.')) +@utils.arg('--remote-image-id', metavar='<REMOTE_IMAGE_ID>', default=None, + help=_('The IMAGE ID of the image of remote glance, which needs' + 'to be imported with glance-download')) +@utils.arg('--remote-service-interface', metavar='<REMOTE_SERVICE_INTERFACE>', + default='public', + help=_('The Remote Glance Service Interface for glance-download')) @utils.arg('id', metavar='<IMAGE_ID>', help=_('ID of image to import.')) @utils.arg('--store', metavar='<STORE>', @@ -757,6 +789,10 @@ def do_image_import(gc, args): stores = getattr(args, "stores", None) all_stores = getattr(args, "os_all_stores", None) allow_failure = getattr(args, "os_allow_failure", True) + uri = getattr(args, "uri", None) + remote_region = getattr(args, "remote-region", None) + remote_image_id = getattr(args, "remote-image-id", None) + remote_service_interface = getattr(args, "remote-service-interface", None) if not getattr(args, 'from_create', False): if (args.store and (stores or all_stores)) or (stores and all_stores): @@ -800,6 +836,20 @@ def do_image_import(gc, args): utils.exit("Import method should be 'web-download' if URI is " "provided.") + if args.import_method == 'glance-download' and \ + not (remote_region and remote_image_id): + utils.exit("Provide REMOTE_IMAGE_ID and remote-region for " + "'glance-download' import method.") + if remote_region and args.import_method != 'glance-download': + utils.exit("Import method should be 'glance-download' if " + "REMOTE REGION is provided.") + if remote_image_id and args.import_method != 'glance-download': + utils.exit("Import method should be 'glance-download' if " + "REMOTE IMAGE ID is provided.") + if remote_service_interface and args.import_method != 'glance-download': + utils.exit("Import method should be 'glance-download' if " + "REMOTE SERVICE INTERFACE is provided.") + if args.import_method == 'copy-image' and not (stores or all_stores): utils.exit("Provide either --stores or --all-stores for " "'copy-image' import method.") @@ -827,10 +877,12 @@ def do_image_import(gc, args): "an image with status 'active'.") # finally, do the import - gc.images.image_import(args.id, args.import_method, args.uri, - backend=backend, - stores=stores, all_stores=all_stores, - allow_failure=allow_failure) + gc.images.image_import(args.id, args.import_method, uri=uri, + remote_region=remote_region, + remote_image_id=remote_image_id, + remote_service_interface=remote_service_interface, + backend=backend, stores=stores, + all_stores=all_stores, allow_failure=allow_failure) image = gc.images.get(args.id) utils.print_image(image) |