From dd66f235ecf2ff67819917ee07bcb0ea13a1b17b Mon Sep 17 00:00:00 2001 From: Oleg Bondarev Date: Wed, 17 Apr 2013 18:18:03 +0400 Subject: Include list of attached volumes with instance info Fixes bug 1112998 Change-Id: I1c3eb578339aabbcfed107043f39e30daf633c4a --- .../OS-DCF/list-servers-detail-get.json | 3 +- .../OS-DCF/server-action-rebuild-resp.json | 3 +- doc/api_samples/OS-DCF/server-get-resp.json | 3 +- doc/api_samples/OS-DCF/server-update-put-resp.json | 3 +- doc/api_samples/OS-EXT-AZ/server-get-resp.json | 3 +- doc/api_samples/OS-EXT-AZ/servers-detail-resp.json | 3 +- .../OS-EXT-IPS-MAC/server-get-resp.json | 3 +- .../OS-EXT-IPS-MAC/servers-detail-resp.json | 3 +- doc/api_samples/OS-EXT-IPS/server-get-resp.json | 3 +- .../OS-EXT-IPS/servers-detail-resp.json | 3 +- .../OS-EXT-SRV-ATTR/server-get-resp.json | 3 +- .../OS-EXT-SRV-ATTR/servers-detail-resp.json | 3 +- doc/api_samples/OS-EXT-STS/server-get-resp.json | 3 +- .../OS-EXT-STS/servers-detail-resp.json | 3 +- .../all_extensions/server-action-rebuild-resp.json | 3 +- .../all_extensions/server-get-resp.json | 6 +- doc/api_samples/all_extensions/server-get-resp.xml | 2 + .../all_extensions/servers-details-resp.json | 6 +- .../all_extensions/servers-details-resp.xml | 2 + .../server-config-drive-get-resp.json | 3 +- .../servers-config-drive-details-resp.json | 3 +- .../os-hide-server-addresses/server-get-resp.json | 6 +- .../os-hide-server-addresses/server-get-resp.xml | 2 + .../servers-details-resp.json | 6 +- .../servers-details-resp.xml | 2 + .../os-rescue/server-get-resp-rescue.json | 3 +- .../os-rescue/server-get-resp-unrescue.json | 3 +- doc/api_samples/server-action-rebuild-resp.json | 3 +- doc/api_samples/server-get-resp.json | 6 +- doc/api_samples/server-get-resp.xml | 2 + doc/api_samples/servers-details-resp.json | 6 +- doc/api_samples/servers-details-resp.xml | 2 + nova/api/openstack/compute/servers.py | 14 ++ nova/api/openstack/compute/views/servers.py | 2 + nova/tests/api/openstack/compute/test_servers.py | 141 +++++++++++++++++++++ nova/tests/api/openstack/fakes.py | 4 + .../OS-DCF/list-servers-detail-get.json.tpl | 3 +- .../OS-DCF/server-action-rebuild-resp.json.tpl | 3 +- .../api_samples/OS-DCF/server-get-resp.json.tpl | 3 +- .../OS-DCF/server-update-put-resp.json.tpl | 3 +- .../api_samples/OS-EXT-AZ/server-get-resp.json.tpl | 3 +- .../OS-EXT-AZ/servers-detail-resp.json.tpl | 3 +- .../OS-EXT-IPS-MAC/server-get-resp.json.tpl | 3 +- .../OS-EXT-IPS-MAC/servers-detail-resp.json.tpl | 3 +- .../OS-EXT-IPS/server-get-resp.json.tpl | 3 +- .../OS-EXT-IPS/servers-detail-resp.json.tpl | 3 +- .../OS-EXT-SRV-ATTR/server-get-resp.json.tpl | 3 +- .../OS-EXT-SRV-ATTR/servers-detail-resp.json.tpl | 3 +- .../OS-EXT-STS/server-get-resp.json.tpl | 3 +- .../OS-EXT-STS/servers-detail-resp.json.tpl | 3 +- .../server-action-rebuild-resp.json.tpl | 3 +- .../all_extensions/server-get-resp.json.tpl | 6 +- .../all_extensions/server-get-resp.xml.tpl | 2 + .../all_extensions/servers-details-resp.json.tpl | 6 +- .../all_extensions/servers-details-resp.xml.tpl | 2 + .../server-config-drive-get-resp.json.tpl | 3 +- .../servers-config-drive-details-resp.json.tpl | 3 +- .../server-get-resp.json.tpl | 6 +- .../server-get-resp.xml.tpl | 2 + .../servers-details-resp.json.tpl | 6 +- .../servers-details-resp.xml.tpl | 2 + .../os-rescue/server-get-resp-rescue.json.tpl | 3 +- .../os-rescue/server-get-resp-unrescue.json.tpl | 3 +- .../server-action-rebuild-resp.json.tpl | 3 +- .../api_samples/server-get-resp.json.tpl | 6 +- .../integrated/api_samples/server-get-resp.xml.tpl | 2 + .../api_samples/servers-details-resp.json.tpl | 6 +- .../api_samples/servers-details-resp.xml.tpl | 2 + nova/tests/integrated/test_api_samples.py | 4 + 69 files changed, 329 insertions(+), 52 deletions(-) diff --git a/doc/api_samples/OS-DCF/list-servers-detail-get.json b/doc/api_samples/OS-DCF/list-servers-detail-get.json index 7aea51e19..3b0c66329 100644 --- a/doc/api_samples/OS-DCF/list-servers-detail-get.json +++ b/doc/api_samples/OS-DCF/list-servers-detail-get.json @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-02T02:11:56Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/doc/api_samples/OS-DCF/server-action-rebuild-resp.json b/doc/api_samples/OS-DCF/server-action-rebuild-resp.json index 24e1e5d04..2f6be80e1 100644 --- a/doc/api_samples/OS-DCF/server-action-rebuild-resp.json +++ b/doc/api_samples/OS-DCF/server-action-rebuild-resp.json @@ -51,6 +51,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-02T02:11:56Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-DCF/server-get-resp.json b/doc/api_samples/OS-DCF/server-get-resp.json index 4ad77036f..94742a806 100644 --- a/doc/api_samples/OS-DCF/server-get-resp.json +++ b/doc/api_samples/OS-DCF/server-get-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-02T02:11:55Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-DCF/server-update-put-resp.json b/doc/api_samples/OS-DCF/server-update-put-resp.json index ce6e08455..9750db476 100644 --- a/doc/api_samples/OS-DCF/server-update-put-resp.json +++ b/doc/api_samples/OS-DCF/server-update-put-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-02T02:11:58Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-AZ/server-get-resp.json b/doc/api_samples/OS-EXT-AZ/server-get-resp.json index c2f0fb2ba..e98b9bc43 100644 --- a/doc/api_samples/OS-EXT-AZ/server-get-resp.json +++ b/doc/api_samples/OS-EXT-AZ/server-get-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-01-30T13:38:49Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/doc/api_samples/OS-EXT-AZ/servers-detail-resp.json b/doc/api_samples/OS-EXT-AZ/servers-detail-resp.json index 2ecea959a..b9310e101 100644 --- a/doc/api_samples/OS-EXT-AZ/servers-detail-resp.json +++ b/doc/api_samples/OS-EXT-AZ/servers-detail-resp.json @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-01-30T13:26:52Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } diff --git a/doc/api_samples/OS-EXT-IPS-MAC/server-get-resp.json b/doc/api_samples/OS-EXT-IPS-MAC/server-get-resp.json index 50b53d810..2767c5c0e 100644 --- a/doc/api_samples/OS-EXT-IPS-MAC/server-get-resp.json +++ b/doc/api_samples/OS-EXT-IPS-MAC/server-get-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:46:29Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/doc/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json b/doc/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json index 115780401..41b1c37c9 100644 --- a/doc/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json +++ b/doc/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:40:59Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } diff --git a/doc/api_samples/OS-EXT-IPS/server-get-resp.json b/doc/api_samples/OS-EXT-IPS/server-get-resp.json index e985ad115..66b710eda 100644 --- a/doc/api_samples/OS-EXT-IPS/server-get-resp.json +++ b/doc/api_samples/OS-EXT-IPS/server-get-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:46:29Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-IPS/servers-detail-resp.json b/doc/api_samples/OS-EXT-IPS/servers-detail-resp.json index cb91d6937..2127ffc1e 100644 --- a/doc/api_samples/OS-EXT-IPS/servers-detail-resp.json +++ b/doc/api_samples/OS-EXT-IPS/servers-detail-resp.json @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:40:59Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json b/doc/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json index ad3bcab5d..31b8687b4 100644 --- a/doc/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json +++ b/doc/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json @@ -52,6 +52,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-11-15T19:27:04Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json b/doc/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json index db3de77f4..b980c0857 100644 --- a/doc/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json +++ b/doc/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json @@ -53,7 +53,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-11-15T19:27:05Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-STS/server-get-resp.json b/doc/api_samples/OS-EXT-STS/server-get-resp.json index 763426bb1..7836dedc3 100644 --- a/doc/api_samples/OS-EXT-STS/server-get-resp.json +++ b/doc/api_samples/OS-EXT-STS/server-get-resp.json @@ -52,6 +52,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T19:35:10Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-STS/servers-detail-resp.json b/doc/api_samples/OS-EXT-STS/servers-detail-resp.json index 6764bd883..e67524e55 100644 --- a/doc/api_samples/OS-EXT-STS/servers-detail-resp.json +++ b/doc/api_samples/OS-EXT-STS/servers-detail-resp.json @@ -53,7 +53,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-05T07:34:10Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/doc/api_samples/all_extensions/server-action-rebuild-resp.json b/doc/api_samples/all_extensions/server-action-rebuild-resp.json index 04ee1d4fb..49fe6c8c6 100644 --- a/doc/api_samples/all_extensions/server-action-rebuild-resp.json +++ b/doc/api_samples/all_extensions/server-action-rebuild-resp.json @@ -51,6 +51,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-09-25T13:36:09Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/all_extensions/server-get-resp.json b/doc/api_samples/all_extensions/server-get-resp.json index 67a33cab1..2b2503e53 100644 --- a/doc/api_samples/all_extensions/server-get-resp.json +++ b/doc/api_samples/all_extensions/server-get-resp.json @@ -66,6 +66,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:58:57Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } diff --git a/doc/api_samples/all_extensions/server-get-resp.xml b/doc/api_samples/all_extensions/server-get-resp.xml index 6db40414b..52598a5db 100644 --- a/doc/api_samples/all_extensions/server-get-resp.xml +++ b/doc/api_samples/all_extensions/server-get-resp.xml @@ -15,6 +15,8 @@ OS-EXT-IPS-MAC:mac_addr="00:0c:29:e1:42:90"/> + + diff --git a/doc/api_samples/all_extensions/servers-details-resp.json b/doc/api_samples/all_extensions/servers-details-resp.json index 05f11a246..5fd189443 100644 --- a/doc/api_samples/all_extensions/servers-details-resp.json +++ b/doc/api_samples/all_extensions/servers-details-resp.json @@ -67,7 +67,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-07T18:58:57Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } diff --git a/doc/api_samples/all_extensions/servers-details-resp.xml b/doc/api_samples/all_extensions/servers-details-resp.xml index 8061caf21..7a3ccbbe7 100644 --- a/doc/api_samples/all_extensions/servers-details-resp.xml +++ b/doc/api_samples/all_extensions/servers-details-resp.xml @@ -15,6 +15,8 @@ + + diff --git a/doc/api_samples/os-config-drive/server-config-drive-get-resp.json b/doc/api_samples/os-config-drive/server-config-drive-get-resp.json index 8745b3d62..e0adab26a 100644 --- a/doc/api_samples/os-config-drive/server-config-drive-get-resp.json +++ b/doc/api_samples/os-config-drive/server-config-drive-get-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-04T13:17:51Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json index 1373721ef..2af535ff2 100644 --- a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json +++ b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2013-02-04T13:21:44Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/doc/api_samples/os-hide-server-addresses/server-get-resp.json b/doc/api_samples/os-hide-server-addresses/server-get-resp.json index b4209f461..982cb9a74 100644 --- a/doc/api_samples/os-hide-server-addresses/server-get-resp.json +++ b/doc/api_samples/os-hide-server-addresses/server-get-resp.json @@ -49,6 +49,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-19T20:32:42Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } \ No newline at end of file diff --git a/doc/api_samples/os-hide-server-addresses/server-get-resp.xml b/doc/api_samples/os-hide-server-addresses/server-get-resp.xml index caa4a2fa5..4eb8999aa 100644 --- a/doc/api_samples/os-hide-server-addresses/server-get-resp.xml +++ b/doc/api_samples/os-hide-server-addresses/server-get-resp.xml @@ -14,6 +14,8 @@ + + \ No newline at end of file diff --git a/doc/api_samples/os-hide-server-addresses/servers-details-resp.json b/doc/api_samples/os-hide-server-addresses/servers-details-resp.json index 3787cd707..bdd37a4c0 100644 --- a/doc/api_samples/os-hide-server-addresses/servers-details-resp.json +++ b/doc/api_samples/os-hide-server-addresses/servers-details-resp.json @@ -50,7 +50,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-12-19T20:32:39Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } \ No newline at end of file diff --git a/doc/api_samples/os-hide-server-addresses/servers-details-resp.xml b/doc/api_samples/os-hide-server-addresses/servers-details-resp.xml index 0296cc167..0fc121880 100644 --- a/doc/api_samples/os-hide-server-addresses/servers-details-resp.xml +++ b/doc/api_samples/os-hide-server-addresses/servers-details-resp.xml @@ -15,6 +15,8 @@ + + diff --git a/doc/api_samples/os-rescue/server-get-resp-rescue.json b/doc/api_samples/os-rescue/server-get-resp-rescue.json index d08191977..926327080 100644 --- a/doc/api_samples/os-rescue/server-get-resp-rescue.json +++ b/doc/api_samples/os-rescue/server-get-resp-rescue.json @@ -48,6 +48,7 @@ "status": "RESCUE", "tenant_id": "openstack", "updated": "2012-09-19T09:22:27Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-get-resp-unrescue.json b/doc/api_samples/os-rescue/server-get-resp-unrescue.json index 21a35da7f..5ab7a742e 100644 --- a/doc/api_samples/os-rescue/server-get-resp-unrescue.json +++ b/doc/api_samples/os-rescue/server-get-resp-unrescue.json @@ -49,6 +49,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-09-19T09:22:28Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/server-action-rebuild-resp.json b/doc/api_samples/server-action-rebuild-resp.json index ac6d6e7e5..49ef1b4ae 100644 --- a/doc/api_samples/server-action-rebuild-resp.json +++ b/doc/api_samples/server-action-rebuild-resp.json @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-09-12T17:20:37Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/doc/api_samples/server-get-resp.json b/doc/api_samples/server-get-resp.json index c6ebd4195..138f186eb 100644 --- a/doc/api_samples/server-get-resp.json +++ b/doc/api_samples/server-get-resp.json @@ -49,6 +49,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-08-20T21:11:09Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } \ No newline at end of file diff --git a/doc/api_samples/server-get-resp.xml b/doc/api_samples/server-get-resp.xml index e59319e42..528707810 100644 --- a/doc/api_samples/server-get-resp.xml +++ b/doc/api_samples/server-get-resp.xml @@ -14,6 +14,8 @@ + + \ No newline at end of file diff --git a/doc/api_samples/servers-details-resp.json b/doc/api_samples/servers-details-resp.json index 3ea61531e..ac27a00dd 100644 --- a/doc/api_samples/servers-details-resp.json +++ b/doc/api_samples/servers-details-resp.json @@ -50,7 +50,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "2012-09-07T16:56:37Z", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } \ No newline at end of file diff --git a/doc/api_samples/servers-details-resp.xml b/doc/api_samples/servers-details-resp.xml index 83bcf0f79..eab2bd887 100644 --- a/doc/api_samples/servers-details-resp.xml +++ b/doc/api_samples/servers-details-resp.xml @@ -15,6 +15,8 @@ + + diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 94912da97..56375e317 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -97,6 +97,11 @@ def make_server(elem, detailed=False): # Attach addresses node elem.append(ips.AddressesTemplate()) + # Attach volumes_attached node + volumes = xmlutil.SubTemplateElement(elem, 'volume_attached', + selector='volumes_attached') + volumes.set('id') + xmlutil.make_links(elem, 'links') @@ -493,6 +498,13 @@ class Controller(wsgi.Controller): return instances + def _add_instance_volumes(self, context, instances): + for instance in instances: + bdms = self.compute_api.get_instance_bdms(context, instance) + volumes = [bdm['volume_id'] for bdm in bdms if bdm['volume_id']] + if volumes: + instance['volumes_attached'] = volumes + def _get_servers(self, req, is_detail): """Returns a list of servers, based on any search options specified.""" @@ -560,6 +572,7 @@ class Controller(wsgi.Controller): if is_detail: self._add_instance_faults(context, instance_list) + self._add_instance_volumes(context, instance_list) response = self._view_builder.detail(req, instance_list) else: response = self._view_builder.index(req, instance_list) @@ -736,6 +749,7 @@ class Controller(wsgi.Controller): instance = self.compute_api.get(context, id) req.cache_db_instance(instance) self._add_instance_faults(context, [instance]) + self._add_instance_volumes(context, [instance]) return self._view_builder.show(req, instance) except exception.NotFound: msg = _("Instance could not be found") diff --git a/nova/api/openstack/compute/views/servers.py b/nova/api/openstack/compute/views/servers.py index f00ab9921..37f6ee4f3 100644 --- a/nova/api/openstack/compute/views/servers.py +++ b/nova/api/openstack/compute/views/servers.py @@ -108,6 +108,8 @@ class ViewBuilder(common.ViewBuilder): "links": self._get_links(request, instance["uuid"], self._collection_name), + "volumes_attached": [{'id': vol_id} for vol_id in + instance.get("volumes_attached", [])], }, } _inst_fault = self._get_fault(request, instance) diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 4fe8a41db..6f03fc523 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -314,6 +314,7 @@ class ServersControllerTest(test.TestCase): "href": "http://localhost/fake/servers/%s" % uuid, }, ], + "volumes_attached": [], } } @@ -380,6 +381,7 @@ class ServersControllerTest(test.TestCase): "href": "http://localhost/fake/servers/%s" % uuid, }, ], + "volumes_attached": [], } } @@ -449,11 +451,79 @@ class ServersControllerTest(test.TestCase): "href": "http://localhost/fake/servers/%s" % uuid, }, ], + "volumes_attached": [], } } self.assertThat(res_dict, matchers.DictMatches(expected_server)) + def test_get_server_with_volumes_attached(self): + image_bookmark = "http://localhost/fake/images/10" + flavor_bookmark = "http://localhost/fake/flavors/1" + + self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', + fakes.stub_bdm_get_all_by_instance) + + uuid = FAKE_UUID + req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % uuid) + res_dict = self.controller.show(req, uuid) + expected_server = { + "server": { + "id": uuid, + "user_id": "fake_user", + "tenant_id": "fake_project", + "updated": "2010-11-11T11:00:00Z", + "created": "2010-10-10T12:00:00Z", + "progress": 0, + "name": "server1", + "status": "BUILD", + "accessIPv4": "", + "accessIPv6": "", + "hostId": '', + "image": { + "id": "10", + "links": [ + { + "rel": "bookmark", + "href": image_bookmark, + }, + ], + }, + "flavor": { + "id": "1", + "links": [ + { + "rel": "bookmark", + "href": flavor_bookmark, + }, + ], + }, + "addresses": { + 'test1': [ + {'version': 4, 'addr': '192.168.1.100'}, + {'version': 6, 'addr': '2001:db8:0:1::1'} + ] + }, + "metadata": { + "seq": "1", + }, + "links": [ + { + "rel": "self", + "href": "http://localhost/v2/fake/servers/%s" % uuid, + }, + { + "rel": "bookmark", + "href": "http://localhost/fake/servers/%s" % uuid, + }, + ], + "volumes_attached": [{'id': 'volume_id1'}, + {'id': 'volume_id2'}], + } + } + + self.assertThat(res_dict, matchers.DictMatches(expected_server)) + def test_get_server_addresses_from_cache(self): pub0 = ('172.19.0.1', '172.19.0.2',) pub1 = ('1.2.3.4',) @@ -4200,6 +4270,7 @@ class ServersViewBuilderTest(test.TestCase): "href": bookmark_link, }, ], + "volumes_attached": [], } } @@ -4278,6 +4349,7 @@ class ServersViewBuilderTest(test.TestCase): "message": "HTTPNotFound", "details": "Stock details for test", }, + "volumes_attached": [], } } @@ -4418,6 +4490,7 @@ class ServersViewBuilderTest(test.TestCase): "href": bookmark_link, }, ], + "volumes_attached": [], } } @@ -4480,6 +4553,7 @@ class ServersViewBuilderTest(test.TestCase): "href": bookmark_link, }, ], + "volumes_attached": [], } } @@ -4542,6 +4616,7 @@ class ServersViewBuilderTest(test.TestCase): "href": bookmark_link, }, ], + "volumes_attached": [], } } @@ -4606,12 +4681,78 @@ class ServersViewBuilderTest(test.TestCase): "href": bookmark_link, }, ], + "volumes_attached": [], } } output = self.view_builder.show(self.request, self.instance) self.assertThat(output, matchers.DictMatches(expected_server)) + def test_build_server_detail_with_volumes_attached(self): + + volumes_attached = ['volume_id1', 'volume_id2'] + self.instance['volumes_attached'] = volumes_attached + + image_bookmark = "http://localhost/fake/images/5" + flavor_bookmark = "http://localhost/fake/flavors/1" + self_link = "http://localhost/v2/fake/servers/%s" % self.uuid + bookmark_link = "http://localhost/fake/servers/%s" % self.uuid + expected_server = { + "server": { + "id": self.uuid, + "user_id": "fake_user", + "tenant_id": "fake_project", + "updated": "2010-11-11T11:00:00Z", + "created": "2010-10-10T12:00:00Z", + "progress": 0, + "name": "test_server", + "status": "BUILD", + "accessIPv4": "", + "accessIPv6": "", + "hostId": '', + "image": { + "id": "5", + "links": [ + { + "rel": "bookmark", + "href": image_bookmark, + }, + ], + }, + "flavor": { + "id": "1", + "links": [ + { + "rel": "bookmark", + "href": flavor_bookmark, + }, + ], + }, + "addresses": { + 'test1': [ + {'version': 4, 'addr': '192.168.1.100'}, + {'version': 6, 'addr': '2001:db8:0:1::1'} + ] + }, + "metadata": {}, + "links": [ + { + "rel": "self", + "href": self_link, + }, + { + "rel": "bookmark", + "href": bookmark_link, + }, + ], + "volumes_attached": [{'id': vol_id} for vol_id in + volumes_attached], + } + } + + output = self.view_builder.show(self.request, self.instance) + self.assertThat(output, matchers.DictMatches(expected_server)) + class ServerXMLSerializationTest(test.TestCase): diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 386d27618..c3c4644fc 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -631,3 +631,7 @@ def stub_snapshot_get_all(self, context): return [stub_snapshot(100, project_id='fake'), stub_snapshot(101, project_id='superfake'), stub_snapshot(102, project_id='superduperfake')] + + +def stub_bdm_get_all_by_instance(context, instance_uuid): + return [{'volume_id': 'volume_id1'}, {'volume_id': 'volume_id2'}] diff --git a/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl index acb9bf531..c24c61ce3 100644 --- a/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl +++ b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl index 1608b9f6b..9a4ab81b9 100644 --- a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl @@ -51,6 +51,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl index 25e51a878..dbeb3f325 100644 --- a/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl index 25e51a878..dbeb3f325 100644 --- a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-EXT-AZ/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-AZ/server-get-resp.json.tpl index 413f3ce95..c4ff3b432 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-AZ/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-AZ/server-get-resp.json.tpl @@ -50,6 +50,7 @@ "progress": 0, "status": "ACTIVE", "tenant_id": "openstack", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-EXT-AZ/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-AZ/servers-detail-resp.json.tpl index 362c85085..3d777ba34 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-AZ/servers-detail-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-AZ/servers-detail-resp.json.tpl @@ -51,7 +51,8 @@ "progress": 0, "status": "ACTIVE", "tenant_id": "openstack", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } diff --git a/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/server-get-resp.json.tpl index 600a063c3..05ceee13b 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/server-get-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json.tpl index 6b5901098..d2224b8c0 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-IPS-MAC/servers-detail-resp.json.tpl @@ -51,6 +51,7 @@ "hostId": "%(hostid)s", "metadata": { "My Server Name": "Apache1" - } + }, + "volumes_attached": [] }] } diff --git a/nova/tests/integrated/api_samples/OS-EXT-IPS/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-IPS/server-get-resp.json.tpl index bea96d4f6..7bd189bf3 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-IPS/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-IPS/server-get-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-EXT-IPS/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-IPS/servers-detail-resp.json.tpl index 27c6faa4e..8ce04e474 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-IPS/servers-detail-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-IPS/servers-detail-resp.json.tpl @@ -51,6 +51,7 @@ "hostId": "%(hostid)s", "metadata": { "My Server Name": "Apache1" - } + }, + "volumes_attached": [] }] } diff --git a/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json.tpl index c70192949..c81e814b7 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/server-get-resp.json.tpl @@ -52,6 +52,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json.tpl index 1fb8e1a47..0f7da9870 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-SRV-ATTR/servers-detail-resp.json.tpl @@ -53,7 +53,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/server-get-resp.json.tpl index 7ac35024b..d6a86c8fb 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-STS/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/server-get-resp.json.tpl @@ -52,6 +52,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl index a060332d4..a4818165d 100644 --- a/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl @@ -53,6 +53,7 @@ "hostId": "%(hostid)s", "metadata": { "My Server Name": "Apache1" - } + }, + "volumes_attached": [] }] } diff --git a/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.json.tpl index 884be7549..3421225ed 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.json.tpl @@ -51,6 +51,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl index 22be331e4..0fa93402b 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl @@ -66,6 +66,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl index 35fe0a6c3..211259fe5 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl @@ -15,6 +15,8 @@ OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/> + + diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl index 649aa6f9b..84a5eb47d 100644 --- a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl @@ -67,7 +67,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl index 6ac363176..3f4f72495 100644 --- a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl @@ -16,6 +16,8 @@ OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/> + + diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl index ea47da06c..54d1e7c2f 100644 --- a/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl index 535d00410..4235c51c1 100644 --- a/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl @@ -51,7 +51,8 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } ] } diff --git a/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.json.tpl index 86e39aedc..8c19e34c6 100644 --- a/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.json.tpl @@ -49,6 +49,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } diff --git a/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.xml.tpl index adc8a5c1b..07db2436c 100644 --- a/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-hide-server-addresses/server-get-resp.xml.tpl @@ -14,6 +14,8 @@ + + diff --git a/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.json.tpl b/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.json.tpl index e244ea0df..1f96734bc 100644 --- a/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.json.tpl @@ -50,7 +50,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } diff --git a/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.xml.tpl b/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.xml.tpl index 568807ecb..90d38375a 100644 --- a/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-hide-server-addresses/servers-details-resp.xml.tpl @@ -15,6 +15,8 @@ + + diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl index 011ed6396..03d4cfa03 100644 --- a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl @@ -48,6 +48,7 @@ "status": "%(status)s", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl index bc483c6da..366bdcef6 100644 --- a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl @@ -49,6 +49,7 @@ "status": "%(status)s", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/server-action-rebuild-resp.json.tpl b/nova/tests/integrated/api_samples/server-action-rebuild-resp.json.tpl index 9c16a15f0..d6da7ec07 100644 --- a/nova/tests/integrated/api_samples/server-action-rebuild-resp.json.tpl +++ b/nova/tests/integrated/api_samples/server-action-rebuild-resp.json.tpl @@ -50,6 +50,7 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [] } } diff --git a/nova/tests/integrated/api_samples/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/server-get-resp.json.tpl index 86e39aedc..8c19e34c6 100644 --- a/nova/tests/integrated/api_samples/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/server-get-resp.json.tpl @@ -49,6 +49,10 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } } diff --git a/nova/tests/integrated/api_samples/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/server-get-resp.xml.tpl index adc8a5c1b..07db2436c 100644 --- a/nova/tests/integrated/api_samples/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/server-get-resp.xml.tpl @@ -14,6 +14,8 @@ + + diff --git a/nova/tests/integrated/api_samples/servers-details-resp.json.tpl b/nova/tests/integrated/api_samples/servers-details-resp.json.tpl index e244ea0df..1f96734bc 100644 --- a/nova/tests/integrated/api_samples/servers-details-resp.json.tpl +++ b/nova/tests/integrated/api_samples/servers-details-resp.json.tpl @@ -50,7 +50,11 @@ "status": "ACTIVE", "tenant_id": "openstack", "updated": "%(timestamp)s", - "user_id": "fake" + "user_id": "fake", + "volumes_attached": [ + {"id": "volume_id1"}, + {"id": "volume_id2"} + ] } ] } diff --git a/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl b/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl index 568807ecb..90d38375a 100644 --- a/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl @@ -15,6 +15,8 @@ + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 188f96055..cc5455c7f 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -456,6 +456,8 @@ class ServersSampleJsonTest(ServersSampleBase): def test_servers_get(self): uuid = self.test_servers_post() + self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', + fakes.stub_bdm_get_all_by_instance) response = self._do_get('servers/%s' % uuid) subs = self._get_regexes() subs['hostid'] = '[a-f0-9]+' @@ -473,6 +475,8 @@ class ServersSampleJsonTest(ServersSampleBase): def test_servers_details(self): uuid = self._post_server() + self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', + fakes.stub_bdm_get_all_by_instance) response = self._do_get('servers/detail') subs = self._get_regexes() subs['hostid'] = '[a-f0-9]+' -- cgit