Esempio n. 1
0
def update_resource_member(resource_id,
                           res_type,
                           member_id,
                           values,
                           session=None):
    # Only member who is not the owner of the resource can update the
    # membership status.
    if member_id != security.get_project_id():
        raise exc.NotFoundException(
            "Resource member not found [resource_id=%s, member_id=%s]" %
            (resource_id, member_id))

    query = _secure_query(
        models.ResourceMember).filter_by(resource_type=res_type)

    res_member = query.filter(
        _get_criterion(resource_id, member_id, is_owner=False)).first()

    if not res_member:
        raise exc.NotFoundException(
            "Resource member not found [resource_id=%s, member_id=%s]" %
            (resource_id, member_id))

    res_member.update(values.copy())

    return res_member
Esempio n. 2
0
def delete_environment(name, session=None):
    env = _get_environment(name)

    if not env:
        raise exc.NotFoundException("Environment not found [name=%s]" % name)

    session.delete(env)
Esempio n. 3
0
def delete_delayed_call(id, session=None):
    delayed_call = _get_delayed_call(id)

    if not delayed_call:
        raise exc.NotFoundException("DelayedCall not found [id=%s]" % id)

    session.delete(delayed_call)
Esempio n. 4
0
def get_environment(name):
    env = _get_environment(name)

    if not env:
        raise exc.NotFoundException("Environment not found [name=%s]" % name)

    return env
Esempio n. 5
0
def update_cron_trigger(name, values, session=None, query_filter=None):
    cron_trigger = _get_cron_trigger(name)

    if not cron_trigger:
        raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)

    if query_filter:
        try:
            # Execute the UPDATE statement with the query_filter as the WHERE.
            specimen = models.CronTrigger(id=cron_trigger.id, **query_filter)
            cron_trigger = b.model_query(models.CronTrigger).update_on_match(
                specimen=specimen, surrogate_key='id', values=values)

            return cron_trigger, 1

        except oslo_sqlalchemy.update_match.NoRowsMatched:
            LOG.debug(
                "No rows matched for cron update call"
                "[id=%s, values=%s, query_filter=%s", id, values, query_filter)

            return cron_trigger, 0

    else:
        cron_trigger.update(values.copy())

        return cron_trigger, len(session.dirty)
Esempio n. 6
0
def delete_cron_trigger(name, session=None):
    cron_trigger = _get_cron_trigger(name)

    if not cron_trigger:
        raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)

    session.delete(cron_trigger)
Esempio n. 7
0
def get_delayed_call(id, session=None):
    delayed_call = _get_delayed_call(id=id, session=session)

    if not delayed_call:
        raise exc.NotFoundException("Delayed Call not found [id=%s]" % id)

    return delayed_call
Esempio n. 8
0
def delete_action_execution(id, session=None):
    a_ex = _get_action_execution(id)

    if not a_ex:
        raise exc.NotFoundException("ActionExecution not found [id=%s]" % id)

    session.delete(a_ex)
Esempio n. 9
0
def get_cron_trigger(name):
    cron_trigger = _get_cron_trigger(name)

    if not cron_trigger:
        raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)

    return cron_trigger
Esempio n. 10
0
def get_action_execution(id):
    a_ex = _get_action_execution(id)

    if not a_ex:
        raise exc.NotFoundException("ActionExecution not found [id=%s]" % id)

    return a_ex
Esempio n. 11
0
def delete_workflow_execution(id, session=None):
    wf_ex = _get_workflow_execution(id)

    if not wf_ex:
        raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)

    session.delete(wf_ex)
Esempio n. 12
0
def get_task_execution(id):
    task_ex = _get_task_execution(id)

    if not task_ex:
        raise exc.NotFoundException("Task execution not found [id=%s]" % id)

    return task_ex
Esempio n. 13
0
def get_action_definition_by_id(id):
    action_def = _get_db_object_by_id(models.ActionDefinition, id)

    if not action_def:
        raise exc.NotFoundException("Action not found [action_id=%s]" % id)

    return action_def
Esempio n. 14
0
def delete_task_execution(id, session=None):
    task_ex = _get_task_execution(id)

    if not task_ex:
        raise exc.NotFoundException("TaskExecution not found [id=%s]" % id)

    session.delete(task_ex)
Esempio n. 15
0
def get_workflow_definition_by_id(id):
    wf_def = _get_workflow_definition_by_id(id)

    if not wf_def:
        raise exc.NotFoundException("Workflow not found [workflow_id=%s]" % id)

    return wf_def
Esempio n. 16
0
def get_workflow_execution(id):
    wf_ex = _get_workflow_execution(id)

    if not wf_ex:
        raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)

    return wf_ex
Esempio n. 17
0
def delete_workbook(name, session=None):
    wb = _get_workbook(name)

    if not wb:
        raise exc.NotFoundException("Workbook not found [workbook_name=%s]" %
                                    name)

    session.delete(wb)
Esempio n. 18
0
def delete_execution(id, session=None):
    ex = _get_execution(id)

    if not ex:
        raise exc.NotFoundException("Execution not found [execution_id=%s]" %
                                    id)

    session.delete(ex)
Esempio n. 19
0
def delete_action_definition(name, session=None):
    a_def = _get_action_definition(name)

    if not a_def:
        raise exc.NotFoundException(
            "Action definition not found [action_name=%s]" % name)

    session.delete(a_def)
Esempio n. 20
0
def get_action_definition(name):
    a_def = _get_action_definition(name)

    if not a_def:
        raise exc.NotFoundException(
            "Action definition not found [action_name=%s]" % name)

    return a_def
Esempio n. 21
0
def get_workbook(name):
    wb = _get_workbook(name)

    if not wb:
        raise exc.NotFoundException("Workbook not found [workbook_name=%s]" %
                                    name)

    return wb
Esempio n. 22
0
def get_execution(id):
    ex = _get_execution(id)

    if not ex:
        raise exc.NotFoundException("Execution not found [execution_id=%s]" %
                                    id)

    return ex
Esempio n. 23
0
def get_workflow_definition(name):
    wf_def = _get_workflow_definition(name)

    if not wf_def:
        raise exc.NotFoundException(
            "Workflow not found [workflow_name=%s]" % name
        )

    return wf_def
Esempio n. 24
0
def update_environment(name, values, session=None):
    env = _get_environment(name)

    if not env:
        raise exc.NotFoundException("Environment not found [name=%s]" % name)

    env.update(values)

    return env
Esempio n. 25
0
def update_cron_trigger(name, values, session=None):
    cron_trigger = _get_cron_trigger(name)

    if not cron_trigger:
        raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)

    cron_trigger.update(values.copy())

    return cron_trigger
Esempio n. 26
0
def delete_workflow_definition(name, session=None):
    wf_def = _get_workflow_definition(name)

    if not wf_def:
        raise exc.NotFoundException(
            "Workflow not found [workflow_name=%s]" % name
        )

    session.delete(wf_def)
Esempio n. 27
0
def update_task_execution(id, values, session=None):
    task_ex = _get_task_execution(id)

    if not task_ex:
        raise exc.NotFoundException("TaskExecution not found [id=%s]" % id)

    task_ex.update(values.copy())

    return task_ex
Esempio n. 28
0
def update_action_execution(id, values, session=None):
    a_ex = _get_action_execution(id)

    if not a_ex:
        raise exc.NotFoundException("ActionExecution not found [id=%s]" % id)

    a_ex.update(values.copy())

    return a_ex
Esempio n. 29
0
def update_workflow_execution(id, values, session=None):
    wf_ex = _get_workflow_execution(id)

    if not wf_ex:
        raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)

    wf_ex.update(values.copy())

    return wf_ex
Esempio n. 30
0
def update_execution(id, values, session=None):
    ex = _get_execution(id)

    if not ex:
        raise exc.NotFoundException("Execution not found [execution_id=%s]" %
                                    id)

    ex.update(values.copy())

    return ex