Merge "VMAX driver - None connector object in a terminate_connection" into stable/ocata

This commit is contained in:
Jenkins 2017-07-18 22:34:48 +00:00 committed by Gerrit Code Review
commit 4c5a29a863
3 changed files with 77 additions and 24 deletions

View File

@ -2381,6 +2381,13 @@ class VMAXISCSIDriverNoFastTestCase(test.TestCase):
host))
self.assertEqual('OS-fakehost-MV', data['maskingview'])
def test_find_device_number_host_none(self):
host = None
data, __, __ = (
self.driver.common.find_device_number(self.data.test_volume,
host))
self.assertEqual('OS-myhost-MV', data['maskingview'])
@mock.patch.object(
FakeEcomConnection,
'ReferenceNames',
@ -8562,6 +8569,22 @@ class VMAXFCTest(test.TestCase):
conn, controllerConfigService, storageGroupInstanceName,
volumeInstanceName, volumeName, extraSpecs)
@mock.patch.object(
fc.VMAXFCDriver,
'_get_zoning_mappings',
return_value=None)
@mock.patch.object(
common.VMAXCommon,
'terminate_connection')
@mock.patch.object(
fc.VMAXFCDriver,
'_cleanup_zones')
def test_terminate_connection_connector_none(
self, mock_cleanup_zones, mock_term_conn, mock_zone_map):
self.driver.terminate_connection(self.data.test_volume, None)
self.driver._get_zoning_mappings.assert_not_called()
self.driver._cleanup_zones.assert_not_called()
@ddt.ddt
class VMAXUtilsTest(test.TestCase):
@ -10112,6 +10135,36 @@ class VMAXISCSITest(test.TestCase):
common._unmap_lun.assert_called_once_with(
self.data.test_snapshot_v3, self.data.connector)
@mock.patch.object(
masking.VMAXMasking,
'return_volume_to_default_storage_group_v3')
@mock.patch.object(
volume_types,
'get_volume_type_extra_specs',
return_value={'volume_backend_name': 'FCFAST',
'FASTPOLICY': 'FC_GOLD1'})
def test_terminate_connection_connector_none(
self, mock_volume_type, mock_ret):
common = self.driver.common
conn = FakeEcomConnection()
common.conn = conn
sourceInstance = (
conn.EnumerateInstanceNames("EMC_StorageVolume")[0])
return_vol = common.masking.return_volume_to_default_storage_group_v3
with mock.patch.object(common, '_initial_setup',
return_value=self.data.extra_specs),\
mock.patch.object(common, '_find_lun',
return_value=sourceInstance):
self.driver.terminate_connection(self.data.test_volume,
None)
common._find_lun.assert_called_with(self.data.test_volume)
controllerConfigService = (
common.utils.find_controller_configuration_service(
conn, self.data.storage_system))
return_vol.assert_called_once_with(
conn, controllerConfigService, sourceInstance, '1',
self.data.extra_specs)
class EMCV3ReplicationTest(test.TestCase):

View File

@ -517,9 +517,10 @@ class VMAXCommon(object):
volumename = volume['name']
LOG.info(_LI("Unmap volume: %(volume)s."),
{'volume': volumename})
host = connector and connector.get('host')
device_info, __, __ = self.find_device_number(
volume, connector['host'])
volume, host)
if 'hostlunid' not in device_info:
LOG.info(_LI("Volume %s is not mapped. No volume to unmap."),
volumename)
@ -820,11 +821,6 @@ class VMAXCommon(object):
volumename = volume['name']
LOG.info(_LI("Terminate connection: %(volume)s."),
{'volume': volumename})
if not connector:
exception_message = (_("The connector object from nova "
"cannot be None."))
raise exception.VolumeBackendAPIException(
data=exception_message)
self._unmap_lun(volume, connector)
def extend_volume(self, volume, newSize):
@ -2015,20 +2011,23 @@ class VMAXCommon(object):
{'volumeName': volumeName,
'volumeInstance': volumeInstance.path})
else:
host = self.utils.get_host_short_name(host)
hoststr = ("-%(host)s-"
% {'host': host})
for maskedvol in maskedvols:
if hoststr.lower() in maskedvol['maskingview'].lower():
data = maskedvol
if not data:
if len(maskedvols) > 0:
source_data = maskedvols[0]
LOG.warning(_LW(
"Volume is masked but not to host %(host)s as is "
"expected. Assuming live migration."),
{'host': hoststr})
isLiveMigration = True
if host:
host = self.utils.get_host_short_name(host)
hoststr = ("-%(host)s-"
% {'host': host})
for maskedvol in maskedvols:
if hoststr.lower() in maskedvol['maskingview'].lower():
data = maskedvol
if not data:
if len(maskedvols) > 0:
source_data = maskedvols[0]
LOG.warning(_LW(
"Volume is masked but not to host %(host)s as is "
"expected. Assuming live migration."),
{'host': hoststr})
isLiveMigration = True
else:
data = maskedvols[0]
LOG.debug("Device info: %(data)s.", {'data': data})
return data, isLiveMigration, source_data

View File

@ -225,11 +225,12 @@ class VMAXFCDriver(driver.FibreChannelDriver):
"""
data = {'driver_volume_type': 'fibre_channel',
'data': {}}
zoning_mappings = (
self._get_zoning_mappings(volume, connector))
zoning_mappings = {}
if connector:
zoning_mappings = (
self._get_zoning_mappings(volume, connector))
self.common.terminate_connection(volume, connector)
if zoning_mappings:
self.common.terminate_connection(volume, connector)
data = self._cleanup_zones(zoning_mappings)
return data