Resolve circular import, introduce ExecuteCommandMixin

Adding new methods to utils won't work as the circular import appears
between errors.py and utils.py.

Introduce ExecuteCommandMixin and use it for IronicPythonAgent and
FlowExtension (in future patch).

Also add tests for its.

Change-Id: Id95b31349292a7967d2ee66ec82c1662d8e5de94
This commit is contained in:
Alexander Gordeev
2014-04-09 18:06:57 +04:00
parent 88f06e2831
commit 5bc793bcb0
5 changed files with 158 additions and 76 deletions

@ -38,14 +38,3 @@ def execute(*cmd, **kwargs):
LOG.debug(gtu._('Command stdout is: "%s"') % result[0])
LOG.debug(gtu._('Command stderr is: "%s"') % result[1])
return result
def split_command(command_name):
command_parts = command_name.split('.', 1)
if len(command_parts) != 2:
#NOTE(agordeev): fix to avoid import looping
from ironic_python_agent import errors
raise errors.InvalidCommandError(
'Command name must be of the form <extension>.<name>')
return (command_parts[0], command_parts[1])