diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-15 18:41:27 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-15 18:41:27 +0000 |
| commit | 3492d83140c12a23e29f0b103aced9a96f623cf2 (patch) | |
| tree | d215ec9fdd486eae8f14e07978ae116cab20bc72 /nova/api | |
| parent | 8dc14fad859e85752cb51fdf3f1790c58da7b51e (diff) | |
| parent | dd66f235ecf2ff67819917ee07bcb0ea13a1b17b (diff) | |
Merge "Include list of attached volumes with instance info"
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 cb3f7ad49..71b4e86bf 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -98,6 +98,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') @@ -495,6 +500,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.""" @@ -562,6 +574,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) @@ -738,6 +751,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 0cd6afaa1..ff64e5f8e 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) |
