summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-01-17 00:51:37 +0000
committerGerrit Code Review <review@openstack.org>2012-01-17 00:51:37 +0000
commit3972390d286ba487a53a27fa59a6cc1b0e2573ba (patch)
treed228b357d89b27a353fc324cbbbfe2df700ef96f /nova/api
parentf2fc7dd9b2dbf9259c232f9561804dc6c0cff0bd (diff)
parentc1cf917bceeabdddf6f14bc0e51663e1df382677 (diff)
Merge "Add tests for volume list and detail through new volume api, and fix error that the tests caught"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/volume/volumes.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/nova/api/openstack/volume/volumes.py b/nova/api/openstack/volume/volumes.py
index 6783244d6..b37a56374 100644
--- a/nova/api/openstack/volume/volumes.py
+++ b/nova/api/openstack/volume/volumes.py
@@ -34,6 +34,34 @@ LOG = logging.getLogger("nova.api.openstack.volume.volumes")
FLAGS = flags.FLAGS
+def _translate_attachment_detail_view(_context, vol):
+ """Maps keys for attachment details view."""
+
+ d = _translate_attachment_summary_view(_context, vol)
+
+ # No additional data / lookups at the moment
+
+ return d
+
+
+def _translate_attachment_summary_view(_context, vol):
+ """Maps keys for attachment summary view."""
+ d = {}
+
+ volume_id = vol['id']
+
+ # NOTE(justinsb): We use the volume id as the id of the attachment object
+ d['id'] = volume_id
+
+ d['volumeId'] = volume_id
+ if vol.get('instance'):
+ d['serverId'] = vol['instance']['uuid']
+ if vol.get('mountpoint'):
+ d['device'] = vol['mountpoint']
+
+ return d
+
+
def _translate_volume_detail_view(context, vol):
"""Maps keys for volumes details view."""