Browse Source

Merge "Do not fail network interface collection on unsupported interface"

changes/88/787688/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
9edb13d891
3 changed files with 19 additions and 6 deletions
  1. +7
    -2
      ironic_python_agent/hardware.py
  2. +7
    -4
      ironic_python_agent/tests/unit/test_hardware.py
  3. +5
    -0
      releasenotes/notes/no-mac-54616606ee6b844d.yaml

+ 7
- 2
ironic_python_agent/hardware.py View File

@ -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)


+ 7
- 4
ironic_python_agent/tests/unit/test_hardware.py View File

@ -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
- 0
releasenotes/notes/no-mac-54616606ee6b844d.yaml View File

@ -0,0 +1,5 @@
---
fixes:
- |
No longer crashes if MAC address cannot be determined for one of the
network interfaces.

Loading…
Cancel
Save