Brocade: Fix lookup UnboundLocalError
If we get an exception when getting the southbound client in method get_device_mapping_from_network we will end up seeing the following error: UnboundLocalError: local variable 'conn' referenced before assignment This patch fixes this issue by making sure that the conn variable exists even if that call fails. TrivialFix Closes-Bug: #1888550 Change-Id: I621a00d34e9c2b14234e11e94857a39fe54a111f
This commit is contained in:
parent
641762befc
commit
122036638d
@ -124,6 +124,16 @@ class TestBrcdFCSanLookupService(brcd_lookup.BrcdFCSanLookupService,
|
|||||||
initiator_list, target_list)
|
initiator_list, target_list)
|
||||||
self.assertDictEqual(_device_map_to_verify, device_map)
|
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):
|
class FakeClient(object):
|
||||||
def is_supported_firmware(self):
|
def is_supported_firmware(self):
|
||||||
|
@ -111,6 +111,7 @@ class BrcdFCSanLookupService(fc_service.FCSanLookupService):
|
|||||||
# Get name server data from fabric and find the targets
|
# Get name server data from fabric and find the targets
|
||||||
# logged in
|
# logged in
|
||||||
nsinfo = ''
|
nsinfo = ''
|
||||||
|
conn = None
|
||||||
try:
|
try:
|
||||||
LOG.debug("Getting name server data for "
|
LOG.debug("Getting name server data for "
|
||||||
"fabric %s", fabric_ip)
|
"fabric %s", fabric_ip)
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fix `UnboundLocalError` on the Brocade lookup driver on southbound client
|
||||||
|
creation failure during the device mapping retrieval (Bug #1888550).
|
Loading…
Reference in New Issue
Block a user