Optimize FC device checking

Checks for fibre channel device paths will only fail if there are
no FC HBAs since the actual paths are just calculated based on the
HBA information, whether they exist or not. This moves the check
earlier in the process to avoid that calculation if we don't have
any HBA information.

Change-Id: Ib8bfea2c9603335e93b1407605f0e59d3c29f622
This commit is contained in:
yenai 2018-09-19 15:01:38 +08:00 committed by Sean McGinnis
parent 9a62860dd4
commit 9370a16512
1 changed files with 7 additions and 9 deletions

View File

@ -192,14 +192,13 @@ class FibreChannelConnector(base.BaseLinuxConnector):
connection_properties)
hbas = self._linuxfc.get_fc_hbas_info()
if not hbas:
LOG.warning("We are unable to locate any Fibre Channel devices.")
raise exception.NoFibreChannelHostsFound()
host_devices = self._get_possible_volume_paths(
connection_properties, hbas)
if len(host_devices) == 0:
# this is empty because we don't have any FC HBAs
LOG.warning("We are unable to locate any Fibre Channel devices")
raise exception.NoFibreChannelHostsFound()
# The /dev/disk/by-path/... node is not always present immediately
# We only need to find the first device. Once we see the first device
# multipath will have any others.
@ -232,10 +231,9 @@ class FibreChannelConnector(base.BaseLinuxConnector):
_wait_for_device_discovery, host_devices)
timer.start(interval=2).wait()
if self.host_device is not None and self.device_name is not None:
LOG.debug("Found Fibre Channel volume %(name)s "
"(after %(tries)s rescans)",
{'name': self.device_name, 'tries': self.tries})
LOG.debug("Found Fibre Channel volume %(name)s "
"(after %(tries)s rescans.)",
{'name': self.device_name, 'tries': self.tries})
# find out the WWN of the device
device_wwn = self._linuxscsi.get_scsi_wwn(self.host_device)