From c1cf917bceeabdddf6f14bc0e51663e1df382677 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 16 Jan 2012 13:41:48 -0800 Subject: Add tests for volume list and detail through new volume api, and fix error that the tests caught Change-Id: I6c706e4681cf079caab614b0870315b275339028 --- nova/api/openstack/volume/volumes.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'nova/api') 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.""" -- cgit