Commit e99f9efb authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Allow image_register to accept a location tuple

Refs: #3778

Location tuple: (user_uuid, container, image_object)
parent b773795c
......@@ -103,7 +103,9 @@ class ImageClient(Client):
:param name: (str)
:param location: (str) pithos://<account>/<container>/<path>
:param location: (str or iterable) if iterable, then
(user_uuid, container, image_path) else if string
pithos://<user_uuid>/<container>/<image object>
:param params: (dict) image metadata (X-Image-Meta) can be id, store,
disc_format, container_format, size, checksum, is_public, owner
......@@ -114,6 +116,9 @@ class ImageClient(Client):
"""
path = path4url('images') + '/'
self.set_header('X-Image-Meta-Name', name)
location = location if (
isinstance(location, str) or isinstance(location, unicode)) else (
'pithos://%s' % '/'.join(location))
self.set_header('X-Image-Meta-Location', location)
async_headers = {}
......
......@@ -224,8 +224,7 @@ class ImageClient(TestCase):
props['%s%s' % (proprfx, args[i])] = k
async_headers.update(props)
r = self.client.register(
img0_name, img0_location,
params=params, properties=props)
img0_name, img0_location, params=params, properties=props)
expectedict = dict(example_image_headers)
expectedict.pop('extraheaders')
from kamaki.clients.image import _format_image_headers
......@@ -236,6 +235,13 @@ class ImageClient(TestCase):
self.assertEqual(SH.mock_calls[-2:], [
call('X-Image-Meta-Name', img0_name),
call('X-Image-Meta-Location', img0_location)])
img1_location = ('some_uuid', 'some_container', 'some/path')
r = self.client.register(
img0_name, img1_location, params=params, properties=props)
img1_location = 'pithos://%s' % '/'.join(img1_location)
self.assertEqual(SH.mock_calls[-2:], [
call('X-Image-Meta-Name', img0_name),
call('X-Image-Meta-Location', img1_location)])
@patch('%s.delete' % image_pkg)
def test_unregister(self, delete):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment