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
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index d283ab3..96031ac 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -131,7 +131,7 @@
# 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 a3802a9..80c01a5 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -206,7 +206,7 @@
# 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 abf427c..ae6ce25 100644
--- a/tempest/lib/services/image/v2/images_client.py
+++ b/tempest/lib/services/image/v2/images_client.py
@@ -206,7 +206,7 @@
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 @@
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 @@
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)