summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2011-09-14 16:19:00 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2011-09-14 16:19:00 +0000
commit9614c5690118f239652e7ebccdd4ce6ecffbe4ee (patch)
treeff71837cc793c42fd3f98aba8639976cca64f2a1 /nova/api
parent147290d01389d72d3754bbaa088660f38a6871d8 (diff)
parent89736bf13562811cebb42cd6e3377d7f9e0a0b9c (diff)
downloadnova-9614c5690118f239652e7ebccdd4ce6ecffbe4ee.tar.gz
nova-9614c5690118f239652e7ebccdd4ce6ecffbe4ee.tar.xz
nova-9614c5690118f239652e7ebccdd4ce6ecffbe4ee.zip
Merge with trunk
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index eacfdc0df..0efb90d6e 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -272,11 +272,23 @@ class CloudController(object):
mappings = {}
mappings['ami'] = block_device.strip_dev(root_device_name)
mappings['root'] = root_device_name
-
- # 'ephemeralN' and 'swap'
+ default_local_device = instance_ref.get('default_local_device')
+ if default_local_device:
+ mappings['ephemeral0'] = default_local_device
+ default_swap_device = instance_ref.get('default_swap_device')
+ if default_swap_device:
+ mappings['swap'] = default_swap_device
+ ebs_devices = []
+
+ # 'ephemeralN', 'swap' and ebs
for bdm in db.block_device_mapping_get_all_by_instance(
ctxt, instance_ref['id']):
- if (bdm['volume_id'] or bdm['snapshot_id'] or bdm['no_device']):
+ if bdm['no_device']:
+ continue
+
+ # ebs volume case
+ if (bdm['volume_id'] or bdm['snapshot_id']):
+ ebs_devices.append(bdm['device_name'])
continue
virtual_name = bdm['virtual_name']
@@ -286,6 +298,16 @@ class CloudController(object):
if block_device.is_swap_or_ephemeral(virtual_name):
mappings[virtual_name] = bdm['device_name']
+ # NOTE(yamahata): I'm not sure how ebs device should be numbered.
+ # Right now sort by device name for deterministic
+ # result.
+ if ebs_devices:
+ nebs = 0
+ ebs_devices.sort()
+ for ebs in ebs_devices:
+ mappings['ebs%d' % nebs] = ebs
+ nebs += 1
+
return mappings
def get_metadata(self, address):