FC PPC64 device discovery issue

Change ppc64 device discovery to remove duplicate devices
in _get_host_devices().

Change _get_hba_channel_scsi_target() to find devices
regardless of the case of WWPNs.

Change-Id: I18e74d13cd94aba625c51ee05fde75642fbfd2f6
Closes-Bug: #1715647
This commit is contained in:
Chhavi Agarwal 2017-09-06 09:11:49 -04:00
parent 1d617b2adb
commit acfcca557a
3 changed files with 15 additions and 8 deletions

View File

@ -45,13 +45,13 @@ class FibreChannelConnectorPPC64(fibre_channel.FibreChannelConnector):
self._linuxfc.set_execute(execute)
def _get_host_devices(self, possible_devs, lun):
host_devices = []
host_devices = set()
for pci_num, target_wwn in possible_devs:
host_device = "/dev/disk/by-path/fc-%s-lun-%s" % (
target_wwn,
self._linuxscsi.process_lun_id(lun))
host_devices.append(host_device)
return host_devices
host_devices.add(host_device)
return list(host_devices)
def _get_possible_volume_paths(self, connection_properties, hbas):
ports = connection_properties['target_wwn']

View File

@ -280,8 +280,8 @@ class LinuxFibreChannelPPC64(LinuxFibreChannel):
if host_device and len(host_device) > 4:
host_device = host_device[4:]
path = '/sys/class/fc_transport/target%s:' % host_device
cmd = 'grep -l %(wwpn)s %(path)s*/port_name' % {'wwpn': wwpn,
'path': path}
cmd = 'grep -il %(wwpn)s %(path)s*/port_name' % {'wwpn': wwpn,
'path': path}
try:
out, _err = self._execute(cmd, shell=True)
return [line.split('/')[4].split(':')[1:]

View File

@ -37,7 +37,14 @@ class FibreChannelConnectorPPC64TestCase(test_connector.ConnectorTestCase):
(3, "0x5005076802332ade"), ]
devices = self.connector._get_host_devices(possible_devs, lun)
self.assertEqual(2, len(devices))
device_path = "/dev/disk/by-path/fc-0x5005076802232ade-lun-2"
self.assertEqual(devices[0], device_path)
device_path = "/dev/disk/by-path/fc-0x5005076802332ade-lun-2"
self.assertEqual(devices[1], device_path)
self.assertIn(device_path, devices)
device_path = "/dev/disk/by-path/fc-0x5005076802232ade-lun-2"
self.assertIn(device_path, devices)
# test duplicates
possible_devs = [(3, "0x5005076802232ade"),
(3, "0x5005076802232ade"), ]
devices = self.connector._get_host_devices(possible_devs, lun)
self.assertEqual(1, len(devices))
device_path = "/dev/disk/by-path/fc-0x5005076802232ade-lun-2"
self.assertIn(device_path, devices)