summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project
diff options
context:
space:
mode:
authorArvinder Singh <arvinder.singh@aricent.com>2015-03-17 15:33:27 +0530
committerArvinder Singh <arvinder.singh@aricent.com>2015-03-17 15:33:27 +0530
commit45ed4ab8f8f5517a36c1f65a47ebc1e5ac5867eb (patch)
tree6ca599644c87ce737eb8cfac963356893b46d2f2 /openstack_dashboard/dashboards/project
parentf9f936eee77c67ca3ba3db65494e3d9c670d11e0 (diff)
downloadhorizon-45ed4ab8f8f5517a36c1f65a47ebc1e5ac5867eb.tar.gz
Use bdmv2 format when instance is boot from volume
Currently boot from volume uses bdmv1 format. In this blueprint bdmv2 format will be used for block device mapping instead bdmv1 format if V2 extension api is supported else bdmv1 format will be used. Unit tests have been added. implements bp horizon-block-device-mapping-v2 Change-Id: I3a6b89d690966080c85b629e0b2b7f2a790a0aaf
Diffstat (limited to 'openstack_dashboard/dashboards/project')
-rw-r--r--openstack_dashboard/dashboards/project/instances/tests.py39
-rw-r--r--openstack_dashboard/dashboards/project/instances/workflows/create_instance.py31
2 files changed, 61 insertions, 9 deletions
diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py
index a5fe31955..3e4793978 100644
--- a/openstack_dashboard/dashboards/project/instances/tests.py
+++ b/openstack_dashboard/dashboards/project/instances/tests.py
@@ -1988,8 +1988,11 @@ class InstanceTests(helpers.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
- def test_launch_instance_post_boot_from_volume(self,
- test_with_profile=False):
+ def test_launch_instance_post_boot_from_volume(
+ self,
+ test_with_profile=False,
+ test_with_bdmv2=False
+ ):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@@ -1999,13 +2002,29 @@ class InstanceTests(helpers.TestCase):
customization_script = 'user data'
device_name = u'vda'
volume_choice = "%s:vol" % volume.id
- block_device_mapping = {device_name: u"%s::0" % volume_choice}
+ if test_with_bdmv2:
+ volume_source_id = volume.id.split(':')[0]
+ block_device_mapping = None
+ block_device_mapping_2 = [
+ {'device_name': u'vda',
+ 'source_type': 'volume',
+ 'destination_type': 'volume',
+ 'delete_on_termination': 0,
+ 'uuid': volume_source_id,
+ 'boot_index': '0',
+ 'volume_size': 1
+ }
+ ]
+ else:
+ block_device_mapping = {device_name: u"%s::0" % volume_choice}
+ block_device_mapping_2 = None
+
nics = [{"net-id": self.networks.first().id, "v4-fixed-ip": ''}]
quota_usages = self.quota_usages.first()
api.nova.extension_supported('BlockDeviceMappingV2Boot',
IsA(http.HttpRequest)) \
- .AndReturn(True)
+ .AndReturn(test_with_bdmv2)
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
api.nova.keypair_list(IsA(http.HttpRequest)) \
@@ -2057,6 +2076,10 @@ class InstanceTests(helpers.TestCase):
cinder.volume_snapshot_list(IsA(http.HttpRequest),
search_opts=SNAPSHOT_SEARCH_OPTS) \
.AndReturn([])
+ api.nova.extension_supported('BlockDeviceMappingV2Boot',
+ IsA(http.HttpRequest)) \
+ .AndReturn(test_with_bdmv2)
+
api.nova.server_create(IsA(http.HttpRequest),
server.name,
'',
@@ -2065,7 +2088,7 @@ class InstanceTests(helpers.TestCase):
customization_script,
[sec_group.name],
block_device_mapping=block_device_mapping,
- block_device_mapping_v2=None,
+ block_device_mapping_v2=block_device_mapping_2,
nics=nics,
availability_zone=avail_zone.zoneName,
instance_count=IsA(int),
@@ -2103,6 +2126,9 @@ class InstanceTests(helpers.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
+ def test_launch_instance_post_boot_from_volume_with_bdmv2(self):
+ self.test_launch_instance_post_boot_from_volume(test_with_bdmv2=True)
+
@helpers.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_post_boot_from_volume_with_profile(self):
@@ -2196,6 +2222,9 @@ class InstanceTests(helpers.TestCase):
quotas.tenant_quota_usages(IsA(http.HttpRequest)) \
.AndReturn(quota_usages)
+ api.nova.extension_supported('BlockDeviceMappingV2Boot',
+ IsA(http.HttpRequest)) \
+ .AndReturn(False)
api.nova.server_create(IsA(http.HttpRequest),
server.name,
'',
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
index ddea8a57e..e531f58f6 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
@@ -852,10 +852,33 @@ class LaunchInstance(workflows.Workflow):
if source_type in ['image_id', 'instance_snapshot_id']:
image_id = context['source_id']
elif source_type in ['volume_id', 'volume_snapshot_id']:
- dev_mapping_1 = {context['device_name']:
- '%s::%s' %
- (context['source_id'],
- int(bool(context['delete_on_terminate'])))}
+ try:
+ if api.nova.extension_supported("BlockDeviceMappingV2Boot",
+ request):
+ # Volume source id is extracted from the source
+ volume_source_id = context['source_id'].split(':')[0]
+ device_name = context.get('device_name', '') \
+ .strip() or None
+ dev_mapping_2 = [
+ {'device_name': device_name,
+ 'source_type': 'volume',
+ 'destination_type': 'volume',
+ 'delete_on_termination':
+ int(bool(context['delete_on_terminate'])),
+ 'uuid': volume_source_id,
+ 'boot_index': '0',
+ 'volume_size': context['volume_size']
+ }
+ ]
+ else:
+ dev_mapping_1 = {context['device_name']: '%s::%s' %
+ (context['source_id'],
+ int(bool(context['delete_on_terminate'])))
+ }
+ except Exception:
+ msg = _('Unable to retrieve extensions information')
+ exceptions.handle(request, msg)
+
elif source_type == 'volume_image_id':
device_name = context.get('device_name', '').strip() or None
dev_mapping_2 = [