From 18578ded46a307a70b030c0dc3f4955273a584a1 Mon Sep 17 00:00:00 2001 From: Edwin Wang Date: Mon, 20 Jul 2015 20:25:25 +0800 Subject: [PATCH] Add I/T mapping check for IBM FlashSystem No initiator_target_map within properties is needed if no more I/T connection. Otherwise the FCZone manager will remove the zoning between I/T. This patch is to add host check in terminate_connection. If no I/T exists, host will be removed in _unmap_vdisk_from_host. Closes-Bug: #1469581 Change-Id: Ide5d2f5cb3557bd167f065fc168722c143f8f267 --- cinder/tests/unit/test_ibm_flashsystem.py | 26 ++++++++++++++++ .../volume/drivers/ibm/flashsystem_common.py | 4 ++- cinder/volume/drivers/ibm/flashsystem_fc.py | 31 +++++++++++-------- .../volume/drivers/ibm/flashsystem_iscsi.py | 4 ++- 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/cinder/tests/unit/test_ibm_flashsystem.py b/cinder/tests/unit/test_ibm_flashsystem.py index 48b79b60f..231be396a 100644 --- a/cinder/tests/unit/test_ibm_flashsystem.py +++ b/cinder/tests/unit/test_ibm_flashsystem.py @@ -885,8 +885,34 @@ class FlashSystemDriverTestCase(test.TestCase): self.driver.initialize_connection, vol1, self.connector) + # case 4: terminate_connection with no host + with mock.patch.object(flashsystem_fc.FlashSystemFCDriver, + '_get_hostvdisk_mappings') as mock_host: + mock_host.return_value = {} + vol3 = self._generate_vol_info(None) + self.driver.create_volume(vol3) + self.driver.initialize_connection(vol3, self.connector) + return_value = self.driver.terminate_connection(vol3, + self.connector) + self.assertNotEqual({}, return_value['data']) + + # case 5: terminate_connection with host + vol4 = self._generate_vol_info(None) + self.driver.create_volume(vol4) + self.driver.initialize_connection(vol4, self.connector) + vol5 = self._generate_vol_info(None) + self.driver.create_volume(vol5) + self.driver.initialize_connection(vol5, self.connector) + return_value = self.driver.terminate_connection(vol4, + self.connector) + self.assertEqual({}, return_value['data']) + # clear environment self.driver.delete_volume(vol1) + self.driver.delete_volume(vol2) + self.driver.delete_volume(vol3) + self.driver.delete_volume(vol4) + self.driver.delete_volume(vol5) @mock.patch.object(flashsystem_fc.FlashSystemFCDriver, '_create_and_copy_vdisk_data') diff --git a/cinder/volume/drivers/ibm/flashsystem_common.py b/cinder/volume/drivers/ibm/flashsystem_common.py index 678eecb8a..87562f82d 100644 --- a/cinder/volume/drivers/ibm/flashsystem_common.py +++ b/cinder/volume/drivers/ibm/flashsystem_common.py @@ -73,10 +73,12 @@ class FlashSystemDriver(san.SanDriver): 1.0.3 - Initial driver for iSCSI 1.0.4 - Split Flashsystem driver into common and FC 1.0.5 - Report capability of volume multiattach + 1.0.6 - Fix bug #1469581, add I/T mapping check in + terminate_connection """ - VERSION = "1.0.5" + VERSION = "1.0.6" def __init__(self, *args, **kwargs): super(FlashSystemDriver, self).__init__(*args, **kwargs) diff --git a/cinder/volume/drivers/ibm/flashsystem_fc.py b/cinder/volume/drivers/ibm/flashsystem_fc.py index 329b0207f..3f0a63cfe 100644 --- a/cinder/volume/drivers/ibm/flashsystem_fc.py +++ b/cinder/volume/drivers/ibm/flashsystem_fc.py @@ -64,10 +64,12 @@ class FlashSystemFCDriver(fscommon.FlashSystemDriver, 1.0.3 - Initial driver for iSCSI 1.0.4 - Split Flashsystem driver into common and FC 1.0.5 - Report capability of volume multiattach + 1.0.6 - Fix bug #1469581, add I/T mapping check in + terminate_connection """ - VERSION = "1.0.5" + VERSION = "1.0.6" def __init__(self, *args, **kwargs): super(FlashSystemFCDriver, self).__init__(*args, **kwargs) @@ -317,27 +319,30 @@ class FlashSystemFCDriver(fscommon.FlashSystemDriver, 'connector %(conn)s.', {'vol': volume, 'conn': connector}) + return_data = { + 'driver_volume_type': 'fibre_channel', + 'data': {}, + } + vdisk_name = volume['name'] self._wait_vdisk_copy_completed(vdisk_name) self._unmap_vdisk_from_host(vdisk_name, connector) - properties = {} - conn_wwpns = self._get_conn_fc_wwpns() - properties['target_wwn'] = conn_wwpns - # TODO(edwin): add judgement here. No initiator_target_map within - # properties need if no more I/T connection. Otherwise the FCZone - # manager will remove the zoning between I/T. - properties['initiator_target_map'] = self._build_initiator_target_map( - connector['wwpns'], conn_wwpns) + host_name = self._get_host_from_connector(connector) + if not host_name: + properties = {} + conn_wwpns = self._get_conn_fc_wwpns() + properties['target_wwn'] = conn_wwpns + properties['initiator_target_map'] = ( + self._build_initiator_target_map( + connector['wwpns'], conn_wwpns)) + return_data['data'] = properties LOG.debug( 'leave: terminate_connection: volume %(vol)s with ' 'connector %(conn)s.', {'vol': volume, 'conn': connector}) - return { - 'driver_volume_type': 'fibre_channel', - 'data': properties - } + return return_data def do_setup(self, ctxt): """Check that we have all configuration details from the storage.""" diff --git a/cinder/volume/drivers/ibm/flashsystem_iscsi.py b/cinder/volume/drivers/ibm/flashsystem_iscsi.py index 5634a0b20..edec1082e 100644 --- a/cinder/volume/drivers/ibm/flashsystem_iscsi.py +++ b/cinder/volume/drivers/ibm/flashsystem_iscsi.py @@ -63,10 +63,12 @@ class FlashSystemISCSIDriver(fscommon.FlashSystemDriver, 1.0.3 - Initial driver for iSCSI 1.0.4 - Split Flashsystem driver into common and FC 1.0.5 - Report capability of volume multiattach + 1.0.6 - Fix bug #1469581, add I/T mapping check in + terminate_connection """ - VERSION = "1.0.5" + VERSION = "1.0.6" def __init__(self, *args, **kwargs): super(FlashSystemISCSIDriver, self).__init__(*args, **kwargs) -- 2.45.2