Merge "Fixing engine facade hierarchy"

This commit is contained in:
Jenkins 2016-05-11 10:08:33 +00:00 committed by Gerrit Code Review
commit fa9f46b542
3 changed files with 60 additions and 22 deletions

View File

@ -69,28 +69,41 @@ class Engine(object):
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def pause_workflow(self, execution_id): def pause_workflow(self, wf_ex_id):
"""Pauses workflow execution. """Pauses workflow.
:param execution_id: Execution id. :param wf_ex_id: Execution id.
:return: Workflow execution object. :return: Workflow execution object.
""" """
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def resume_workflow(self, execution_id): def resume_workflow(self, wf_ex_id):
"""Resumes workflow execution. """Resumes workflow.
:param execution_id: Execution id. :param wf_ex_id: Execution id.
:return: Workflow execution object. :return: Workflow execution object.
""" """
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def stop_workflow(self, execution_id, state, message): def rerun_workflow(self, wf_ex_id, task_ex_id, reset=True, env=None):
"""Stops workflow execution. """Rerun workflow from the specified task.
:param execution_id: Workflow execution id. :param wf_ex_id: Workflow execution id.
:param task_ex_id: Task execution id.
:param reset: If True, reset task state including deleting its action
executions.
:param env: Workflow environment.
:return: Workflow execution object.
"""
raise NotImplementedError
@abc.abstractmethod
def stop_workflow(self, wf_ex_id, state, message):
"""Stops workflow.
:param wf_ex_id: Workflow execution id.
:param state: State assigned to the workflow. Permitted states are :param state: State assigned to the workflow. Permitted states are
SUCCESS or ERROR. SUCCESS or ERROR.
:param message: Optional information string. :param message: Optional information string.
@ -100,10 +113,10 @@ class Engine(object):
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def rollback_workflow(self, execution_id): def rollback_workflow(self, wf_ex_id):
"""Rolls back workflow execution. """Rolls back workflow execution.
:param execution_id: Execution id. :param wf_ex_id: Execution id.
:return: Workflow execution object. :return: Workflow execution object.
""" """
raise NotImplementedError raise NotImplementedError

View File

@ -275,9 +275,9 @@ class DefaultEngine(base.Engine, coordination.Service):
raise e raise e
@u.log_exec(LOG) @u.log_exec(LOG)
def pause_workflow(self, execution_id): def pause_workflow(self, wf_ex_id):
with db_api.transaction(): with db_api.transaction():
wf_ex = wf_handler.lock_workflow_execution(execution_id) wf_ex = wf_handler.lock_workflow_execution(wf_ex_id)
wf_handler.set_execution_state(wf_ex, states.PAUSED) wf_handler.set_execution_state(wf_ex, states.PAUSED)

View File

@ -140,6 +140,10 @@ class EngineServer(object):
"""Receives calls over RPC to start workflows on engine. """Receives calls over RPC to start workflows on engine.
:param rpc_ctx: RPC request context. :param rpc_ctx: RPC request context.
:param workflow_identifier: Workflow definition identifier.
:param workflow_input: Workflow input.
:param description: Workflow execution description.
:param params: Additional workflow type specific parameters.
:return: Workflow execution. :return: Workflow execution.
""" """
@ -398,6 +402,8 @@ class EngineClient(base.Engine):
it possibly needs to move the workflow on, i.e. run other workflow it possibly needs to move the workflow on, i.e. run other workflow
tasks for which all dependencies are satisfied. tasks for which all dependencies are satisfied.
:param action_ex_id: Action execution id.
:param result: Action execution result.
:return: Task. :return: Task.
""" """
@ -410,16 +416,17 @@ class EngineClient(base.Engine):
) )
@wrap_messaging_exception @wrap_messaging_exception
def pause_workflow(self, execution_id): def pause_workflow(self, wf_ex_id):
"""Stops the workflow with the given execution id. """Stops the workflow with the given execution id.
:param wf_ex_id: Workflow execution id.
:return: Workflow execution. :return: Workflow execution.
""" """
return self._client.call( return self._client.call(
auth_ctx.ctx(), auth_ctx.ctx(),
'pause_workflow', 'pause_workflow',
execution_id=execution_id execution_id=wf_ex_id
) )
@wrap_messaging_exception @wrap_messaging_exception
@ -431,7 +438,8 @@ class EngineClient(base.Engine):
:param wf_ex_id: Workflow execution id. :param wf_ex_id: Workflow execution id.
:param task_ex_id: Task execution id. :param task_ex_id: Task execution id.
:param reset: If true, then purge action execution for the task. :param reset: If true, then reset task execution state and purge
action execution for the task.
:param env: Environment variables to update. :param env: Environment variables to update.
:return: Workflow execution. :return: Workflow execution.
""" """
@ -462,13 +470,13 @@ class EngineClient(base.Engine):
) )
@wrap_messaging_exception @wrap_messaging_exception
def stop_workflow(self, execution_id, state, message=None): def stop_workflow(self, wf_ex_id, state, message=None):
"""Stops workflow execution with given status. """Stops workflow execution with given status.
Once stopped, the workflow is complete with SUCCESS or ERROR, Once stopped, the workflow is complete with SUCCESS or ERROR,
and can not be resumed. and can not be resumed.
:param execution_id: Workflow execution id :param wf_ex_id: Workflow execution id
:param state: State assigned to the workflow: SUCCESS or ERROR :param state: State assigned to the workflow: SUCCESS or ERROR
:param message: Optional information string :param message: Optional information string
@ -478,22 +486,24 @@ class EngineClient(base.Engine):
return self._client.call( return self._client.call(
auth_ctx.ctx(), auth_ctx.ctx(),
'stop_workflow', 'stop_workflow',
execution_id=execution_id, execution_id=wf_ex_id,
state=state, state=state,
message=message message=message
) )
@wrap_messaging_exception @wrap_messaging_exception
def rollback_workflow(self, execution_id): def rollback_workflow(self, wf_ex_id):
"""Rolls back the workflow with the given execution id. """Rolls back the workflow with the given execution id.
:param wf_ex_id: Workflow execution id.
:return: Workflow execution. :return: Workflow execution.
""" """
return self._client.call( return self._client.call(
auth_ctx.ctx(), auth_ctx.ctx(),
'rollback_workflow', 'rollback_workflow',
execution_id=execution_id execution_id=wf_ex_id
) )
@ -508,6 +518,11 @@ class ExecutorServer(object):
"""Receives calls over RPC to run action on executor. """Receives calls over RPC to run action on executor.
:param rpc_ctx: RPC request context dictionary. :param rpc_ctx: RPC request context dictionary.
:param action_ex_id: Action execution id.
:param action_class_str: Action class name.
:param attributes: Action class attributes.
:param params: Action input parameters.
:return: Action result.
""" """
LOG.info( LOG.info(
@ -546,7 +561,17 @@ class ExecutorClient(base.Executor):
def run_action(self, action_ex_id, action_class_str, attributes, def run_action(self, action_ex_id, action_class_str, attributes,
action_params, target=None, async=True): action_params, target=None, async=True):
"""Sends a request to run action to executor.""" """Sends a request to run action to executor.
:param action_ex_id: Action execution id.
:param action_class_str: Action class name.
:param attributes: Action class attributes.
:param action_params: Action input parameters.
:param target: Target (group of action executors).
:param async: If True, run action in asynchronous mode (w/o waiting
for completion).
:return: Action result.
"""
kwargs = { kwargs = {
'action_ex_id': action_ex_id, 'action_ex_id': action_ex_id,