Merge "Scan for MAC through all devices in macvtap agent"
This commit is contained in:
commit
a6997efae6
@ -112,13 +112,13 @@ class MacvtapManager(amb.CommonAgentManagerBase):
|
||||
|
||||
def get_agent_id(self):
|
||||
devices = ip_lib.IPWrapper().get_devices(True)
|
||||
if devices:
|
||||
mac = ip_lib.get_device_mac(devices[0].name)
|
||||
return 'macvtap%s' % mac.replace(":", "")
|
||||
else:
|
||||
LOG.error("Unable to obtain MAC address for unique ID. "
|
||||
"Agent terminated!")
|
||||
sys.exit(1)
|
||||
for device in devices:
|
||||
mac = ip_lib.get_device_mac(device.name)
|
||||
if mac:
|
||||
return 'macvtap%s' % mac.replace(":", "")
|
||||
LOG.error("Unable to obtain MAC address for unique ID. "
|
||||
"Agent terminated!")
|
||||
sys.exit(1)
|
||||
|
||||
def get_devices_modified_timestamps(self, devices):
|
||||
# TODO(kevinbenton): this should be implemented to detect
|
||||
|
@ -146,6 +146,17 @@ class TestMacvtapManager(base.BaseTestCase):
|
||||
self.mgr.get_agent_id()
|
||||
mock_exit.assert_called_once_with(1)
|
||||
|
||||
def test_get_agent_id_no_mac(self):
|
||||
mock_devices = [ip_lib.IPDevice('macvtap0'),
|
||||
ip_lib.IPDevice('macvtap1')]
|
||||
with mock.patch.object(ip_lib.IPWrapper, 'get_devices',
|
||||
return_value=mock_devices),\
|
||||
mock.patch.object(ip_lib, 'get_device_mac',
|
||||
side_effect=[None, 'foo:bar:1']) as mock_gdm:
|
||||
self.assertEqual('macvtapfoobar1', self.mgr.get_agent_id())
|
||||
mock_gdm.assert_has_calls([mock.call('macvtap0'),
|
||||
mock.call('macvtap1')])
|
||||
|
||||
def test_get_extension_driver_type(self):
|
||||
self.assertEqual('macvtap', self.mgr.get_extension_driver_type())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user