Remove default parameter from execute
The param check_exit_code from the processutils extension execute has default already at [0] See: https://opendev.org/openstack/oslo.concurrency/src/branch/master/oslo_concurrency/processutils.py#L214 Change-Id: Iedff5325e0737556d5eb3da601c984ddfc633873
This commit is contained in:
parent
4354d4f792
commit
bff252c726
ironic_python_agent
@ -206,7 +206,7 @@ def _write_whole_disk_image(image, image_info, device):
|
|||||||
command = ['/bin/bash', script, image, device]
|
command = ['/bin/bash', script, image, device]
|
||||||
LOG.info('Writing image with command: {}'.format(' '.join(command)))
|
LOG.info('Writing image with command: {}'.format(' '.join(command)))
|
||||||
try:
|
try:
|
||||||
stdout, stderr = utils.execute(*command, check_exit_code=[0])
|
stdout, stderr = utils.execute(*command)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
raise errors.ImageWriteError(device, e.exit_code, e.stdout, e.stderr)
|
raise errors.ImageWriteError(device, e.exit_code, e.stdout, e.stderr)
|
||||||
|
|
||||||
@ -745,8 +745,7 @@ class StandbyExtension(base.BaseAgentExtension):
|
|||||||
except errors.CommandExecutionError as e:
|
except errors.CommandExecutionError as e:
|
||||||
LOG.warning('Failed to sync file system buffers: % s', e)
|
LOG.warning('Failed to sync file system buffers: % s', e)
|
||||||
try:
|
try:
|
||||||
_, stderr = utils.execute(command, use_standard_locale=True,
|
_, stderr = utils.execute(command, use_standard_locale=True)
|
||||||
check_exit_code=[0])
|
|
||||||
if 'ignoring request.' in stderr:
|
if 'ignoring request.' in stderr:
|
||||||
LOG.debug('%s command failed with error %s, '
|
LOG.debug('%s command failed with error %s, '
|
||||||
'falling back to sysrq-trigger.', command, stderr)
|
'falling back to sysrq-trigger.', command, stderr)
|
||||||
|
@ -411,8 +411,8 @@ def list_all_block_devices(block_type='disk',
|
|||||||
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
||||||
|
|
||||||
columns = utils.LSBLK_COLUMNS
|
columns = utils.LSBLK_COLUMNS
|
||||||
report = utils.execute('lsblk', '-Pbia', '-o{}'.format(','.join(columns)),
|
report = utils.execute('lsblk', '-Pbia',
|
||||||
check_exit_code=[0])[0]
|
'-o{}'.format(','.join(columns)))[0]
|
||||||
lines = report.splitlines()
|
lines = report.splitlines()
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
execute_mock.return_value = ('', '')
|
execute_mock.return_value = ('', '')
|
||||||
|
|
||||||
standby._write_image(image_info, device)
|
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.assert_called_once_with(device, node_uuid=None)
|
||||||
|
|
||||||
fix_gpt_mock.side_effect = exception.InstanceDeployFailure
|
fix_gpt_mock.side_effect = exception.InstanceDeployFailure
|
||||||
@ -193,7 +193,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
image_info,
|
image_info,
|
||||||
device)
|
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(utils, 'get_node_boot_mode', lambda self: 'bios')
|
||||||
@mock.patch.object(hardware, 'dispatch_to_managers', autospec=True)
|
@mock.patch.object(hardware, 'dispatch_to_managers', autospec=True)
|
||||||
@ -1044,8 +1044,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
|
|
||||||
self.agent_extension._run_shutdown_command('poweroff')
|
self.agent_extension._run_shutdown_command('poweroff')
|
||||||
calls = [mock.call('sync'),
|
calls = [mock.call('sync'),
|
||||||
mock.call('poweroff', use_standard_locale=True,
|
mock.call('poweroff', use_standard_locale=True)]
|
||||||
check_exit_code=[0])]
|
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
|
|
||||||
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
||||||
@ -1057,8 +1056,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
self.agent_extension._run_shutdown_command('poweroff')
|
self.agent_extension._run_shutdown_command('poweroff')
|
||||||
calls = [mock.call('hwclock', '-v', '--systohc'),
|
calls = [mock.call('hwclock', '-v', '--systohc'),
|
||||||
mock.call('sync'),
|
mock.call('sync'),
|
||||||
mock.call('poweroff', use_standard_locale=True,
|
mock.call('poweroff', use_standard_locale=True),
|
||||||
check_exit_code=[0]),
|
|
||||||
mock.call("echo o > /proc/sysrq-trigger", shell=True)]
|
mock.call("echo o > /proc/sysrq-trigger", shell=True)]
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
|
|
||||||
@ -1070,8 +1068,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
|
|
||||||
self.agent_extension._run_shutdown_command('reboot')
|
self.agent_extension._run_shutdown_command('reboot')
|
||||||
calls = [mock.call('sync'),
|
calls = [mock.call('sync'),
|
||||||
mock.call('reboot', use_standard_locale=True,
|
mock.call('reboot', use_standard_locale=True),
|
||||||
check_exit_code=[0]),
|
|
||||||
mock.call("echo b > /proc/sysrq-trigger", shell=True)]
|
mock.call("echo b > /proc/sysrq-trigger", shell=True)]
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
|
|
||||||
@ -1082,8 +1079,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
success_result = self.agent_extension.run_image()
|
success_result = self.agent_extension.run_image()
|
||||||
success_result.join()
|
success_result.join()
|
||||||
calls = [mock.call('sync'),
|
calls = [mock.call('sync'),
|
||||||
mock.call('reboot', use_standard_locale=True,
|
mock.call('reboot', use_standard_locale=True)]
|
||||||
check_exit_code=[0])]
|
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
self.assertEqual('SUCCEEDED', success_result.command_status)
|
self.assertEqual('SUCCEEDED', success_result.command_status)
|
||||||
|
|
||||||
@ -1105,8 +1101,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
success_result.join()
|
success_result.join()
|
||||||
|
|
||||||
calls = [mock.call('sync'),
|
calls = [mock.call('sync'),
|
||||||
mock.call('poweroff', use_standard_locale=True,
|
mock.call('poweroff', use_standard_locale=True)]
|
||||||
check_exit_code=[0])]
|
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
self.assertEqual('SUCCEEDED', success_result.command_status)
|
self.assertEqual('SUCCEEDED', success_result.command_status)
|
||||||
|
|
||||||
@ -1135,8 +1130,7 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
calls = [mock.call('ntpdate', '192.168.1.1'),
|
calls = [mock.call('ntpdate', '192.168.1.1'),
|
||||||
mock.call('hwclock', '-v', '--systohc'),
|
mock.call('hwclock', '-v', '--systohc'),
|
||||||
mock.call('sync'),
|
mock.call('sync'),
|
||||||
mock.call('poweroff', use_standard_locale=True,
|
mock.call('poweroff', use_standard_locale=True)]
|
||||||
check_exit_code=[0])]
|
|
||||||
execute_mock.assert_has_calls(calls)
|
execute_mock.assert_has_calls(calls)
|
||||||
self.assertEqual('SUCCEEDED', success_result.command_status)
|
self.assertEqual('SUCCEEDED', success_result.command_status)
|
||||||
|
|
||||||
|
@ -725,8 +725,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE, '')
|
mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE, '')
|
||||||
self.assertEqual('/dev/sdb', self.hardware.get_os_install_device())
|
self.assertEqual('/dev/sdb', self.hardware.get_os_install_device())
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@ -747,8 +746,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
# should always be smaller
|
# should always be smaller
|
||||||
self.assertEqual('/dev/md0', self.hardware.get_os_install_device())
|
self.assertEqual('/dev/md0', self.hardware.get_os_install_device())
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@ -766,8 +764,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
ex = self.assertRaises(errors.DeviceNotFound,
|
ex = self.assertRaises(errors.DeviceNotFound,
|
||||||
self.hardware.get_os_install_device)
|
self.hardware.get_os_install_device)
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
self.assertIn(str(4 * units.Gi), ex.details)
|
self.assertIn(str(4 * units.Gi), ex.details)
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
|
|
||||||
@ -4091,8 +4088,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE_SMALL, '')
|
mocked_execute.return_value = (hws.BLK_DEVICE_TEMPLATE_SMALL, '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices()
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
self.assertEqual(BLK_DEVICE_TEMPLATE_SMALL_DEVICES, result)
|
self.assertEqual(BLK_DEVICE_TEMPLATE_SMALL_DEVICES, result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
|
|
||||||
@ -4110,8 +4106,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (hws.RAID_BLK_DEVICE_TEMPLATE, '')
|
mocked_execute.return_value = (hws.RAID_BLK_DEVICE_TEMPLATE, '')
|
||||||
result = hardware.list_all_block_devices(ignore_empty=False)
|
result = hardware.list_all_block_devices(ignore_empty=False)
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result)
|
self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
|
|
||||||
@ -4123,8 +4118,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = ('TYPE="foo" MODEL="model"', '')
|
mocked_execute.return_value = ('TYPE="foo" MODEL="model"', '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices()
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID')
|
||||||
check_exit_code=[0])
|
|
||||||
self.assertEqual([], result)
|
self.assertEqual([], result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user