Merge "spawn is not checking if volume is a FC volume"

This commit is contained in:
Jenkins 2017-04-24 09:23:08 +00:00 committed by Gerrit Code Review
commit fc57d88e5e
3 changed files with 39 additions and 0 deletions

View File

@ -95,6 +95,31 @@ class DPMdriverInitHostTestCase(TestCase):
self.assertEqual(target_wwpn, '500507680B214AC1')
self.assertEqual(lun, '0')
def test_validate_volume_type_unsupported(self):
bdms = [
{'connection_info': {'driver_volume_type': 'fake_vol_type'}}]
self.assertRaises(exceptions.UnsupportedVolumeTypeException,
self.dpmdriver._validate_volume_type, bdms)
bdms = [
{'connection_info': {'driver_volume_type': 'fake_vol_type'}},
{'connection_info': {'driver_volume_type': 'fake_vol_type'}}]
self.assertRaises(exceptions.UnsupportedVolumeTypeException,
self.dpmdriver._validate_volume_type, bdms)
bdms = [
{'connection_info': {'driver_volume_type': 'fibre_channel'}},
{'connection_info': {'driver_volume_type': 'fake_vol_type'}}]
self.assertRaises(exceptions.UnsupportedVolumeTypeException,
self.dpmdriver._validate_volume_type, bdms)
def test_validate_volume_type_supported(self):
bdms = [
{'connection_info': {'driver_volume_type': 'fibre_channel'}},
{'connection_info': {'driver_volume_type': 'fibre_channel'}}]
self.dpmdriver._validate_volume_type(bdms)
@mock.patch.object(vm.PartitionInstance, 'get_partition')
@mock.patch.object(vm.PartitionInstance,
'get_partition_wwpns', return_value=[PARTITION_WWPN])

View File

@ -359,6 +359,8 @@ class DPMDriver(driver.ComputeDriver):
block_device_mapping = driver.block_device_info_get_mapping(
block_device_info)
self._validate_volume_type(block_device_mapping)
LOG.debug("Block device mapping %s", str(block_device_mapping))
wwpns = inst.get_partition_wwpns()
@ -409,6 +411,13 @@ class DPMDriver(driver.ComputeDriver):
LOG.debug("Returning valid target WWPN %s", target_wwpn)
return target_wwpn
def _validate_volume_type(self, bdms):
for bdm in bdms:
vol_type = bdm['connection_info']['driver_volume_type']
if vol_type != 'fibre_channel':
raise exceptions.UnsupportedVolumeTypeException(
vol_type=vol_type)
def destroy(self, context, instance, network_info, block_device_info=None,
destroy_disks=True, migrate_data=None):
inst = vm.PartitionInstance(instance, self._cpc)

View File

@ -30,3 +30,8 @@ class BootOsSpecificParametersPropertyExceededError(NovaException):
"""The boot-os-specific-parameters property would exceed the allowed max"""
msg_fmt = _("Exceeded the maximum len for the partitions "
"'boot-os-specific-parameters' property.")
class UnsupportedVolumeTypeException(NovaException):
msg_fmt = _("Driver volume type"
" %(vol_type)s is not supported by nova-dpm.")