Fix getting agent id in linuxbridge agent
If bridge_mappings is configured in linuxbridge agent, it will now determine agent_id which is based on MAC address of first device from bridge_mappings in correct way. Change-Id: I940379b2fd3b5f8c96cdf3b7a3c0da78532491f6 Closes-bug: #1542923
This commit is contained in:
parent
2909f0d486
commit
034d5a2f37
|
@ -654,7 +654,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
|
|||
|
||||
def get_agent_id(self):
|
||||
if self.bridge_mappings:
|
||||
mac = utils.get_interface_mac(self.bridge_mappings.values[0])
|
||||
mac = utils.get_interface_mac(
|
||||
list(self.bridge_mappings.values())[0])
|
||||
else:
|
||||
devices = ip_lib.IPWrapper().get_devices(True)
|
||||
if devices:
|
||||
|
|
|
@ -1228,6 +1228,37 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||
def test_ensure_port_admin_state_down(self):
|
||||
self._test_ensure_port_admin_state(False)
|
||||
|
||||
def test_get_agent_id_bridge_mappings(self):
|
||||
lbm = get_linuxbridge_manager(BRIDGE_MAPPINGS, INTERFACE_MAPPINGS)
|
||||
with mock.patch.object(utils,
|
||||
"get_interface_mac",
|
||||
return_value='16:63:69:10:a0:59') as mock_gim:
|
||||
|
||||
agent_id = lbm.get_agent_id()
|
||||
self.assertEqual("lb16636910a059", agent_id)
|
||||
mock_gim.assert_called_with(BRIDGE_MAPPING_VALUE)
|
||||
|
||||
def test_get_agent_id_no_bridge_mappings(self):
|
||||
devices_mock = [
|
||||
mock.MagicMock(),
|
||||
mock.MagicMock()
|
||||
]
|
||||
devices_mock[0].name = "eth1"
|
||||
devices_mock[1].name = "eth2"
|
||||
bridge_mappings = {}
|
||||
lbm = get_linuxbridge_manager(bridge_mappings, INTERFACE_MAPPINGS)
|
||||
with mock.patch.object(ip_lib.IPWrapper,
|
||||
'get_devices',
|
||||
return_value=devices_mock), \
|
||||
mock.patch.object(
|
||||
utils,
|
||||
"get_interface_mac",
|
||||
return_value='16:63:69:10:a0:59') as mock_gim:
|
||||
|
||||
agent_id = lbm.get_agent_id()
|
||||
self.assertEqual("lb16636910a059", agent_id)
|
||||
mock_gim.assert_called_with("eth1")
|
||||
|
||||
|
||||
class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue