From a8c9082c701a65f221f218cd8baa92b3859fc0ab Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 7 Jul 2011 16:52:32 -0400 Subject: Added server entity to images that only has id --- nova/api/openstack/views/images.py | 5 +++-- nova/tests/api/openstack/test_images.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py index ae8e73678..d1f89a785 100644 --- a/nova/api/openstack/views/images.py +++ b/nova/api/openstack/views/images.py @@ -99,8 +99,9 @@ class ViewBuilderV11(ViewBuilder): def _build_server(self, image, image_obj): try: serverRef = image_obj['properties']['instance_ref'] - #TODO (ameade) get the server information - #image['server'] = ? + image['server'] = { + "id": common.get_id_from_href(serverRef), + } except KeyError: return diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index d407057a8..87e5c6d7f 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -411,6 +411,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): "updated": self.NOW_API_FORMAT, "created": self.NOW_API_FORMAT, "status": "QUEUED", + 'server': { + 'id': 42, + }, "metadata": { "instance_ref": "http://localhost/v1.1/servers/42", "user_id": "1", @@ -652,6 +655,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, 'status': 'QUEUED', + 'server': { + 'id': 42, + }, "links": [{ "rel": "self", "href": "http://localhost/v1.1/images/124", @@ -672,6 +678,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'created': self.NOW_API_FORMAT, 'status': 'SAVING', 'progress': 0, + 'server': { + 'id': 42, + }, "links": [{ "rel": "self", "href": "http://localhost/v1.1/images/125", @@ -691,6 +700,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, 'status': 'ACTIVE', + 'server': { + 'id': 42, + }, "links": [{ "rel": "self", "href": "http://localhost/v1.1/images/126", @@ -710,6 +722,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, 'status': 'FAILED', + 'server': { + 'id': 42, + }, "links": [{ "rel": "self", "href": "http://localhost/v1.1/images/127", -- cgit