diff options
author | Jacob Anders <janders@redhat.com> | 2021-02-08 15:44:36 +1000 |
---|---|---|
committer | Jacob Anders <janders@redhat.com> | 2021-02-11 17:03:18 +1000 |
commit | 05df3d7aa4aa7a1fd25a2f2d55726197e1b5f9df (patch) | |
tree | a1275de79c194277a9016d51d6cd44c4e91aae39 /ironic/tests/unit/drivers/modules/redfish/test_management.py | |
parent | f81843aa05cdc3b20f3a85fb30fb098b4fa7dbd9 (diff) | |
download | ironic-05df3d7aa4aa7a1fd25a2f2d55726197e1b5f9df.tar.gz |
Use OOB inspection to fetch MACs for IB inspection
This change adds get_mac_addresses call to the ManagementInterface which will
be used by both out-of-band inspection and in-band inspection with
ironic-inspector. This will remove the necessity of manually defining MAC
addresses for nodes and/or enabling IPMI functionality on Redfish-based
systems.
Change-Id: I3debcd1f32a2627dafd8456ec73a71fc7c402ebb
Story: 2008038
Task: 40699
Diffstat (limited to 'ironic/tests/unit/drivers/modules/redfish/test_management.py')
-rw-r--r-- | ironic/tests/unit/drivers/modules/redfish/test_management.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_management.py b/ironic/tests/unit/drivers/modules/redfish/test_management.py index e0f174c84..fb397e615 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_management.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_management.py @@ -17,6 +17,7 @@ import datetime from unittest import mock from oslo_utils import importutils +from oslo_utils import units from ironic.common import boot_devices from ironic.common import boot_modes @@ -56,6 +57,28 @@ class RedfishManagementTestCase(db_base.DbTestCase): self.chassis_uuid = 'XXX-YYY-ZZZ' self.drive_uuid = 'ZZZ-YYY-XXX' + def init_system_mock(self, system_mock, **properties): + + system_mock.reset() + + system_mock.boot.mode = 'uefi' + + system_mock.memory_summary.size_gib = 2 + + system_mock.processors.summary = '8', 'MIPS' + + system_mock.simple_storage.disks_sizes_bytes = ( + 1 * units.Gi, units.Gi * 3, units.Gi * 5) + system_mock.storage.volumes_sizes_bytes = ( + 2 * units.Gi, units.Gi * 4, units.Gi * 6) + + system_mock.ethernet_interfaces.summary = { + '00:11:22:33:44:55': sushy.STATE_ENABLED, + '66:77:88:99:AA:BB': sushy.STATE_DISABLED, + } + + return system_mock + @mock.patch.object(redfish_mgmt, 'sushy', None) def test_loading_error(self): self.assertRaisesRegex( @@ -1446,3 +1469,25 @@ class RedfishManagementTestCase(db_base.DbTestCase): self.assertRaises( exception.UnsupportedDriverExtension, task.driver.management.clear_secure_boot_keys, task) + + @mock.patch.object(redfish_utils, 'get_system', autospec=True) + def test_get_mac_addresses_success(self, mock_get_system): + expected_properties = {'00:11:22:33:44:55': 'enabled'} + + self.init_system_mock(mock_get_system.return_value) + + with task_manager.acquire(self.context, self.node.uuid, + shared=True) as task: + self.assertEqual(expected_properties, + task.driver.management.get_mac_addresses(task)) + + @mock.patch.object(redfish_utils, 'get_system', autospec=True) + def test_get_mac_addresses_no_ports_found(self, mock_get_system): + expected_properties = None + + system_mock = self.init_system_mock(mock_get_system.return_value) + system_mock.ethernet_interfaces.summary = None + with task_manager.acquire(self.context, self.node.uuid, + shared=True) as task: + self.assertEqual(expected_properties, + task.driver.management.get_mac_addresses(task)) |