예제 #1
0
def resolve_action_definition(action_spec_name, wf_name=None,
                              wf_spec_name=None):
    action_db = None

    if wf_name and wf_name != wf_spec_name:
        # If workflow belongs to a workbook then check
        # action 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 an action in DB.
        wb_name = wf_name.rstrip(wf_spec_name)[:-1]

        action_full_name = "%s.%s" % (wb_name, action_spec_name)

        action_db = db_api.load_action_definition(action_full_name)

    if not action_db:
        action_db = db_api.load_action_definition(action_spec_name)

    if not action_db:
        raise exc.InvalidActionException(
            "Failed to find action [action_name=%s]" % action_spec_name
        )

    return action_db
예제 #2
0
def resolve_action_definition(action_spec_name, wf_name=None,
                              wf_spec_name=None):
    """Resolve action definition accounting for ad-hoc action namespacing.

    :param action_spec_name: Action name according to a spec.
    :param wf_name: Workflow name.
    :param wf_spec_name: Workflow name according to a spec.
    :return: Action definition (python or ad-hoc).
    """
    action_db = None

    if wf_name and wf_name != wf_spec_name:
        # If workflow belongs to a workbook then check
        # action 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 an action in DB.
        wb_name = wf_name.rstrip(wf_spec_name)[:-1]

        action_full_name = "%s.%s" % (wb_name, action_spec_name)

        action_db = db_api.load_action_definition(action_full_name)

    if not action_db:
        action_db = db_api.load_action_definition(action_spec_name)

    if not action_db:
        raise exc.InvalidActionException(
            "Failed to find action [action_name=%s]" % action_spec_name
        )

    return action_db
예제 #3
0
def resolve_action_definition(action_spec_name, wf_name=None,
                              wf_spec_name=None):
    action_db = None

    if wf_name and wf_name != wf_spec_name:
        # If workflow belongs to a workbook then check
        # action 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 an action in DB.
        wb_name = wf_name.rstrip(wf_spec_name)[:-1]

        action_full_name = "%s.%s" % (wb_name, action_spec_name)

        action_db = db_api.load_action_definition(action_full_name)

    if not action_db:
        action_db = db_api.load_action_definition(action_spec_name)

    if not action_db:
        raise exc.InvalidActionException(
            "Failed to find action [action_name=%s]" % action_spec_name
        )

    return action_db
예제 #4
0
def resolve_action_definition(action_spec_name,
                              wf_name=None,
                              wf_spec_name=None):
    """Resolve action definition accounting for ad-hoc action namespacing.

    :param action_spec_name: Action name according to a spec.
    :param wf_name: Workflow name.
    :param wf_spec_name: Workflow name according to a spec.
    :return: Action definition (python or ad-hoc).
    """

    action_db = None

    if wf_name and wf_name != wf_spec_name:
        # If workflow belongs to a workbook then check
        # action 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 an action in DB.
        wb_name = wf_name.rstrip(wf_spec_name)[:-1]

        action_full_name = "%s.%s" % (wb_name, action_spec_name)

        action_db = db_api.load_action_definition(action_full_name)

    if not action_db:
        action_db = db_api.load_action_definition(action_spec_name)

    if not action_db:
        raise exc.InvalidActionException(
            "Failed to find action [action_name=%s]" % action_spec_name)

    return action_db
예제 #5
0
    def test_delete(self):
        # Create an adhoc action for the purpose of the test.
        adhoc_actions.create_actions(ADHOC_ACTION_YAML)

        self.assertIsNotNone(db_api.load_action_definition('my_action'))

        resp = self.app.delete('/v2/actions/my_action')

        self.assertEqual(204, resp.status_int)

        self.assertIsNone(db_api.load_action_definition('my_action'))
예제 #6
0
    def __init__(self, action_def, action_ex=None, task_ex=None, task_ctx=None,
                 wf_ctx=None):
        self.action_spec = spec_parser.get_action_spec(action_def.spec)

        base_action_def = db_api.load_action_definition(
            self.action_spec.get_base(),
            namespace=action_def.namespace
        )

        if not base_action_def:
            raise exc.InvalidActionException(
                "Failed to find action [action_name=%s]" %
                self.action_spec.get_base()
            )

        base_action_def = self._gather_base_actions(
            action_def,
            base_action_def
        )

        super(AdHocAction, self).__init__(
            base_action_def,
            action_ex,
            task_ex
        )

        self.adhoc_action_def = action_def
        self.namespace = action_def.namespace
        self.task_ctx = task_ctx or {}
        self.wf_ctx = wf_ctx or {}
예제 #7
0
    def find(self, action_name, namespace=None):
        action_def = db_api.load_action_definition(action_name,
                                                   namespace=namespace)

        if action_def is None:
            return None

        return AdHocActionDescriptor(action_def)
예제 #8
0
def create_or_update_action(action_spec, definition, scope):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" % action.name)

    values = _get_action_values(action_spec, definition, scope)

    return db_api.create_or_update_action_definition(values['name'], values)
예제 #9
0
def update_action(action_spec, definition, scope, identifier=None):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" % action.name)

    values = _get_action_values(action_spec, definition, scope)

    return db_api.update_action_definition(
        identifier if identifier else values['name'], values)
예제 #10
0
def create_or_update_action(action_spec, definition, scope):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" %
            action.name
        )

    values = _get_action_values(action_spec, definition, scope)

    return db_api.create_or_update_action_definition(values['name'], values)
예제 #11
0
def update_action(action_spec, definition, scope, identifier=None):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" %
            action.name
        )

    values = _get_action_values(action_spec, definition, scope)

    return db_api.update_action_definition(
        identifier if identifier else values['name'],
        values
    )
예제 #12
0
def find_action_definition_by_name(action_name):
    """Find action definition name.

    :param action_name: Action name.
    :return: Action definition (possibly a cached value).
    """
    with _ACTION_DEF_CACHE_LOCK:
        action_definition = _ACTION_DEF_CACHE.get(action_name)

    if action_definition:
        return action_definition

    action_definition = db_api.load_action_definition(action_name)

    with _ACTION_DEF_CACHE_LOCK:
        _ACTION_DEF_CACHE[action_name] = action_definition

    return action_definition
예제 #13
0
def _find_action_definition_by_name(action_name):
    """Find action definition name.

    :param action_name: Action name.
    :return: Action definition (possibly a cached value).
    """
    with _ACTION_DEF_CACHE_LOCK:
        action_def = _ACTION_DEF_CACHE.get(action_name)

    if action_def:
        return action_def

    action_def = db_api.load_action_definition(action_name)

    with _ACTION_DEF_CACHE_LOCK:
        _ACTION_DEF_CACHE[action_name] = (action_def.get_clone()
                                          if action_def else None)

    return action_def
예제 #14
0
def _find_action_definition_by_name(action_name):
    """Find action definition name.

    :param action_name: Action name.
    :return: Action definition (possibly a cached value).
    """
    with _ACTION_DEF_CACHE_LOCK:
        action_def = _ACTION_DEF_CACHE.get(action_name)

    if action_def:
        return action_def

    action_def = db_api.load_action_definition(action_name)

    with _ACTION_DEF_CACHE_LOCK:
        _ACTION_DEF_CACHE[action_name] = (
            action_def.get_clone() if action_def else None
        )

    return action_def
예제 #15
0
def get_action_db(action_name):
    return db_api.load_action_definition(action_name)
예제 #16
0
def get_action_db(action_name):
    return db_api.load_action_definition(action_name)
예제 #17
0
def get_action_db(action_name, namespace=''):
    return db_api.load_action_definition(action_name, namespace=namespace)