Ejemplo n.º 1
0
def node_before_update(mapper, connection, target):
    if not target.enabled:
        return
    allowed, current = quotas(connection, target)
    if allowed < current:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" % (
            current, allowed), model="Node")
Ejemplo n.º 2
0
def prof_before_update(mapper, connection, target):
    if not target.enabled:
        return
    total_allowed, current_total = quotas(connection, target)
    if total_allowed < current_total:
        raise QuotaExceeded(msg="Quota exceeded(%s of %s used)" % (
            current_total, total_allowed), model="Cloud profile")
Ejemplo n.º 3
0
def depl_before_update(mapper, connection, target):
    if not target.enabled:
        return
    total_allowed, current_total = quotas(connection, target)
    if total_allowed < current_total:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" %
                            (current_total, total_allowed),
                            model="Deployment")
Ejemplo n.º 4
0
def group_before_insert(mapper, connection, target):
    allowed = target.org.tier.groups
    current = connection.scalar(
        select([func.count(distinct(Group.id))
                ]).where(Group.org_id == target.org.id))
    if allowed <= current:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" %
                            (current, allowed),
                            model="Group")
Ejemplo n.º 5
0
def user_before_update(mapper, connection, target):
    allowed = target.org.tier.users
    current = connection.scalar(
        select([func.count(distinct(User.id))]).where(
            User.org_id == target.org.id).where(User.enabled == True))  # noqa
    if allowed < current:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" %
                            (current, allowed),
                            model="User")
Ejemplo n.º 6
0
def depl_before_insert(mapper, connection, target):
    total_allowed, current_total = quotas(connection, target)
    if total_allowed <= current_total:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" %
                            (current_total, total_allowed),
                            model="Deployment")
Ejemplo n.º 7
0
def apikey_before_update(mapper, connection, target):
    allowed, current = quotas(connection, target)
    if allowed < current:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" %
                            (current, allowed),
                            model="User")
Ejemplo n.º 8
0
def node_before_insert(mapper, connection, target):
    allowed, current = quotas(connection, target)
    if allowed <= current:
        raise QuotaExceeded(msg="Quota exceeded(%d of %d used)" % (
            current, allowed), model="Node")