summaryrefslogtreecommitdiff
path: root/ironic_python_agent
diff options
context:
space:
mode:
Diffstat (limited to 'ironic_python_agent')
-rw-r--r--ironic_python_agent/errors.py9
-rw-r--r--ironic_python_agent/extensions/base.py2
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_base.py11
3 files changed, 21 insertions, 1 deletions
diff --git a/ironic_python_agent/errors.py b/ironic_python_agent/errors.py
index bf0253dd..0f7a185c 100644
--- a/ironic_python_agent/errors.py
+++ b/ironic_python_agent/errors.py
@@ -91,6 +91,15 @@ class RequestedObjectNotFoundError(NotFound):
super(RequestedObjectNotFoundError, self).__init__(details)
+class AgentIsBusy(CommandExecutionError):
+
+ message = 'Agent is busy'
+ status_code = 409
+
+ def __init__(self, command_name):
+ super().__init__('executing command %s' % command_name)
+
+
class IronicAPIError(RESTError):
"""Error raised when a call to the agent API fails."""
diff --git a/ironic_python_agent/extensions/base.py b/ironic_python_agent/extensions/base.py
index 98554511..93adfe93 100644
--- a/ironic_python_agent/extensions/base.py
+++ b/ironic_python_agent/extensions/base.py
@@ -250,7 +250,7 @@ class ExecuteCommandMixin(object):
LOG.error('Tried to execute %(command)s, agent is still '
'executing %(last)s', {'command': command_name,
'last': last_command})
- raise errors.CommandExecutionError('agent is busy')
+ raise errors.AgentIsBusy(last_command.command_name)
try:
ext = self.get_extension(extension_part)
diff --git a/ironic_python_agent/tests/unit/extensions/test_base.py b/ironic_python_agent/tests/unit/extensions/test_base.py
index 2881d2ab..f609e580 100644
--- a/ironic_python_agent/tests/unit/extensions/test_base.py
+++ b/ironic_python_agent/tests/unit/extensions/test_base.py
@@ -117,6 +117,17 @@ class TestExecuteCommandMixin(test_base.IronicAgentTest):
result.command_status)
self.assertEqual(exc, result.command_error)
+ def test_busy(self):
+ fake_extension = FakeExtension()
+ self.agent.ext_mgr = extension.ExtensionManager.make_test_instance(
+ [extension.Extension('fake', None, FakeExtension, fake_extension)])
+
+ self.agent.command_results = {
+ 'fake': base.BaseCommandResult('name', {})
+ }
+ self.assertRaises(errors.AgentIsBusy,
+ self.agent.execute_command, 'fake.fake_sync_command')
+
class TestExtensionDecorators(test_base.IronicAgentTest):
def setUp(self):