Merge "Scan for mac through all devices"

This commit is contained in:
Jenkins 2017-03-02 11:16:27 +00:00 committed by Gerrit Code Review
commit 55d3c9a79d
2 changed files with 6 additions and 4 deletions

View File

@ -716,8 +716,10 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
list(self.bridge_mappings.values())[0])
else:
devices = ip_lib.IPWrapper().get_devices(True)
if devices:
mac = ip_lib.get_device_mac(devices[0].name)
for device in devices:
mac = ip_lib.get_device_mac(device.name)
if mac:
break
else:
LOG.error(_LE("Unable to obtain MAC address for unique ID. "
"Agent terminated!"))

View File

@ -872,11 +872,11 @@ class TestLinuxBridgeManager(base.BaseTestCase):
mock.patch.object(
ip_lib,
"get_device_mac",
return_value='16:63:69:10:a0:59') as mock_gim:
side_effect=[None, '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")
mock_gim.assert_has_calls([mock.call("eth1"), mock.call("eth2")])
class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):