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:
Darragh O'Reilly 2014-04-04 16:46:30 +00:00
parent de916ec823
commit 12c551c690
2 changed files with 6 additions and 0 deletions

View File

@ -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(

View File

@ -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']