Esempio n. 1
0
def run_task(wf_cmd):
    """Runs workflow task.

    :param wf_cmd: Workflow command.
    """

    task = _build_task_from_command(wf_cmd)

    try:
        task.run()
    except exc.MistralException as e:
        wf_ex = wf_cmd.wf_ex
        task_spec = wf_cmd.task_spec

        msg = (
            "Failed to run task [wf=%s, task=%s]: %s\n%s" %
            (wf_ex, task_spec.get_name(), e, tb.format_exc())
        )

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task.task_ex)
Esempio n. 2
0
def run_task(wf_cmd):
    """Runs workflow task.

    :param wf_cmd: Workflow command.
    """

    task = _build_task_from_command(wf_cmd)

    try:
        task.run()
    except exc.MistralException as e:
        wf_ex = wf_cmd.wf_ex
        task_spec = wf_cmd.task_spec

        msg = ("Failed to run task [wf=%s, task=%s]: %s\n%s" %
               (wf_ex, task_spec.get_name(), e, tb.format_exc()))

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task.task_ex)
Esempio n. 3
0
def complete_task(task_ex, state, state_info):
    task = _build_task_from_execution(
        spec_parser.get_workflow_spec_by_id(task_ex.workflow_id),
        task_ex
    )

    try:
        task.complete(state, state_info)
    except exc.MistralException as e:
        wf_ex = task_ex.workflow_execution

        msg = (
            "Failed to complete task [wf=%s, task=%s]: %s\n%s" %
            (wf_ex, task_ex.name, e, tb.format_exc())
        )

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 4
0
def complete_task(task_ex, state, state_info):
    task = _build_task_from_execution(task_ex)

    # TODO(rakhmerov): Error handling.
    task.complete(state, state_info)

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 5
0
def continue_task(task_ex):
    task = _build_task_from_execution(task_ex)

    # TODO(rakhmerov): Error handling.
    task.run()

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 6
0
def complete_task(task_ex, state, state_info):
    task = _build_task_from_execution(task_ex)

    # TODO(rakhmerov): Error handling.
    task.complete(state, state_info)

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 7
0
def continue_task(task_ex):
    task = _build_task_from_execution(task_ex)

    # TODO(rakhmerov): Error handling.
    task.run()

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 8
0
def on_action_complete(action_ex):
    """Handles action completion event.

    :param action_ex: Action execution.
    """

    task_ex = action_ex.task_execution

    if not task_ex:
        return

    task_spec = spec_parser.get_task_spec(task_ex.spec)

    wf_ex = task_ex.workflow_execution

    task = _create_task(
        wf_ex,
        task_spec,
        task_ex.in_context,
        task_ex
    )

    try:
        task.on_action_complete(action_ex)
    except exc.MistralException as e:
        task_ex = action_ex.task_execution
        wf_ex = task_ex.workflow_execution

        msg = ("Failed to handle action completion [wf=%s, task=%s,"
               " action=%s]: %s\n%s" %
               (wf_ex.name, task_ex.name, action_ex.name, e, tb.format_exc()))

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 9
0
def on_action_complete(action_ex):
    """Handles action completion event.

    :param action_ex: Action execution.
    """

    task_ex = action_ex.task_execution

    if not task_ex:
        return

    task_spec = spec_parser.get_task_spec(task_ex.spec)

    wf_ex = task_ex.workflow_execution

    task = _create_task(
        wf_ex,
        spec_parser.get_workflow_spec_by_id(wf_ex.workflow_id),
        task_spec,
        task_ex.in_context,
        task_ex
    )

    try:
        task.on_action_complete(action_ex)
    except exc.MistralException as e:
        wf_ex = task_ex.workflow_execution

        msg = ("Failed to handle action completion [wf=%s, task=%s,"
               " action=%s]: %s\n%s" %
               (wf_ex.name, task_ex.name, action_ex.name, e, tb.format_exc()))

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 10
0
def continue_task(task_ex):
    task = _build_task_from_execution(task_ex)

    try:
        task.run()
    except exc.MistralException as e:
        wf_ex = task_ex.workflow_execution

        msg = ("Failed to run task [wf=%s, task=%s]: %s\n%s" %
               (wf_ex, task_ex.name, e, tb.format_exc()))

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)
Esempio n. 11
0
def continue_task(task_ex):
    task = _build_task_from_execution(task_ex)

    try:
        task.run()
    except exc.MistralException as e:
        wf_ex = task_ex.workflow_execution

        msg = (
            "Failed to run task [wf=%s, task=%s]: %s\n%s" %
            (wf_ex, task_ex.name, e, tb.format_exc())
        )

        LOG.error(msg)

        task.set_state(states.ERROR, msg)

        wf_handler.fail_workflow(wf_ex, msg)

        return

    if task.is_completed():
        wf_handler.on_task_complete(task_ex)