Browse Source

Merge "Incorporate the connection_properties input for PPC64" into stable/queens

changes/24/564724/1 2.3.1
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
773fad170f
  1. 13
      os_brick/initiator/connectors/fibre_channel_ppc64.py
  2. 51
      os_brick/initiator/linuxfc.py
  3. 2
      os_brick/tests/initiator/connectors/test_fibre_channel_ppc64.py

13
os_brick/initiator/connectors/fibre_channel_ppc64.py

@ -16,7 +16,6 @@ from oslo_log import log as logging
from os_brick import initiator
from os_brick.initiator.connectors import fibre_channel
from os_brick.initiator import linuxfc
LOG = logging.getLogger(__name__)
@ -36,7 +35,6 @@ class FibreChannelConnectorPPC64(fibre_channel.FibreChannelConnector):
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
self._linuxfc = linuxfc.LinuxFibreChannelPPC64(root_helper, execute)
self.use_multipath = use_multipath
def set_execute(self, execute):
@ -52,14 +50,3 @@ class FibreChannelConnectorPPC64(fibre_channel.FibreChannelConnector):
self._linuxscsi.process_lun_id(lun))
host_devices.add(host_device)
return list(host_devices)
def _get_possible_volume_paths(self, connection_properties, hbas):
ports = connection_properties['target_wwn']
it_map = connection_properties['initiator_target_map']
for hba in hbas:
if hba['node_name'] in it_map.keys():
hba['target_wwn'] = it_map.get(hba['node_name'])
possible_devs = self._get_possible_devices(hbas, ports)
lun = connection_properties.get('target_lun', 0)
host_paths = self._get_host_devices(possible_devs, lun)
return host_paths

51
os_brick/initiator/linuxfc.py

@ -281,54 +281,3 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
LOG.warning("unit_remove call for s390 failed exit %(code)s, "
"stderr %(stderr)s",
{'code': exc.exit_code, 'stderr': exc.stderr})
class LinuxFibreChannelPPC64(LinuxFibreChannel):
def _get_hba_channel_scsi_target(self, hba, wwpn):
"""Try to get the HBA channel and SCSI target for an HBA.
This method works for Fibre Channel targets iterating over all the
target wwpn port and finding the c, t, l. so caller should expect us to
return either None or an empty list.
"""
# Leave only the number from the host_device field (ie: host6)
host_device = hba['host_device']
if host_device and len(host_device) > 4:
host_device = host_device[4:]
path = '/sys/class/fc_transport/target%s:' % host_device
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:]
for line in out.split('\n') if line.startswith(path)]
except Exception as exc:
LOG.error("Could not get HBA channel and SCSI target ID, "
"reason: %s", exc)
return None
def rescan_hosts(self, hbas, target_lun):
for hba in hbas:
# Try to get HBA channel and SCSI target to use as filters
# Ignore HBA which does not have target wwn
if 'target_wwn' not in hba.keys():
continue
for wwpn in hba['target_wwn']:
cts = self._get_hba_channel_scsi_target(hba, wwpn)
# If we couldn't get the channel and target use wildcards
if not cts:
cts = [('-', '-')]
for hba_channel, target_id in cts:
LOG.debug('Scanning host %(host)s (wwpn: %(wwpn)s, c: '
'%(channel)s, t: %(target)s, l: %(lun)s)',
{'host': hba['host_device'],
'wwpn': hba['target_wwn'],
'channel': hba_channel,
'target': target_id,
'lun': target_lun})
self.echo_scsi_command(
"/sys/class/scsi_host/%s/scan" % hba['host_device'],
"%(c)s %(t)s %(l)s" % {'c': hba_channel,
't': target_id,
'l': target_lun})

2
os_brick/tests/initiator/connectors/test_fibre_channel_ppc64.py

@ -27,7 +27,7 @@ class FibreChannelConnectorPPC64TestCase(test_connector.ConnectorTestCase):
self.assertIsNotNone(self.connector)
self.assertIsNotNone(self.connector._linuxfc)
self.assertEqual(self.connector._linuxfc.__class__.__name__,
"LinuxFibreChannelPPC64")
"LinuxFibreChannel")
self.assertIsNotNone(self.connector._linuxscsi)
@mock.patch.object(linuxscsi.LinuxSCSI, 'process_lun_id', return_value='2')

Loading…
Cancel
Save