spawn is not checking if volume is a FC volume
On instance spawn we only indirectly check if the requested volume is a FC volume via [1]. This will either fail with an "KeyError" or a "NoneType Error" depending on how the block_device_info object looks like for non FC volumes. [1] https://github.com/openstack/nova-dpm/blob/1.0.0/nova_dpm/virt/dpm/driver.py#L374 Closes-Bug: #1668343 Change-Id: I6eefda4127402d43ad9407190626220722ddee58 Signed-off-by: Prabhat Ranjan <pranjank@in.ibm.com>
This commit is contained in:
parent
cb0074b90e
commit
cc01b3bafb
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue