FibreChannel: ignore unsupported HBA adapters
In some cases, when attempting to fetch FC HBA port information, we
may stumble upon unsupported HBA adapters, which should be ignored.
A previous patch attempted to fix this issue, assuming that only the
call fetching FC ports for a specific adapter may fail. It seems like
in some cases, fetching the adapter name may fail as well.
This change ensures we're going to catch such exceptions as well.
Change-Id: I27f9d2062aa0bedb4cb0e6589d8731b77cf30829
Closes-Bug: #1539702
(cherry picked from commit b09e79c9a3
)
This commit is contained in:
parent
00bb2296a0
commit
d13d6d7310
|
@ -209,9 +209,11 @@ class FCUtilsTestCase(base.BaseTestCase):
|
|||
def test_get_fc_hba_ports(self, mock_get_fc_hba_count,
|
||||
mock_get_adapter_name,
|
||||
mock_get_adapter_ports):
|
||||
fake_adapter_count = 2
|
||||
fake_adapter_count = 3
|
||||
|
||||
mock_get_adapter_name.return_value = mock.sentinel.adapter_name
|
||||
mock_get_adapter_name.side_effect = [Exception,
|
||||
mock.sentinel.adapter_name,
|
||||
mock.sentinel.adapter_name]
|
||||
mock_get_fc_hba_count.return_value = fake_adapter_count
|
||||
mock_get_adapter_ports.side_effect = [Exception,
|
||||
[mock.sentinel.port]]
|
||||
|
@ -224,7 +226,7 @@ class FCUtilsTestCase(base.BaseTestCase):
|
|||
mock_get_adapter_name.assert_has_calls(
|
||||
[mock.call(index) for index in range(fake_adapter_count)])
|
||||
mock_get_adapter_ports.assert_has_calls(
|
||||
[mock.call(mock.sentinel.adapter_name)] * fake_adapter_count)
|
||||
[mock.call(mock.sentinel.adapter_name)] * 2)
|
||||
|
||||
@mock.patch.object(fc_utils.FCUtils, '_open_adapter')
|
||||
@mock.patch.object(fc_utils.FCUtils, '_close_adapter')
|
||||
|
|
|
@ -139,7 +139,16 @@ class FCUtils(object):
|
|||
|
||||
adapter_count = self.get_fc_hba_count()
|
||||
for adapter_index in range(adapter_count):
|
||||
adapter_name = self._get_adapter_name(adapter_index)
|
||||
# We'll ignore unsupported FC HBA ports.
|
||||
try:
|
||||
adapter_name = self._get_adapter_name(adapter_index)
|
||||
except Exception as exc:
|
||||
msg = _LW("Could not retrieve FC HBA adapter name for "
|
||||
"adapter number: %(adapter_index)s. "
|
||||
"Exception: %(exc)s")
|
||||
LOG.warning(msg, dict(adapter_index=adapter_index, exc=exc))
|
||||
continue
|
||||
|
||||
try:
|
||||
hba_ports += self._get_fc_hba_adapter_ports(adapter_name)
|
||||
except Exception as exc:
|
||||
|
|
Loading…
Reference in New Issue