Example #1
0
def resolve_workflow_definition(parent_wf_name, parent_wf_spec_name,
                                wf_spec_name):
    wf_def = None

    if parent_wf_name != parent_wf_spec_name:
        # If parent workflow belongs to a workbook then
        # check child workflow within the same workbook
        # (to be able to use short names within workbooks).
        # If it doesn't exist then use a name from spec
        # to find a workflow in DB.
        wb_name = parent_wf_name.rstrip(parent_wf_spec_name)[:-1]

        wf_full_name = "%s.%s" % (wb_name, wf_spec_name)

        wf_def = db_api.load_workflow_definition(wf_full_name)

    if not wf_def:
        wf_def = db_api.load_workflow_definition(wf_spec_name)

    if not wf_def:
        raise exc.WorkflowException(
            "Failed to find workflow [name=%s]" % wf_spec_name
        )

    return wf_def
Example #2
0
def _update_workflow(wf_spec, definition, scope):
    workflow = db_api.load_workflow_definition(wf_spec.get_name())

    if workflow and workflow.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system workflow: %s" %
            workflow.name
        )
    values = _get_workflow_values(wf_spec, definition, scope)

    return db_api.update_workflow_definition(values['name'], values)