diff options
| author | Oleg Bondarev <obondarev@mirantis.com> | 2013-04-17 18:18:03 +0400 |
|---|---|---|
| committer | Oleg Bondarev <obondarev@mirantis.com> | 2013-05-08 10:18:10 +0400 |
| commit | dd66f235ecf2ff67819917ee07bcb0ea13a1b17b (patch) | |
| tree | 328ca93faaf3cf195c6563a0f749f3493278f0e5 /nova/api | |
| parent | d9be77ddd487c71729387a2b31f470be56738bd8 (diff) | |
| download | nova-dd66f235ecf2ff67819917ee07bcb0ea13a1b17b.tar.gz nova-dd66f235ecf2ff67819917ee07bcb0ea13a1b17b.tar.xz nova-dd66f235ecf2ff67819917ee07bcb0ea13a1b17b.zip | |
Include list of attached volumes with instance info
Fixes bug 1112998
Change-Id: I1c3eb578339aabbcfed107043f39e30daf633c4a
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 14 | ||||
| -rw-r--r-- | nova/api/openstack/compute/views/servers.py | 2 |
2 files changed, 16 insertions, 0 deletions
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) |
