Merge "Add sync() command to the standby module"
This commit is contained in:
commit
4f1caf11e9
ironic_python_agent
releasenotes/notes
@ -374,3 +374,17 @@ class StandbyExtension(base.BaseAgentExtension):
|
||||
def power_off(self):
|
||||
LOG.info('Powering off system')
|
||||
self._run_shutdown_script('-h')
|
||||
|
||||
@base.sync_command('sync')
|
||||
def sync(self):
|
||||
"""Flush file system buffers forcing changed blocks to disk.
|
||||
|
||||
:raises: CommandExecutionError if flushing file system buffers fails.
|
||||
"""
|
||||
LOG.debug('Flushing file system buffers')
|
||||
try:
|
||||
utils.execute('sync')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
error_msg = 'Flushing file system buffers failed. Error: %s' % e
|
||||
LOG.error(error_msg)
|
||||
raise errors.CommandExecutionError(error_msg)
|
||||
|
@ -760,6 +760,19 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
execute_mock.assert_called_once_with(*command, check_exit_code=[0])
|
||||
self.assertEqual('FAILED', failed_result.command_status)
|
||||
|
||||
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
||||
def test_sync(self, execute_mock):
|
||||
result = self.agent_extension.sync()
|
||||
execute_mock.assert_called_once_with('sync')
|
||||
self.assertEqual('SUCCEEDED', result.command_status)
|
||||
|
||||
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
||||
def test_sync_error(self, execute_mock):
|
||||
execute_mock.side_effect = processutils.ProcessExecutionError
|
||||
self.assertRaises(
|
||||
errors.CommandExecutionError, self.agent_extension.sync)
|
||||
execute_mock.assert_called_once_with('sync')
|
||||
|
||||
@mock.patch('ironic_python_agent.extensions.standby._write_image',
|
||||
autospec=True)
|
||||
@mock.patch('ironic_python_agent.extensions.standby._download_image',
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Add a new sync() command to the standby extension. When invoked,
|
||||
the new command is responsible for flushing the file system buffers
|
||||
to the disk.
|
Loading…
x
Reference in New Issue
Block a user