Merge "Fix: make Intel CNA hardware manager none generic"
This commit is contained in:
commit
c7ff931fe6
@ -69,29 +69,20 @@ def _disable_embedded_lldp_agent_in_cna_card():
|
|||||||
.format(str(failed_dirs).strip('[]')))
|
.format(str(failed_dirs).strip('[]')))
|
||||||
|
|
||||||
|
|
||||||
class IntelCnaHardwareManager(hardware.GenericHardwareManager):
|
class IntelCnaHardwareManager(hardware.HardwareManager):
|
||||||
HARDWARE_MANAGER_NAME = 'IntelCnaHardwareManager'
|
HARDWARE_MANAGER_NAME = 'IntelCnaHardwareManager'
|
||||||
HARDWARE_MANAGER_VERSION = '1.0'
|
HARDWARE_MANAGER_VERSION = '1.0'
|
||||||
|
|
||||||
def evaluate_hardware_support(self):
|
def evaluate_hardware_support(self):
|
||||||
if _detect_cna_card():
|
if _detect_cna_card():
|
||||||
LOG.debug('Found Intel CNA network card')
|
LOG.debug('Found Intel CNA network card')
|
||||||
|
# On Intel CNA cards, in order to make LLDP info collecting
|
||||||
|
# possible, the embedded LLDP agent, which runs inside that
|
||||||
|
# card, needs to be turned off.
|
||||||
|
if CONF.collect_lldp:
|
||||||
|
LOG.info('Disable CNA network card embedded lldp agent now')
|
||||||
|
_disable_embedded_lldp_agent_in_cna_card()
|
||||||
return hardware.HardwareSupport.MAINLINE
|
return hardware.HardwareSupport.MAINLINE
|
||||||
else:
|
else:
|
||||||
LOG.debug('No Intel CNA network card found')
|
LOG.debug('No Intel CNA network card found')
|
||||||
return hardware.HardwareSupport.NONE
|
return hardware.HardwareSupport.NONE
|
||||||
|
|
||||||
def collect_lldp_data(self, interface_names):
|
|
||||||
"""Collect and convert LLDP info from the node.
|
|
||||||
|
|
||||||
On Intel CNA cards, in order to make LLDP info collecting possible,
|
|
||||||
the embedded LLDP agent, which runs inside that card, needs to be
|
|
||||||
turned off. Then we can give the control back to the super class.
|
|
||||||
|
|
||||||
:param interface_names: list of names of node's interfaces.
|
|
||||||
:return: a dict, containing the lldp data from every interface.
|
|
||||||
"""
|
|
||||||
|
|
||||||
_disable_embedded_lldp_agent_in_cna_card()
|
|
||||||
return super(IntelCnaHardwareManager, self).collect_lldp_data(
|
|
||||||
interface_names)
|
|
||||||
|
@ -118,13 +118,29 @@ class TestIntelCnaHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(cna, 'LOG', autospec=True)
|
@mock.patch.object(cna, 'LOG', autospec=True)
|
||||||
@mock.patch.object(cna, '_detect_cna_card', autospec=True)
|
@mock.patch.object(cna, '_detect_cna_card', autospec=True)
|
||||||
def test_evaluate_hardware_support(self, mock_detect_card, mock_log):
|
def test_evaluate_hardware_support_with_collect_lldp_disabled(
|
||||||
|
self, mock_detect_card, mock_log):
|
||||||
mock_detect_card.return_value = True
|
mock_detect_card.return_value = True
|
||||||
expected_support = hardware.HardwareSupport.MAINLINE
|
expected_support = hardware.HardwareSupport.MAINLINE
|
||||||
actual_support = self.hardware.evaluate_hardware_support()
|
actual_support = self.hardware.evaluate_hardware_support()
|
||||||
self.assertEqual(expected_support, actual_support)
|
self.assertEqual(expected_support, actual_support)
|
||||||
mock_log.debug.assert_called_once()
|
mock_log.debug.assert_called_once()
|
||||||
|
|
||||||
|
@mock.patch.object(cna, 'LOG', autospec=True)
|
||||||
|
@mock.patch.object(cna, '_detect_cna_card', autospec=True)
|
||||||
|
@mock.patch.object(cna, '_disable_embedded_lldp_agent_in_cna_card',
|
||||||
|
autospec=True)
|
||||||
|
def test_evaluate_hardware_support_with_collect_lldp_enabled(
|
||||||
|
self, mock_disable_lldp_agent, mock_detect_card, mock_log):
|
||||||
|
self.config(collect_lldp=True)
|
||||||
|
mock_detect_card.return_value = True
|
||||||
|
expected_support = hardware.HardwareSupport.MAINLINE
|
||||||
|
actual_support = self.hardware.evaluate_hardware_support()
|
||||||
|
self.assertEqual(expected_support, actual_support)
|
||||||
|
mock_log.debug.assert_called_once()
|
||||||
|
mock_log.info.assert_called_once()
|
||||||
|
mock_disable_lldp_agent.assert_called_once()
|
||||||
|
|
||||||
@mock.patch.object(cna, 'LOG', autospec=True)
|
@mock.patch.object(cna, 'LOG', autospec=True)
|
||||||
@mock.patch.object(cna, '_detect_cna_card', autospec=True)
|
@mock.patch.object(cna, '_detect_cna_card', autospec=True)
|
||||||
def test_evaluate_hardware_support_no_cna_card_detected(self,
|
def test_evaluate_hardware_support_no_cna_card_detected(self,
|
||||||
@ -135,19 +151,3 @@ class TestIntelCnaHardwareManager(base.IronicAgentTest):
|
|||||||
actual_support = self.hardware.evaluate_hardware_support()
|
actual_support = self.hardware.evaluate_hardware_support()
|
||||||
self.assertEqual(expected_support, actual_support)
|
self.assertEqual(expected_support, actual_support)
|
||||||
mock_log.debug.assert_called_once()
|
mock_log.debug.assert_called_once()
|
||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, 'collect_lldp_data',
|
|
||||||
autospec=True)
|
|
||||||
def test_collect_lldp_data(self, mock_super_collect):
|
|
||||||
iface_names = ['eth0', 'eth1']
|
|
||||||
returned_lldp_data = [
|
|
||||||
(0, 'foo'),
|
|
||||||
(1, 'bar'),
|
|
||||||
]
|
|
||||||
mock_super_collect.return_value = returned_lldp_data
|
|
||||||
with mock.patch.object(cna, '_disable_embedded_lldp_agent_in_cna_card',
|
|
||||||
autospec=True):
|
|
||||||
result = self.hardware.collect_lldp_data(iface_names)
|
|
||||||
mock_super_collect.assert_called_once_with(self.hardware,
|
|
||||||
iface_names)
|
|
||||||
self.assertEqual(returned_lldp_data, result)
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes an issue with the IntelCnaHardwareManager which prevented hardware
|
||||||
|
managers with lower priority to be executed and therefore may blocked the
|
||||||
|
initialization and collection of hardware these managers are supposed to take
|
||||||
|
care of.
|
Loading…
Reference in New Issue
Block a user