Merge "Make create_image use **kwargs"
This commit is contained in:
commit
8ceb030317
@ -70,8 +70,10 @@ class BaseImageTest(tempest.test.BaseTestCase):
|
|||||||
container_format = kwargs.pop('container_format')
|
container_format = kwargs.pop('container_format')
|
||||||
disk_format = kwargs.pop('disk_format')
|
disk_format = kwargs.pop('disk_format')
|
||||||
|
|
||||||
image = cls.client.create_image(name, container_format,
|
image = cls.client.create_image(name=name,
|
||||||
disk_format, **kwargs)
|
container_format=container_format,
|
||||||
|
disk_format=disk_format,
|
||||||
|
**kwargs)
|
||||||
# Image objects returned by the v1 client have the image
|
# Image objects returned by the v1 client have the image
|
||||||
# data inside a dict that is keyed against 'image'.
|
# data inside a dict that is keyed against 'image'.
|
||||||
if 'image' in image:
|
if 'image' in image:
|
||||||
@ -156,7 +158,7 @@ class BaseV2MemberImageTest(BaseV2ImageTest):
|
|||||||
|
|
||||||
def _create_image(self):
|
def _create_image(self):
|
||||||
name = data_utils.rand_name('image')
|
name = data_utils.rand_name('image')
|
||||||
image = self.os_img_client.create_image(name,
|
image = self.os_img_client.create_image(name=name,
|
||||||
container_format='bare',
|
container_format='bare',
|
||||||
disk_format='raw')
|
disk_format='raw')
|
||||||
image_id = image['id']
|
image_id = image['id']
|
||||||
|
@ -90,10 +90,12 @@ class ImagesNegativeTest(base.BaseV2ImageTest):
|
|||||||
def test_register_with_invalid_container_format(self):
|
def test_register_with_invalid_container_format(self):
|
||||||
# Negative tests for invalid data supplied to POST /images
|
# Negative tests for invalid data supplied to POST /images
|
||||||
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
|
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
|
||||||
'test', 'wrong', 'vhd')
|
name='test', container_format='wrong',
|
||||||
|
disk_format='vhd')
|
||||||
|
|
||||||
@test.attr(type=['negative'])
|
@test.attr(type=['negative'])
|
||||||
@test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1')
|
@test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1')
|
||||||
def test_register_with_invalid_disk_format(self):
|
def test_register_with_invalid_disk_format(self):
|
||||||
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
|
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
|
||||||
'test', 'bare', 'wrong')
|
name='test', container_format='bare',
|
||||||
|
disk_format='wrong')
|
||||||
|
@ -77,7 +77,7 @@ class BaseTelemetryTest(tempest.test.BaseTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create_image(cls, client):
|
def create_image(cls, client):
|
||||||
body = client.create_image(
|
body = client.create_image(
|
||||||
data_utils.rand_name('image'), container_format='bare',
|
name=data_utils.rand_name('image'), container_format='bare',
|
||||||
disk_format='raw', visibility='private')
|
disk_format='raw', visibility='private')
|
||||||
# TODO(jswarren) Move ['image'] up to initial body value assignment
|
# TODO(jswarren) Move ['image'] up to initial body value assignment
|
||||||
# once both v1 and v2 glance clients include the full response
|
# once both v1 and v2 glance clients include the full response
|
||||||
|
@ -55,6 +55,11 @@ class ImagesClientV2(service_client.ServiceClient):
|
|||||||
return self._http
|
return self._http
|
||||||
|
|
||||||
def update_image(self, image_id, patch):
|
def update_image(self, image_id, patch):
|
||||||
|
"""Update an image.
|
||||||
|
|
||||||
|
Available params: see http://developer.openstack.org/
|
||||||
|
api-ref-image-v2.html#updateImage-v2
|
||||||
|
"""
|
||||||
data = json.dumps(patch)
|
data = json.dumps(patch)
|
||||||
headers = {"Content-Type": "application/openstack-images-v2.0"
|
headers = {"Content-Type": "application/openstack-images-v2.0"
|
||||||
"-json-patch"}
|
"-json-patch"}
|
||||||
@ -63,21 +68,13 @@ class ImagesClientV2(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return service_client.ResponseBody(resp, body)
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def create_image(self, name, container_format, disk_format, **kwargs):
|
def create_image(self, **kwargs):
|
||||||
params = {
|
"""Create an image.
|
||||||
"name": name,
|
|
||||||
"container_format": container_format,
|
|
||||||
"disk_format": disk_format,
|
|
||||||
}
|
|
||||||
|
|
||||||
for option in kwargs:
|
Available params: see http://developer.openstack.org/
|
||||||
value = kwargs.get(option)
|
api-ref-image-v2.html#createImage-v2
|
||||||
if isinstance(value, dict) or isinstance(value, tuple):
|
"""
|
||||||
params.update(value)
|
data = json.dumps(kwargs)
|
||||||
else:
|
|
||||||
params[option] = value
|
|
||||||
|
|
||||||
data = json.dumps(params)
|
|
||||||
resp, body = self.post('v2/images', data)
|
resp, body = self.post('v2/images', data)
|
||||||
self.expected_success(201, resp.status)
|
self.expected_success(201, resp.status)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
|
Loading…
Reference in New Issue
Block a user