diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py index 029bd9e8b28..a39e08a455c 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py @@ -124,6 +124,16 @@ class TestBrcdFCSanLookupService(brcd_lookup.BrcdFCSanLookupService, initiator_list, target_list) self.assertDictEqual(_device_map_to_verify, device_map) + @mock.patch.object(brcd_lookup.BrcdFCSanLookupService, + '_get_southbound_client', side_effect=ValueError) + def test_get_device_mapping_from_network_fail(self, + get_southbound_client_mock): + initiator_list = [parsed_switch_port_wwns[1]] + target_list = [parsed_switch_port_wwns[0], '20240002ac000a40'] + self.assertRaises(brcd_lookup.exception.FCSanLookupServiceException, + self.get_device_mapping_from_network, + initiator_list, target_list) + class FakeClient(object): def is_supported_firmware(self): diff --git a/cinder/zonemanager/drivers/brocade/brcd_fc_san_lookup_service.py b/cinder/zonemanager/drivers/brocade/brcd_fc_san_lookup_service.py index 75c671938e4..c478d8282a0 100644 --- a/cinder/zonemanager/drivers/brocade/brcd_fc_san_lookup_service.py +++ b/cinder/zonemanager/drivers/brocade/brcd_fc_san_lookup_service.py @@ -111,6 +111,7 @@ class BrcdFCSanLookupService(fc_service.FCSanLookupService): # Get name server data from fabric and find the targets # logged in nsinfo = '' + conn = None try: LOG.debug("Getting name server data for " "fabric %s", fabric_ip) diff --git a/releasenotes/notes/brocade_looup_fail_get_client-179151d449a34aa4.yaml b/releasenotes/notes/brocade_looup_fail_get_client-179151d449a34aa4.yaml new file mode 100644 index 00000000000..98d027366f6 --- /dev/null +++ b/releasenotes/notes/brocade_looup_fail_get_client-179151d449a34aa4.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix `UnboundLocalError` on the Brocade lookup driver on southbound client + creation failure during the device mapping retrieval (Bug #1888550).