lb-agent: fix get_interfaces_on_bridge returning None
Change get_interfaces_on_bridge() to return [] instead of None if the bridge is not found, as callers are expecting an iterator. Change-Id: I359a2a0cf932c049f6891d4ba3eb8b9b23ab360d Related-Bug: 1284311
This commit is contained in:
parent
de916ec823
commit
12c551c690
@ -143,6 +143,8 @@ class LinuxBridgeManager:
|
||||
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
|
||||
BRIDGE_NAME_PLACEHOLDER, bridge_name)
|
||||
return os.listdir(bridge_interface_path)
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_tap_devices_count(self, bridge_name):
|
||||
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
|
||||
|
@ -231,6 +231,10 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
self.assertEqual(self.lbm.get_interfaces_on_bridge("br0"),
|
||||
["qbr1"])
|
||||
|
||||
def test_get_interfaces_on_bridge_not_existing(self):
|
||||
self.lbm.device_exists = mock.Mock(return_value=False)
|
||||
self.assertEqual([], self.lbm.get_interfaces_on_bridge("br0"))
|
||||
|
||||
def test_get_tap_devices_count(self):
|
||||
with mock.patch.object(os, 'listdir') as listdir_fn:
|
||||
listdir_fn.return_value = ['tap2101', 'eth0.100', 'vxlan-1000']
|
||||
|
Loading…
x
Reference in New Issue
Block a user