From b5214838303e56d0556a843ee40da591cd747b87 Mon Sep 17 00:00:00 2001 From: Patrick East Date: Fri, 12 Aug 2016 17:41:25 -0700 Subject: [PATCH] Ignore case when comparing wwns in Pure FC driver We would previously just assume the wwpns in our connector were lower-case and this was not valid for all systems. We will now compare with all lower case strings. Change-Id: Icdb818c97fc7810b5276b83debf8e75fe48fd15d Closes-Bug: #1612866 --- cinder/tests/unit/volume/drivers/test_pure.py | 14 ++++++++++++-- cinder/volume/drivers/pure.py | 2 +- .../notes/pure-fc-wwpn-case-c1d97f3fa7663acf.yaml | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/pure-fc-wwpn-case-c1d97f3fa7663acf.yaml diff --git a/cinder/tests/unit/volume/drivers/test_pure.py b/cinder/tests/unit/volume/drivers/test_pure.py index 6625948e420..cdb8ce400ac 100644 --- a/cinder/tests/unit/volume/drivers/test_pure.py +++ b/cinder/tests/unit/volume/drivers/test_pure.py @@ -122,7 +122,7 @@ SNAPSHOT_WITH_CGROUP = SNAPSHOT.copy() SNAPSHOT_WITH_CGROUP['cgsnapshot_id'] = \ "4a2f7e3a-312a-40c5-96a8-536b8a0fe075" INITIATOR_IQN = "iqn.1993-08.org.debian:01:222" -INITIATOR_WWN = "5001500150015081" +INITIATOR_WWN = "5001500150015081abc" ISCSI_CONNECTOR = {"initiator": INITIATOR_IQN, "host": HOSTNAME} FC_CONNECTOR = {"wwpns": {INITIATOR_WWN}, "host": HOSTNAME} TARGET_IQN = "iqn.2010-06.com.purestorage:flasharray.12345abc" @@ -132,7 +132,7 @@ INITIATOR_TARGET_MAP =\ { # _build_initiator_target_map() calls list(set()) on the list, # we must also call list(set()) to get the exact same order - '5001500150015081': list(set(FC_WWNS)), + '5001500150015081abc': list(set(FC_WWNS)), } DEVICE_MAPPING =\ { @@ -2280,6 +2280,16 @@ class PureFCDriverTestCase(PureDriverTestCase): self.array, FC_CONNECTOR) + def test_get_host_uppercase_wwpn(self): + expected_host = PURE_HOST.copy() + expected_host['wwn'] = [INITIATOR_WWN] + self.array.list_hosts.return_value = [expected_host] + connector = FC_CONNECTOR.copy() + connector['wwpns'] = [wwpn.upper() for wwpn in FC_CONNECTOR['wwpns']] + + actual_result = self.driver._get_host(self.array, connector) + self.assertEqual(expected_host, actual_result) + @mock.patch(FC_DRIVER_OBJ + "._connect") def test_initialize_connection(self, mock_connection): lookup_service = self.driver._lookup_service diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 66bee72d498..ff44a987d74 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -1700,7 +1700,7 @@ class PureFCDriver(PureBaseVolumeDriver, driver.FibreChannelDriver): hosts = array.list_hosts() for host in hosts: for wwn in connector["wwpns"]: - if wwn in str(host["wwn"]).lower(): + if wwn.lower() in str(host["wwn"]).lower(): return host @staticmethod diff --git a/releasenotes/notes/pure-fc-wwpn-case-c1d97f3fa7663acf.yaml b/releasenotes/notes/pure-fc-wwpn-case-c1d97f3fa7663acf.yaml new file mode 100644 index 00000000000..fdb20859507 --- /dev/null +++ b/releasenotes/notes/pure-fc-wwpn-case-c1d97f3fa7663acf.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Fix issue with PureFCDriver where partially case sensitive comparison of + connector wwpn could cause initialize_connection to fail when attempting + to create duplicate Purity host.