diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index 8d7c26c68..333bbe848 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -206,7 +206,7 @@ def _write_whole_disk_image(image, image_info, device): command = ['/bin/bash', script, image, device] LOG.info('Writing image with command: {}'.format(' '.join(command))) try: - stdout, stderr = utils.execute(*command, check_exit_code=[0]) + stdout, stderr = utils.execute(*command) except processutils.ProcessExecutionError as e: raise errors.ImageWriteError(device, e.exit_code, e.stdout, e.stderr) @@ -745,8 +745,7 @@ class StandbyExtension(base.BaseAgentExtension): except errors.CommandExecutionError as e: LOG.warning('Failed to sync file system buffers: % s', e) try: - _, stderr = utils.execute(command, use_standard_locale=True, - check_exit_code=[0]) + _, stderr = utils.execute(command, use_standard_locale=True) if 'ignoring request.' in stderr: LOG.debug('%s command failed with error %s, ' 'falling back to sysrq-trigger.', command, stderr) diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 78d31bbb2..b9958e198 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -411,8 +411,8 @@ def list_all_block_devices(block_type='disk', "Cause: %(error)s", {'path': disk_by_path_dir, 'error': e}) columns = utils.LSBLK_COLUMNS - report = utils.execute('lsblk', '-Pbia', '-o{}'.format(','.join(columns)), - check_exit_code=[0])[0] + report = utils.execute('lsblk', '-Pbia', + '-o{}'.format(','.join(columns)))[0] lines = report.splitlines() context = pyudev.Context() diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py index 57a99a84c..a25d38ac5 100644 --- a/ironic_python_agent/tests/unit/extensions/test_standby.py +++ b/ironic_python_agent/tests/unit/extensions/test_standby.py @@ -178,7 +178,7 @@ class TestStandbyExtension(base.IronicAgentTest): execute_mock.return_value = ('', '') standby._write_image(image_info, device) - execute_mock.assert_called_once_with(*command, check_exit_code=[0]) + execute_mock.assert_called_once_with(*command) fix_gpt_mock.assert_called_once_with(device, node_uuid=None) fix_gpt_mock.side_effect = exception.InstanceDeployFailure @@ -193,7 +193,7 @@ class TestStandbyExtension(base.IronicAgentTest): image_info, device) - execute_mock.assert_called_once_with(*command, check_exit_code=[0]) + execute_mock.assert_called_once_with(*command) @mock.patch.object(utils, 'get_node_boot_mode', lambda self: 'bios') @mock.patch.object(hardware, 'dispatch_to_managers', autospec=True) @@ -1044,8 +1044,7 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension._run_shutdown_command('poweroff') calls = [mock.call('sync'), - mock.call('poweroff', use_standard_locale=True, - check_exit_code=[0])] + mock.call('poweroff', use_standard_locale=True)] execute_mock.assert_has_calls(calls) @mock.patch('ironic_python_agent.utils.execute', autospec=True) @@ -1057,8 +1056,7 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension._run_shutdown_command('poweroff') calls = [mock.call('hwclock', '-v', '--systohc'), mock.call('sync'), - mock.call('poweroff', use_standard_locale=True, - check_exit_code=[0]), + mock.call('poweroff', use_standard_locale=True), mock.call("echo o > /proc/sysrq-trigger", shell=True)] execute_mock.assert_has_calls(calls) @@ -1070,8 +1068,7 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension._run_shutdown_command('reboot') calls = [mock.call('sync'), - mock.call('reboot', use_standard_locale=True, - check_exit_code=[0]), + mock.call('reboot', use_standard_locale=True), mock.call("echo b > /proc/sysrq-trigger", shell=True)] execute_mock.assert_has_calls(calls) @@ -1082,8 +1079,7 @@ class TestStandbyExtension(base.IronicAgentTest): success_result = self.agent_extension.run_image() success_result.join() calls = [mock.call('sync'), - mock.call('reboot', use_standard_locale=True, - check_exit_code=[0])] + mock.call('reboot', use_standard_locale=True)] execute_mock.assert_has_calls(calls) self.assertEqual('SUCCEEDED', success_result.command_status) @@ -1105,8 +1101,7 @@ class TestStandbyExtension(base.IronicAgentTest): success_result.join() calls = [mock.call('sync'), - mock.call('poweroff', use_standard_locale=True, - check_exit_code=[0])] + mock.call('poweroff', use_standard_locale=True)] execute_mock.assert_has_calls(calls) self.assertEqual('SUCCEEDED', success_result.command_status) @@ -1135,8 +1130,7 @@ class TestStandbyExtension(base.IronicAgentTest): calls = [mock.call('ntpdate', '192.168.1.1'), mock.call('hwclock', '-v', '--systohc'), mock.call('sync'), - mock.call('poweroff', use_standard_locale=True, - check_exit_code=[0])] + mock.call('poweroff', use_standard_locale=True)] execute_mock.assert_has_calls(calls) self.assertEqual('SUCCEEDED', success_result.command_status) diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index 22f8a1880..646cf01b8 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -725,8 +725,7 @@ class TestGenericHardwareManager(base.IronicAgentTest): mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE, '') self.assertEqual('/dev/sdb', self.hardware.get_os_install_device()) mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') mock_cached_node.assert_called_once_with() @mock.patch.object(os, 'readlink', autospec=True) @@ -747,8 +746,7 @@ class TestGenericHardwareManager(base.IronicAgentTest): # should always be smaller self.assertEqual('/dev/md0', self.hardware.get_os_install_device()) mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') mock_cached_node.assert_called_once_with() @mock.patch.object(os, 'readlink', autospec=True) @@ -766,8 +764,7 @@ class TestGenericHardwareManager(base.IronicAgentTest): ex = self.assertRaises(errors.DeviceNotFound, self.hardware.get_os_install_device) mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') self.assertIn(str(4 * units.Gi), ex.details) mock_cached_node.assert_called_once_with() @@ -4091,8 +4088,7 @@ class TestModuleFunctions(base.IronicAgentTest): mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE_SMALL, '') result = hardware.list_all_block_devices() mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') self.assertEqual(BLK_DEVICE_TEMPLATE_SMALL_DEVICES, result) mocked_udev.assert_called_once_with() @@ -4110,8 +4106,7 @@ class TestModuleFunctions(base.IronicAgentTest): mocked_execute.return_value = (hws.RAID_BLK_DEVICE_TEMPLATE, '') result = hardware.list_all_block_devices(ignore_empty=False) mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result) mocked_udev.assert_called_once_with() @@ -4123,8 +4118,7 @@ class TestModuleFunctions(base.IronicAgentTest): mocked_execute.return_value = ('TYPE="foo" MODEL="model"', '') result = hardware.list_all_block_devices() mocked_execute.assert_called_once_with( - 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID', - check_exit_code=[0]) + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') self.assertEqual([], result) mocked_udev.assert_called_once_with()