diff options
author | Aija Jauntēva <aija.jaunteva@dell.com> | 2021-05-19 08:53:04 -0400 |
---|---|---|
committer | Aija Jauntēva <aija.jaunteva@dell.com> | 2021-05-19 09:17:04 -0400 |
commit | 28a94780381243ea1f0ad3706232f45ea89ebe45 (patch) | |
tree | 32b913c241362c99917e2ca1133e1f59f5e797b3 | |
parent | 9a8b501e5c66a1f31adcfcc342f677a6288188fc (diff) | |
download | ironic-28a94780381243ea1f0ad3706232f45ea89ebe45.tar.gz |
Remove inventory time workaround for WS-man BIOS
The workaround was necessary for older versions to be backportable.
Change-Id: Ifd0d66ad4ed191fafd58090f92e4ee44814f4b86
-rw-r--r-- | ironic/drivers/modules/drac/bios.py | 38 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/drac/test_bios.py | 42 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/third_party_driver_mock_specs.py | 11 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/third_party_driver_mocks.py | 9 |
4 files changed, 11 insertions, 89 deletions
diff --git a/ironic/drivers/modules/drac/bios.py b/ironic/drivers/modules/drac/bios.py index b6f59db61..52ccc8e66 100644 --- a/ironic/drivers/modules/drac/bios.py +++ b/ironic/drivers/modules/drac/bios.py @@ -43,38 +43,6 @@ LOG = logging.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) -def _get_last_system_inventory_time(client, task): - """Gets last system inventory time - - Uses last_system_inventory_time, if that is not available, then fall - backs to raw requests. Warns user about option to update - python-dracclient. - :param client: python-dracclient instance - :param task: a TaskManager instance with the node to act on - :returns: Last system inventory time - """ - try: - return client.get_system().last_system_inventory_time - except AttributeError as ae: - LOG.warning("Failed to get the last system inventory time for node " - "%(node_uuid)s. Update the python-dracclient to the " - "latest version. Reason: %(error)s", - {"node_uuid": task.node.uuid, "error": ae}) - driver_info = drac_common.parse_driver_info(task.node) - client = drac_client.WSManClient( - driver_info['drac_address'], driver_info['drac_username'], - driver_info['drac_password'], driver_info['drac_port'], - driver_info['drac_path'], driver_info['drac_protocol']) - - doc = client.enumerate( - drac_uris.DCIM_SystemView, filter_query=( - 'select LastSystemInventoryTime from DCIM_SystemView')) - - return drac_utils.find_xml( - doc, 'LastSystemInventoryTime', - drac_uris.DCIM_SystemView).text.split('.')[0] - - class DracRedfishBIOS(redfish_bios.RedfishBIOS): """iDRAC Redfish interface for BIOS settings-related actions. @@ -254,8 +222,8 @@ class DracWSManBIOS(base.BIOSInterface): # reset start time time_difference = 0 # Get the last system inventory time after reboot - factory_reset_time_endof_reboot = _get_last_system_inventory_time( - client, task) + factory_reset_time_endof_reboot = (client.get_system() + .last_system_inventory_time) LOG.debug("Factory resetting node %(node_uuid)s " "last inventory reboot time after factory reset " @@ -443,7 +411,7 @@ class DracWSManBIOS(base.BIOSInterface): reboot_needed = True try: factory_reset_time_before_reboot =\ - _get_last_system_inventory_time(client, task) + client.get_system().last_system_inventory_time LOG.debug("Factory resetting node %(node_uuid)s " "last inventory reboot time before factory reset " diff --git a/ironic/tests/unit/drivers/modules/drac/test_bios.py b/ironic/tests/unit/drivers/modules/drac/test_bios.py index 8aae25be2..ad39b9050 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_bios.py +++ b/ironic/tests/unit/drivers/modules/drac/test_bios.py @@ -21,9 +21,7 @@ Test class for DRAC BIOS configuration specific methods from unittest import mock -import dracclient.client from dracclient import exceptions as drac_exceptions -import dracclient.utils from oslo_utils import timeutils from ironic.common import exception @@ -124,8 +122,6 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): self.assertRaises(exception.DracOperationError, task.driver.bios.cache_bios_settings, task) - @mock.patch.object(dracclient.client, 'WSManClient', autospec=True) - @mock.patch.object(dracclient.utils, 'find_xml', autospec=True) @mock.patch.object(deploy_utils, 'get_async_step_return_state', autospec=True) @mock.patch.object(deploy_utils, 'set_async_step_flags', autospec=True) @@ -134,8 +130,8 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): @mock.patch.object(drac_job, 'validate_job_queue', spec_set=True, autospec=True) def _test_step(self, mock_validate_job_queue, mock_cache_bios_settings, - mock_set_async_step_flags, mock_get_async_step_return_state, - mock_findxml, mock_wsmanclient, attribute_error=False): + mock_set_async_step_flags, + mock_get_async_step_return_state): if self.node.clean_step: step_data = self.node.clean_step expected_state = states.CLEANWAIT @@ -156,16 +152,9 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): mock_system = None factory_reset_time_before_reboot = None - if attribute_error: - mock_system = mock.Mock(spec=[]) - mock_xml = mock.Mock() - mock_xml.text = '20200910233024.000000+000' - mock_findxml.return_value = mock_xml - else: - mock_system = mock.Mock() - factory_reset_time_before_reboot = "20200910233024" - mock_system.last_system_inventory_time =\ - "20200910233024" + mock_system = mock.Mock() + factory_reset_time_before_reboot = "20200910233024" + mock_system.last_system_inventory_time = "20200910233024" self.mock_client.get_system.return_value = mock_system @@ -177,12 +166,9 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): self.mock_client.commit_pending_lifecycle_changes.\ assert_called_once_with(reboot=True) self.mock_client.get_system.assert_called_once() - if attribute_error: - mock_findxml.assert_called_once() - else: - self.assertEqual(factory_reset_time_before_reboot, - info['factory_reset_time_before_reboot']) - mock_findxml.assert_not_called() + self.assertEqual(factory_reset_time_before_reboot, + info['factory_reset_time_before_reboot']) + if step == 'apply_configuration': ret_state = task.driver.bios.apply_configuration(task, data) @@ -206,24 +192,12 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): self.node.save() self._test_step() - def test_factory_reset_clean_attribute_error(self): - self.node.clean_step = {'priority': 100, 'interface': 'bios', - 'step': 'factory_reset', 'argsinfo': {}} - self.node.save() - self._test_step(attribute_error=True) - def test_factory_reset_deploy(self): self.node.deploy_step = {'priority': 100, 'interface': 'bios', 'step': 'factory_reset', 'argsinfo': {}} self.node.save() self._test_step() - def test_factory_reset_deploy_attribute_error(self): - self.node.deploy_step = {'priority': 100, 'interface': 'bios', - 'step': 'factory_reset', 'argsinfo': {}} - self.node.save() - self._test_step(attribute_error=True) - def test_apply_configuration_clean(self): settings = [{'name': 'ProcVirtualization', 'value': 'Enabled'}] self.node.clean_step = {'priority': 100, 'interface': 'bios', diff --git a/ironic/tests/unit/drivers/third_party_driver_mock_specs.py b/ironic/tests/unit/drivers/third_party_driver_mock_specs.py index a8d0b996e..fa3cc373e 100644 --- a/ironic/tests/unit/drivers/third_party_driver_mock_specs.py +++ b/ironic/tests/unit/drivers/third_party_driver_mock_specs.py @@ -21,13 +21,10 @@ DRACCLIENT_SPEC = ( 'client', 'constants', 'exceptions', - 'resources', - 'utils' ) DRACCLIENT_CLIENT_MOD_SPEC = ( 'DRACClient', - 'WSManClient' ) DRACCLIENT_CONSTANTS_MOD_SPEC = ( @@ -49,14 +46,6 @@ DRACCLIENT_CONSTANTS_RAID_STATUS_MOD_SPEC = ( 'raid' ) -DRACCLIENT_RESOURCES_URIS_MOD_SPEC = ( - 'DCIM_SystemView', -) - -DRACCLIENT_UTILS_MOD_SPEC = ( - 'find_xml', -) - # proliantutils PROLIANTUTILS_SPEC = ( 'exception', diff --git a/ironic/tests/unit/drivers/third_party_driver_mocks.py b/ironic/tests/unit/drivers/third_party_driver_mocks.py index 694f40d8f..8274dca06 100644 --- a/ironic/tests/unit/drivers/third_party_driver_mocks.py +++ b/ironic/tests/unit/drivers/third_party_driver_mocks.py @@ -99,20 +99,11 @@ if not dracclient: spec_set=mock_specs.DRACCLIENT_CONSTANTS_RAID_STATUS_MOD_SPEC, jbod=mock.sentinel.jbod, raid=mock.sentinel.raid) - dracclient.resources.uris = mock.MagicMock( - spec_set=mock_specs.DRACCLIENT_RESOURCES_URIS_MOD_SPEC, - DCIM_SystemView=mock.sentinel.DCIM_SystemView - ) - dracclient.utils = mock.MagicMock( - spec_set=mock_specs.DRACCLIENT_UTILS_MOD_SPEC - ) sys.modules['dracclient'] = dracclient sys.modules['dracclient.client'] = dracclient.client sys.modules['dracclient.constants'] = dracclient.constants sys.modules['dracclient.exceptions'] = dracclient.exceptions - sys.modules['dracclient.resources.uris'] = dracclient.resources.uris - sys.modules['dracclient.utils'] = dracclient.utils dracclient.exceptions.BaseClientException = type('BaseClientException', (Exception,), {}) |