]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
XtremIO: FC initialize connection failed
authorShay Halsband <shay.halsband@emc.com>
Thu, 10 Dec 2015 12:13:51 +0000 (14:13 +0200)
committerShay Halsband <shay.halsband@emc.com>
Sun, 17 Jan 2016 09:50:39 +0000 (11:50 +0200)
* 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
cinder/volume/drivers/emc/xtremio.py

index fb2a032c4bc4ed144e76d24723b7d79f0f105d9f..20709b9fa464e3bfaaca3fa4b121d7262abe420f 100644 (file)
@@ -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.
 
index 55e7a1125e209940faa9ca33aa75b7621302c656..019560e6c8d70cd000dbbca722ab676a8a8e187f 100644 (file)
@@ -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)