Do not fail network interface collection on unsupported interface
Currently if one interface cannot be handled (e.g. it has empty MAC), the whole collection fails. Ignore unsupported interfaces instead. Change-Id: Ibdaad62b39c239d4f3fb3111c2fae9e31e877b28
This commit is contained in:
parent
993f9a0ceb
commit
1ab405b509
@ -1100,8 +1100,13 @@ class GenericHardwareManager(HardwareManager):
|
||||
interface_names=iface_names)
|
||||
|
||||
for iface_name in iface_names:
|
||||
result = dispatch_to_managers(
|
||||
'get_interface_info', interface_name=iface_name)
|
||||
try:
|
||||
result = dispatch_to_managers(
|
||||
'get_interface_info', interface_name=iface_name)
|
||||
except errors.HardwareManagerMethodNotFound:
|
||||
LOG.warning('No hardware manager was able to handle '
|
||||
'interface %s', iface_name)
|
||||
continue
|
||||
result.lldp = self._get_lldp_data(iface_name)
|
||||
network_interfaces_list.append(result)
|
||||
|
||||
|
@ -238,8 +238,8 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
mocked_ifaddresses,
|
||||
mockedget_managers):
|
||||
mockedget_managers.return_value = [hardware.GenericHardwareManager()]
|
||||
mocked_listdir.return_value = ['lo', 'eth0']
|
||||
mocked_exists.side_effect = [False, True]
|
||||
mocked_listdir.return_value = ['lo', 'eth0', 'foobar']
|
||||
mocked_exists.side_effect = [False, True, True]
|
||||
mocked_open.return_value.__enter__ = lambda s: s
|
||||
mocked_open.return_value.__exit__ = mock.Mock()
|
||||
read_mock = mocked_open.return_value.read
|
||||
@ -249,8 +249,11 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
netifaces.AF_INET6: [{'addr': 'fd00::101'}]
|
||||
}
|
||||
mocked_execute.return_value = ('em0\n', '')
|
||||
mock_get_mac.mock_has_carrier = True
|
||||
mock_get_mac.return_value = '00:0c:29:8c:11:b1'
|
||||
mock_has_carrier.return_value = True
|
||||
mock_get_mac.side_effect = [
|
||||
'00:0c:29:8c:11:b1',
|
||||
None,
|
||||
]
|
||||
interfaces = self.hardware.list_network_interfaces()
|
||||
self.assertEqual(1, len(interfaces))
|
||||
self.assertEqual('eth0', interfaces[0].name)
|
||||
|
5
releasenotes/notes/no-mac-54616606ee6b844d.yaml
Normal file
5
releasenotes/notes/no-mac-54616606ee6b844d.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
No longer crashes if MAC address cannot be determined for one of the
|
||||
network interfaces.
|
Loading…
Reference in New Issue
Block a user