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
This commit is contained in:
Patrick East 2016-08-12 17:41:25 -07:00
parent ba7d9c63a9
commit b521483830
3 changed files with 18 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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.