Commit 910df75d authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Add 'is_public' to Cyclades Image API

parent 2b6c70f9
......@@ -121,6 +121,7 @@ def image_to_dict(image, detail=True):
d['progress'] = 100 if status == 'ACTIVE' else 0
d['user_id'] = image['owner']
d['tenant_id'] = image['owner']
d['public'] = image["is_public"]
d['links'] = util.image_to_links(image["id"])
if image["properties"]:
d['metadata'] = image['properties']
......
......@@ -89,6 +89,7 @@ class ImageAPITest(BaseAPITest):
'owner': 'user1',
'deleted_at': '',
'is_snapshot': False,
'is_public': True,
'properties': {u'foo\u2610': u'bar\u2611'}},
{'id': 2,
'name': 'image-2',
......@@ -98,6 +99,7 @@ class ImageAPITest(BaseAPITest):
'owner': 'user1',
'deleted_at': '2012-12-27 11:52:54',
'is_snapshot': False,
'is_public': True,
'properties': ''},
{'id': 3,
'name': 'image-3',
......@@ -107,6 +109,7 @@ class ImageAPITest(BaseAPITest):
'updated_at': '2012-12-26 11:52:54',
'owner': 'user1',
'is_snapshot': False,
'is_public': False,
'properties': ''}]
result_images = [
{'id': 1,
......@@ -118,6 +121,7 @@ class ImageAPITest(BaseAPITest):
'user_id': 'user1',
'tenant_id': 'user1',
'is_snapshot': False,
'public': True,
'metadata': {u'foo\u2610': u'bar\u2611'}},
{'id': 2,
'name': 'image-2',
......@@ -128,6 +132,7 @@ class ImageAPITest(BaseAPITest):
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'is_snapshot': False,
'public': True,
'metadata': {}},
{'id': 3,
'name': 'image-3',
......@@ -138,6 +143,7 @@ class ImageAPITest(BaseAPITest):
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'is_snapshot': False,
'public': False,
'metadata': {}}]
mimage().__enter__().list_images.return_value = images
response = self.get(join_urls(IMAGES_URL, "detail"), 'user')
......@@ -157,13 +163,14 @@ class ImageAPITest(BaseAPITest):
images = [
{'id': 1,
'name': 'image-1',
'status':'available',
'status': 'available',
'progress': 100,
'created_at': old_time.isoformat(),
'deleted_at': '',
'updated_at': old_time.isoformat(),
'owner': 'user1',
'is_snapshot': False,
'is_public': True,
'properties': ''},
{'id': 2,
'name': 'image-2',
......@@ -174,6 +181,7 @@ class ImageAPITest(BaseAPITest):
'updated_at': new_time.isoformat(),
'deleted_at': new_time.isoformat(),
'is_snapshot': False,
'is_public': False,
'properties': ''}]
mimage().__enter__().list_images.return_value = images
response =\
......@@ -194,6 +202,7 @@ class ImageAPITest(BaseAPITest):
'deleted_at': '',
'owner': 'user1',
'is_snapshot': False,
'is_public': True,
'properties': {'foo': 'bar'}}
result_image = \
{'id': 42,
......@@ -205,6 +214,7 @@ class ImageAPITest(BaseAPITest):
'user_id': 'user1',
'tenant_id': 'user1',
'is_snapshot': False,
'public': True,
'metadata': {'foo': 'bar'}}
mimage().__enter__().get_image.return_value = image
response = self.get(join_urls(IMAGES_URL, "42"), 'user')
......@@ -230,7 +240,7 @@ class ImageAPITest(BaseAPITest):
response = self.get(join_urls(IMAGES_URL, 'nonexistent/lala/foo'))
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
json.loads(response.content)
except ValueError:
self.assertTrue(False)
......@@ -264,20 +274,20 @@ class ImageAPITest(BaseAPITest):
class ImageMetadataAPITest(BaseAPITest):
def setUp(self):
self.image = {'id': 42,
'name': 'image-1',
'status': 'available',
'created_at': '2012-11-26 11:52:54',
'updated_at': '2012-12-26 11:52:54',
'deleted_at': '',
'properties': {'foo': 'bar', 'foo2': 'bar2'}}
'name': 'image-1',
'status': 'available',
'created_at': '2012-11-26 11:52:54',
'updated_at': '2012-12-26 11:52:54',
'deleted_at': '',
'properties': {'foo': 'bar', 'foo2': 'bar2'}}
self.result_image = \
{'id': 42,
'name': 'image-1',
'status': 'ACTIVE',
'progress': 100,
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'metadata': {'foo': 'bar'}}
{'id': 42,
'name': 'image-1',
'status': 'ACTIVE',
'progress': 100,
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'metadata': {'foo': 'bar'}}
super(ImageMetadataAPITest, self).setUp()
@assert_backend_closed
......
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