From 38f949608fc3faaae855bf91719a074c1c545a1d Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Wed, 13 Jul 2011 16:22:55 -0400 Subject: updated to support and check for flavor links in server detail response --- nova/api/openstack/views/servers.py | 11 +++++++++++ nova/tests/api/openstack/test_servers.py | 31 ++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) (limited to 'nova') diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 7fb180246..e17edd6b6 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -163,8 +163,19 @@ class ViewBuilderV11(ViewBuilder): if "instance_type" in dict(inst): flavor_id = inst["instance_type"]['flavorid'] flavor_ref = self.flavor_builder.generate_href(flavor_id) + flavor_bookmark = self.flavor_builder.generate_bookmark(flavor_id) response["flavor"] = { "id": common.get_uuid_from_href(flavor_ref), + "links": [ + { + "rel": "self", + "href": flavor_ref, + }, + { + "rel": "bookmark", + "href": flavor_bookmark, + }, + ] } def _build_extra(self, response, inst): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 0d122762b..ab24b328a 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -124,11 +124,12 @@ def instance_addresses(context, instance_id): def stub_instance(id, user_id=1, private_address=None, public_addresses=None, host=None, power_state=0, reservation_id="", - uuid=FAKE_UUID, image_ref="10", flavor_ref="1"): + uuid=FAKE_UUID, image_ref="10", flavor_id="1"): metadata = [] metadata.append(InstanceMetadata(key='seq', value=id)) - inst_type = instance_types.get_instance_type_by_flavor_id(int(flavor_ref)) + + inst_type = instance_types.get_instance_type_by_flavor_id(int(flavor_id)) if public_addresses is None: public_addresses = list() @@ -280,8 +281,8 @@ class ServersTest(test.TestCase): self.maxDiff = None image_ref = "http://localhost/v1.1/images/10" image_bookmark = "http://localhost/images/10" - #flavor_ref = "http://localhost/v1.1/flavors/1" - flavor_ref = "1" + flavor_ref = "http://localhost/v1.1/flavors/1" + flavor_id = "1" flavor_bookmark = "http://localhost/flavors/1" private = "192.168.0.3" public = ["1.2.3.4"] @@ -292,7 +293,7 @@ class ServersTest(test.TestCase): public_addresses=public, power_state=0, image_ref=image_ref, - flavor_ref=flavor_ref, + flavor_id=flavor_id, ) self.stubs.Set(nova.db.api, 'instance_get', _return_server) @@ -322,16 +323,16 @@ class ServersTest(test.TestCase): }, "flavor": { "id": "1", - #"links": [ - #{ - #"rel": "self", - #"href": flavor_ref, - #}, - #{ - #"rel": "bookmark", - #"href": flavor_bookmark, - #}, - #], + "links": [ + { + "rel": "self", + "href": flavor_ref, + }, + { + "rel": "bookmark", + "href": flavor_bookmark, + }, + ], }, "addresses": { "public": [ -- cgit