Merge "lb-agent: fix get_interfaces_on_bridge returning None"

This commit is contained in:
Jenkins 2014-04-11 14:09:59 +00:00 committed by Gerrit Code Review
commit a47e9335aa
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

@ -229,6 +229,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']