summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2011-06-23 19:51:00 +0900
committerIsaku Yamahata <yamahata@valinux.co.jp>2011-06-23 19:51:00 +0900
commit4b5fdb2ee109960be6b3ff1fa8068ab3ec428283 (patch)
treedc4b7a29a2d003970e872b3d470c58f2443e8b47 /nova/api
parent1c4a3e14a0cef6938c477908d5c3bfe5ddf0e07b (diff)
downloadnova-4b5fdb2ee109960be6b3ff1fa8068ab3ec428283.tar.gz
nova-4b5fdb2ee109960be6b3ff1fa8068ab3ec428283.tar.xz
nova-4b5fdb2ee109960be6b3ff1fa8068ab3ec428283.zip
ec2: bundle block device mapping
device name in block device mapping of bundle doesn't necessary carry "/dev/". So prepend it before processing.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index c25db9014..8bf0950b2 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -92,20 +92,25 @@ def _parse_block_device_mapping(bdm):
"""
ebs = bdm.pop('ebs', None)
if ebs:
- ec2_id = ebs.pop('snapshot_id')
- id = ec2utils.ec2_id_to_id(ec2_id)
- if ec2_id.startswith('snap-'):
- bdm['snapshot_id'] = id
- elif ec2_id.startswith('vol-'):
- bdm['volume_id'] = id
- ebs.setdefault('delete_on_termination', True)
+ ec2_id = ebs.pop('snapshot_id', None)
+ if ec2_id:
+ id = ec2utils.ec2_id_to_id(ec2_id)
+ if ec2_id.startswith('snap-'):
+ bdm['snapshot_id'] = id
+ elif ec2_id.startswith('vol-'):
+ bdm['volume_id'] = id
+ ebs.setdefault('delete_on_termination', True)
bdm.update(ebs)
return bdm
+def _properties_get_mappings(properties):
+ return ec2utils.mappings_prepend_dev(properties.get('mappings', []))
+
+
def _format_block_device_mapping(bdm):
"""Contruct BlockDeviceMappingItemType
- {'device_name': '...', 'Snapshot_Id': , ...}
+ {'device_name': '...', 'snapshot_id': , ...}
=> BlockDeviceMappingItemType
"""
keys = (('deviceName', 'device_name'),
@@ -138,7 +143,7 @@ def _format_block_device_mapping(bdm):
def _format_mappings(properties, result):
"""Format multiple BlockDeviceMappingItemType"""
mappings = [{'virtualName': m['virtual'], 'deviceName': m['device']}
- for m in properties.get('mappings', [])
+ for m in _properties_get_mappings(properties)
if (m['virtual'] == 'swap' or
m['virtual'].startswith('ephemeral'))]
@@ -1381,7 +1386,7 @@ class CloudController(object):
if m:
mapping.append(m)
- for m in properties.get('mappings', []):
+ for m in _properties_get_mappings(properties):
virtual_name = m['virtual']
if virtual_name in ('ami', 'root'):
continue