summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-07-07 16:52:32 -0400
committerAlex Meade <alex.meade@rackspace.com>2011-07-07 16:52:32 -0400
commita8c9082c701a65f221f218cd8baa92b3859fc0ab (patch)
tree886fa80ba05d5ba827edf07447606d89829f978a
parentd4540d2abde8db9519d8e4dad9b57a116a2c8b9e (diff)
Added server entity to images that only has id
-rw-r--r--nova/api/openstack/views/images.py5
-rw-r--r--nova/tests/api/openstack/test_images.py15
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",