summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2022-08-09 09:42:59 -0700
committerDan Smith <dansmith@redhat.com>2022-08-19 06:42:04 -0700
commit5ac5c1887b72af2dd1b75e5669f03586ef868816 (patch)
tree32e1c02f23b743e2659ea825e3ad176bb70d08b6
parent3f9ae1349768ee7ad7f163a302dd387847ebce7a (diff)
downloadtempest-5ac5c1887b72af2dd1b75e5669f03586ef868816.tar.gz
Allow free-form image import parameters
This allows us to pass more complex import parameters when testing those methods. Since web-download had a bespoke parameter, convert that test to use the generic mechanism as well. Related-Blueprint: glance-download-import Change-Id: Ie591c2e62b28546b9ff52fb5d4ea3e74893272a9
-rw-r--r--tempest/api/image/v2/test_images.py2
-rw-r--r--tempest/api/image/v2/test_images_negative.py2
-rw-r--r--tempest/lib/services/image/v2/images_client.py10
3 files changed, 8 insertions, 6 deletions
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index d283ab3c1..96031acda 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -131,7 +131,7 @@ class ImportImagesTest(base.BaseV2ImageTest):
# import image from web to backend
image_uri = CONF.image.http_image
self.client.image_import(image['id'], method='web-download',
- image_uri=image_uri)
+ import_params={'uri': image_uri})
waiters.wait_for_image_imported_to_stores(self.client, image['id'])
@decorators.idempotent_id('e04761a1-22af-42c2-b8bc-a34a3f12b585')
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index a3802a9fb..80c01a549 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -206,7 +206,7 @@ class ImportImagesNegativeTest(base.BaseV2ImageTest):
# import image from web to backend
image_uri = 'http://does-not.exist/no/possible/way'
self.client.image_import(image['id'], method='web-download',
- image_uri=image_uri,
+ import_params={'uri': image_uri},
stores=[stores[0]['id']])
start_time = int(time.time())
diff --git a/tempest/lib/services/image/v2/images_client.py b/tempest/lib/services/image/v2/images_client.py
index abf427cd9..ae6ce25de 100644
--- a/tempest/lib/services/image/v2/images_client.py
+++ b/tempest/lib/services/image/v2/images_client.py
@@ -206,7 +206,7 @@ class ImagesClient(rest_client.RestClient):
def image_import(self, image_id, method='glance-direct',
all_stores_must_succeed=None, all_stores=True,
- stores=None, image_uri=None):
+ stores=None, import_params=None):
"""Import data from staging area to glance store.
For a full list of available parameters, please refer to the official
@@ -222,9 +222,11 @@ class ImagesClient(rest_client.RestClient):
all available stores (incompatible with stores)
:param stores: A list of destination store names for the import. Must
be None if server does not support multistore.
- :param image_uri: A URL to be used with the web-download method
+ :param import_params: A dict of import method parameters
"""
url = 'images/%s/import' % image_id
+ if import_params is None:
+ import_params = {}
data = {
"method": {
"name": method
@@ -237,8 +239,8 @@ class ImagesClient(rest_client.RestClient):
if all_stores_must_succeed is not None:
data['all_stores_must_succeed'] = all_stores_must_succeed
- if image_uri:
- data['method']['uri'] = image_uri
+ if import_params:
+ data['method'].update(import_params)
data = json.dumps(data)
headers = {'Content-Type': 'application/json'}
resp, _ = self.post(url, data, headers=headers)