"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ironic/tests/unit/drivers/modules/drac/test_management.py" between
ironic-17.0.2.tar.gz and ironic-17.0.3.tar.gz

About: OpenStack Ironic (Optional Service: Bare-Metal Provisioning) aims to provision bare metal machines instead of virtual machines, forked from the Nova baremetal driver.
The "Wallaby" series (latest release).

test_management.py  (ironic-17.0.2):test_management.py  (ironic-17.0.3)
skipping to change at line 37 skipping to change at line 37
import ironic.common.boot_devices import ironic.common.boot_devices
from ironic.common import exception from ironic.common import exception
from ironic.common import molds from ironic.common import molds
from ironic.conductor import task_manager from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils from ironic.conductor import utils as manager_utils
from ironic.drivers.modules import deploy_utils from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules.drac import common as drac_common from ironic.drivers.modules.drac import common as drac_common
from ironic.drivers.modules.drac import job as drac_job from ironic.drivers.modules.drac import job as drac_job
from ironic.drivers.modules.drac import management as drac_mgmt from ironic.drivers.modules.drac import management as drac_mgmt
from ironic.drivers.modules.drac import utils as drac_utils
from ironic.drivers.modules.redfish import utils as redfish_utils from ironic.drivers.modules.redfish import utils as redfish_utils
from ironic.tests.unit.drivers.modules.drac import utils as test_utils from ironic.tests.unit.drivers.modules.drac import utils as test_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
dracclient_exceptions = importutils.try_import('dracclient.exceptions') dracclient_exceptions = importutils.try_import('dracclient.exceptions')
sushy = importutils.try_import('sushy') sushy = importutils.try_import('sushy')
INFO_DICT = test_utils.INFO_DICT INFO_DICT = test_utils.INFO_DICT
@mock.patch.object(drac_common, 'get_drac_client', spec_set=True, @mock.patch.object(drac_common, 'get_drac_client', spec_set=True,
skipping to change at line 849 skipping to change at line 850
self.config(enabled_hardware_types=['idrac'], self.config(enabled_hardware_types=['idrac'],
enabled_power_interfaces=['idrac-redfish'], enabled_power_interfaces=['idrac-redfish'],
enabled_management_interfaces=['idrac-redfish']) enabled_management_interfaces=['idrac-redfish'])
def test_export_configuration_name_missing(self): def test_export_configuration_name_missing(self):
task = mock.Mock(node=self.node, context=self.context) task = mock.Mock(node=self.node, context=self.context)
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
self.management.export_configuration, task, None) self.management.export_configuration, task, None)
@mock.patch.object(redfish_utils, 'get_system', autospec=True) @mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_export_configuration_no_managers(self, mock_get_system):
task = mock.Mock(node=self.node, context=self.context)
mock_get_system.return_value.managers = []
self.assertRaises(exception.DracOperationError,
self.management.export_configuration, task, 'edge')
@mock.patch.object(drac_mgmt, 'LOG', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_export_configuration_oem_not_found(self, mock_get_system,
mock_log):
task = mock.Mock(node=self.node, context=self.context)
fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.side_effect = (
sushy.exceptions.OEMExtensionNotFoundError)
mock_get_system.return_value.managers = [fake_manager1]
self.assertRaises(exception.RedfishError,
self.management.export_configuration, task, 'edge')
self.assertEqual(mock_log.error.call_count, 1)
@mock.patch.object(drac_mgmt, 'LOG', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_export_configuration_all_managers_fail(self, mock_get_system,
mock_log):
task = mock.Mock(node=self.node, context=self.context)
fake_manager_oem1 = mock.Mock()
fake_manager_oem1.export_system_configuration.side_effect = (
sushy.exceptions.SushyError)
fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.return_value = fake_manager_oem1
fake_manager_oem2 = mock.Mock()
fake_manager_oem2.export_system_configuration.side_effect = (
sushy.exceptions.SushyError)
fake_manager2 = mock.Mock()
fake_manager2.get_oem_extension.return_value = fake_manager_oem2
mock_get_system.return_value.managers = [fake_manager1, fake_manager2]
self.assertRaises(exception.DracOperationError,
self.management.export_configuration,
task, 'edge')
self.assertEqual(mock_log.debug.call_count, 2)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_export_configuration_export_failed(self, mock_get_system): def test_export_configuration_export_failed(self, mock_get_system):
task = mock.Mock(node=self.node, context=self.context) task = mock.Mock(node=self.node, context=self.context)
fake_manager_oem1 = mock.Mock() fake_manager_oem1 = mock.Mock()
fake_manager_oem1.export_system_configuration = mock.Mock() fake_manager_oem1.export_system_configuration = mock.Mock()
fake_manager_oem1.export_system_configuration.status_code = 500 fake_manager_oem1.export_system_configuration.status_code = 500
fake_manager1 = mock.Mock() fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.return_value = fake_manager_oem1 fake_manager1.get_oem_extension.return_value = fake_manager_oem1
mock_get_system.return_value.managers = [fake_manager1] mock_get_system.return_value.managers = [fake_manager1]
self.assertRaises(exception.DracOperationError, self.assertRaises(exception.DracOperationError,
self.management.export_configuration, task, 'edge') self.management.export_configuration, task, 'edge')
@mock.patch.object(drac_mgmt, 'LOG', autospec=True) @mock.patch.object(drac_utils, 'LOG', autospec=True)
@mock.patch.object(molds, 'save_configuration', autospec=True) @mock.patch.object(molds, 'save_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True) @mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_export_configuration_success(self, mock_get_system, def test_export_configuration_success(self, mock_get_system,
mock_save_configuration, mock_save_configuration,
mock_log): mock_log):
task = mock.Mock(node=self.node, context=self.context) task = mock.Mock(node=self.node, context=self.context)
fake_manager_oem1 = mock.Mock() fake_manager_oem1 = mock.Mock()
fake_manager_oem1.export_system_configuration.side_effect = ( fake_manager_oem1.export_system_configuration.side_effect = (
sushy.exceptions.SushyError) sushy.exceptions.SushyError)
fake_manager1 = mock.Mock() fake_manager1 = mock.Mock()
skipping to change at line 952 skipping to change at line 909
@mock.patch.object(molds, 'get_configuration', autospec=True) @mock.patch.object(molds, 'get_configuration', autospec=True)
def test_import_configuration_file_not_found(self, mock_get_configuration): def test_import_configuration_file_not_found(self, mock_get_configuration):
task = mock.Mock(node=self.node, context=self.context) task = mock.Mock(node=self.node, context=self.context)
mock_get_configuration.return_value = None mock_get_configuration.return_value = None
self.assertRaises(exception.DracOperationError, self.assertRaises(exception.DracOperationError,
self.management.import_configuration, task, 'edge') self.management.import_configuration, task, 'edge')
@mock.patch.object(molds, 'get_configuration', autospec=True) @mock.patch.object(molds, 'get_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True) @mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_import_configuration_no_managers(self, mock_get_system,
mock_get_configuration):
task = mock.Mock(node=self.node, context=self.context)
fake_system = mock.Mock(managers=[])
mock_get_configuration.return_value = json.loads(
'{"oem": {"interface": "idrac-redfish", '
'"data": {"prop1": "value1", "prop2": 2}}}')
mock_get_system.return_value = fake_system
self.assertRaises(exception.DracOperationError,
self.management.import_configuration, task, 'edge')
@mock.patch.object(drac_mgmt, 'LOG', autospec=True)
@mock.patch.object(molds, 'get_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_import_configuration_oem_not_found(self, mock_get_system,
mock_get_configuration,
mock_log):
task = mock.Mock(node=self.node, context=self.context)
fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.side_effect = (
sushy.exceptions.OEMExtensionNotFoundError)
fake_system = mock.Mock(managers=[fake_manager1])
mock_get_system.return_value = fake_system
mock_get_configuration.return_value = json.loads(
'{"oem": {"interface": "idrac-redfish", '
'"data": {"prop1": "value1", "prop2": 2}}}')
self.assertRaises(exception.RedfishError,
self.management.import_configuration, task, 'edge')
self.assertEqual(mock_log.error.call_count, 1)
@mock.patch.object(drac_mgmt, 'LOG', autospec=True)
@mock.patch.object(molds, 'get_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_import_configuration_all_managers_fail(self, mock_get_system,
mock_get_configuration,
mock_log):
task = mock.Mock(node=self.node, context=self.context)
fake_manager_oem1 = mock.Mock()
fake_manager_oem1.import_system_configuration.side_effect = (
sushy.exceptions.SushyError)
fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.return_value = fake_manager_oem1
fake_manager_oem2 = mock.Mock()
fake_manager_oem2.import_system_configuration.side_effect = (
sushy.exceptions.SushyError)
fake_manager2 = mock.Mock()
fake_manager2.get_oem_extension.return_value = fake_manager_oem2
mock_get_system.return_value.managers = [fake_manager1, fake_manager2]
mock_get_configuration.return_value = json.loads(
'{"oem": {"interface": "idrac-redfish", '
'"data": {"prop1": "value1", "prop2": 2}}}')
self.assertRaises(exception.DracOperationError,
self.management.import_configuration, task, 'edge')
self.assertEqual(mock_log.debug.call_count, 2)
@mock.patch.object(molds, 'get_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_import_configuration_incorrect_interface(self, mock_get_system, def test_import_configuration_incorrect_interface(self, mock_get_system,
mock_get_configuration): mock_get_configuration):
task = mock.Mock(node=self.node, context=self.context) task = mock.Mock(node=self.node, context=self.context)
fake_manager_oem1 = mock.Mock() fake_manager_oem1 = mock.Mock()
fake_manager1 = mock.Mock() fake_manager1 = mock.Mock()
fake_manager1.get_oem_extension.return_value = fake_manager_oem1 fake_manager1.get_oem_extension.return_value = fake_manager_oem1
mock_get_system.return_value.managers = [fake_manager1] mock_get_system.return_value.managers = [fake_manager1]
mock_get_configuration.return_value = json.loads( mock_get_configuration.return_value = json.loads(
'{"oem": {"interface": "idrac-wsman", ' '{"oem": {"interface": "idrac-wsman", '
'"data": {"prop1": "value1", "prop2": 2}}}') '"data": {"prop1": "value1", "prop2": 2}}}')
self.assertRaises(exception.DracOperationError, self.assertRaises(exception.DracOperationError,
self.management.import_configuration, task, 'edge') self.management.import_configuration, task, 'edge')
@mock.patch.object(deploy_utils, 'get_async_step_return_state', @mock.patch.object(deploy_utils, 'get_async_step_return_state',
autospec=True) autospec=True)
@mock.patch.object(deploy_utils, 'set_async_step_flags', autospec=True) @mock.patch.object(deploy_utils, 'set_async_step_flags', autospec=True)
@mock.patch.object(deploy_utils, 'build_agent_options', autospec=True) @mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
@mock.patch.object(manager_utils, 'node_power_action', autospec=True) @mock.patch.object(manager_utils, 'node_power_action', autospec=True)
@mock.patch.object(drac_mgmt, 'LOG', autospec=True) @mock.patch.object(drac_utils, 'LOG', autospec=True)
@mock.patch.object(molds, 'get_configuration', autospec=True) @mock.patch.object(molds, 'get_configuration', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True) @mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_import_configuration_success( def test_import_configuration_success(
self, mock_get_system, mock_get_configuration, mock_log, self, mock_get_system, mock_get_configuration, mock_log,
mock_power, mock_build_agent_options, mock_power, mock_build_agent_options,
mock_set_async_step_flags, mock_get_async_step_return_state): mock_set_async_step_flags, mock_get_async_step_return_state):
deploy_opts = mock.Mock() deploy_opts = mock.Mock()
mock_build_agent_options.return_value = deploy_opts mock_build_agent_options.return_value = deploy_opts
step_result = mock.Mock() step_result = mock.Mock()
mock_get_async_step_return_state.return_value = step_result mock_get_async_step_return_state.return_value = step_result
skipping to change at line 1420 skipping to change at line 1317
self.node.clean_step = None self.node.clean_step = None
self.node.save() self.node.save()
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task: shared=False) as task:
self.management._set_failed(task, 'error', 'log message') self.management._set_failed(task, 'error', 'log message')
mock_deploy_handler.assert_called_once_with( mock_deploy_handler.assert_called_once_with(
task, 'error', 'log message') task, 'error', 'log message')
@mock.patch.object(drac_mgmt, 'redfish_utils', autospec=True) @mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
def test_clear_job_queue(self, mock_redfish_utils): def test_clear_job_queue(self, mock_redfish_utils):
mock_system = mock_redfish_utils.get_system.return_value mock_system = mock_redfish_utils.get_system.return_value
mock_manager = mock.MagicMock() mock_manager = mock.MagicMock()
mock_system.managers = [mock_manager] mock_system.managers = [mock_manager]
mock_manager_oem = mock_manager.get_oem_extension.return_value mock_manager_oem = mock_manager.get_oem_extension.return_value
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task: shared=False) as task:
task.driver.management.clear_job_queue(task) task.driver.management.clear_job_queue(task)
mock_manager_oem.job_service.delete_jobs.assert_called_once_with( mock_manager_oem.job_service.delete_jobs.assert_called_once_with(
job_ids=['JID_CLEARALL']) job_ids=['JID_CLEARALL'])
@mock.patch.object(drac_mgmt, 'redfish_utils', autospec=True) @mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
def test_reset_idrac(self, mock_redfish_utils): autospec=True)
@mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
def test_reset_idrac(self, mock_redfish_utils, mock_wait_system_ready):
mock_system = mock_redfish_utils.get_system.return_value mock_system = mock_redfish_utils.get_system.return_value
mock_manager = mock.MagicMock() mock_manager = mock.MagicMock()
mock_system.managers = [mock_manager] mock_system.managers = [mock_manager]
mock_manager_oem = mock_manager.get_oem_extension.return_value mock_manager_oem = mock_manager.get_oem_extension.return_value
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task: shared=False) as task:
task.driver.management.reset_idrac(task) task.driver.management.reset_idrac(task)
mock_manager_oem.reset_idrac.assert_called_once_with() mock_manager_oem.reset_idrac.assert_called_once_with()
@mock.patch.object(drac_mgmt, 'redfish_utils', autospec=True) @mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
def test_known_good_state(self, mock_redfish_utils): autospec=True)
@mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
def test_known_good_state(self, mock_redfish_utils,
mock_wait_system_ready):
mock_system = mock_redfish_utils.get_system.return_value mock_system = mock_redfish_utils.get_system.return_value
mock_manager = mock.MagicMock() mock_manager = mock.MagicMock()
mock_system.managers = [mock_manager] mock_system.managers = [mock_manager]
mock_manager_oem = mock_manager.get_oem_extension.return_value mock_manager_oem = mock_manager.get_oem_extension.return_value
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task: shared=False) as task:
task.driver.management.known_good_state(task) task.driver.management.known_good_state(task)
mock_manager_oem.job_service.delete_jobs.assert_called_once_with( mock_manager_oem.job_service.delete_jobs.assert_called_once_with(
job_ids=['JID_CLEARALL']) job_ids=['JID_CLEARALL'])
 End of changes. 8 change blocks. 
111 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)