Merge "Move split_command to utils"
This commit is contained in:
@@ -158,18 +158,10 @@ class IronicPythonAgent(object):
|
|||||||
raise errors.RequestedObjectNotFoundError('Command Result',
|
raise errors.RequestedObjectNotFoundError('Command Result',
|
||||||
result_id)
|
result_id)
|
||||||
|
|
||||||
def _split_command(self, command_name):
|
|
||||||
command_parts = command_name.split('.', 1)
|
|
||||||
if len(command_parts) != 2:
|
|
||||||
raise errors.InvalidCommandError(
|
|
||||||
'Command name must be of the form <extension>.<name>')
|
|
||||||
|
|
||||||
return (command_parts[0], command_parts[1])
|
|
||||||
|
|
||||||
def execute_command(self, command_name, **kwargs):
|
def execute_command(self, command_name, **kwargs):
|
||||||
"""Execute an agent command."""
|
"""Execute an agent command."""
|
||||||
with self.command_lock:
|
with self.command_lock:
|
||||||
extension_part, command_part = self._split_command(command_name)
|
extension_part, command_part = utils.split_command(command_name)
|
||||||
|
|
||||||
if len(self.command_results) > 0:
|
if len(self.command_results) > 0:
|
||||||
last_command = list(self.command_results.values())[-1]
|
last_command = list(self.command_results.values())[-1]
|
||||||
|
@@ -40,3 +40,14 @@ def execute(*cmd, **kwargs):
|
|||||||
LOG.debug(gtu._('Command stdout is: "%s"') % result[0])
|
LOG.debug(gtu._('Command stdout is: "%s"') % result[0])
|
||||||
LOG.debug(gtu._('Command stderr is: "%s"') % result[1])
|
LOG.debug(gtu._('Command stderr is: "%s"') % result[1])
|
||||||
return result
|
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])
|
||||||
|
Reference in New Issue
Block a user