From 2f3d05b5ba522605d5b6d17cd90786d929be6124 Mon Sep 17 00:00:00 2001 From: Shay Halsband Date: Thu, 10 Dec 2015 14:13:51 +0200 Subject: [PATCH] XtremIO: FC initialize connection failed * Initialize connection fail when all initiators are connected to a non default named initiator group(IG). The failure happens since the default name was always added to the IG list even if one doesn't exists. Added a check before adding the default IG to the list to make sure it was created, thus preventing the failure. * Added unitest for existing IG. Change-Id: Ie761580fc5ff73683c32d2b79d94c6ba4db0b792 closes-bug: #1524766 --- cinder/tests/unit/test_emc_xtremio.py | 27 +++++++++++++++++++++++++++ cinder/volume/drivers/emc/xtremio.py | 5 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/test_emc_xtremio.py b/cinder/tests/unit/test_emc_xtremio.py index fb2a032c4..20709b9fa 100644 --- a/cinder/tests/unit/test_emc_xtremio.py +++ b/cinder/tests/unit/test_emc_xtremio.py @@ -630,6 +630,33 @@ class EMCXIODriverFibreChannelTestCase(test.TestCase): self.data.connector) self.driver.delete_volume(self.data.test_volume) + def test_initialize_existing_ig_terminate_connection(self, req): + req.side_effect = xms_request + self.driver.client = xtremio.XtremIOClient4( + self.config, self.config.xtremio_cluster_name) + + self.driver.create_volume(self.data.test_volume) + + pre_existing = 'pre_existing_host' + self.driver._create_ig(pre_existing) + wwpns = self.driver._get_initiator_name(self.data.connector) + for wwpn in wwpns: + data = {'initiator-name': wwpn, 'ig-id': pre_existing, + 'port-address': wwpn} + self.driver.client.req('initiators', 'POST', data) + + def get_fake_initiator(wwpn): + return {'port-address': wwpn, 'ig-id': ['', pre_existing, 1]} + with mock.patch.object(self.driver.client, 'get_initiator', + side_effect=get_fake_initiator): + map_data = self.driver.initialize_connection(self.data.test_volume, + self.data.connector) + self.assertEqual(1, map_data['data']['target_lun']) + self.assertEqual(1, len(xms_data['initiator-groups'])) + self.driver.terminate_connection(self.data.test_volume, + self.data.connector) + self.driver.delete_volume(self.data.test_volume) + def test_race_on_terminate_connection(self, req): """Test for race conditions on num_of_mapped_volumes. diff --git a/cinder/volume/drivers/emc/xtremio.py b/cinder/volume/drivers/emc/xtremio.py index 55e7a1125..019560e6c 100644 --- a/cinder/volume/drivers/emc/xtremio.py +++ b/cinder/volume/drivers/emc/xtremio.py @@ -938,8 +938,9 @@ class XtremIOFibreChannelDriver(XtremIOVolumeDriver, data = {'initiator-name': wwpn, 'ig-id': ig_name, 'port-address': wwpn} self.client.req('initiators', 'POST', data) - igs = list(set([i['ig-id'][XTREMIO_OID_NAME] - for i in found] + [ig_name])) + igs = list(set([i['ig-id'][XTREMIO_OID_NAME] for i in found])) + if new and ig['ig-id'][XTREMIO_OID_NAME] not in igs: + igs.append(ig['ig-id'][XTREMIO_OID_NAME]) if len(igs) > 1: lun_num = self._get_free_lun(igs) -- 2.45.2