Commit 053bcb0d authored by Giorgos Korfiatis's avatar Giorgos Korfiatis Committed by Christos Stavrakakis
Browse files

astakos: Make limits possibly infinite

Register new resources with unlimited quota.
parent a119610a
......@@ -113,8 +113,8 @@ class Command(BaseCommand):
if exists:
m = "Resource '%s' updated in database.\n" % (r.name)
else:
m = ("Resource '%s' created in database with default "
"quota limit 0.\n" % (r.name))
m = ("Resource '%s' created in database with unlimited "
"quota.\n" % (r.name))
output.append(m)
for line in output:
......
......@@ -32,6 +32,7 @@
# or implied, of GRNET S.A.
import copy
from synnefo.util import units
from astakos.im.models import (
Resource, AstakosUserQuota, AstakosUser, Service,
Project, ProjectMembership, ProjectResourceGrant, ProjectApplication)
......@@ -202,6 +203,10 @@ def get_grant_source(grant):
return SYSTEM
def add_limits(x, y):
return min(x+y, units.PRACTICALLY_INFINITE)
def astakos_users_quotas(users):
users = list(users)
quotas = initial_quotas(users)
......@@ -236,7 +241,7 @@ def astakos_users_quotas(users):
resource = grant.resource.full_name()
prev = source_quotas.get(resource, 0)
new = prev + grant.member_capacity
new = add_limits(prev, grant.member_capacity)
source_quotas[resource] = new
userquotas[source] = source_quotas
quotas[uuid] = userquotas
......@@ -319,11 +324,12 @@ def qh_change_resource_limit(resource):
_set_user_quota(quota)
def qh_sync_new_resource(resource, limit):
def qh_sync_new_resource(resource):
users = AstakosUser.objects.filter(
moderated=True, is_rejected=False).order_by('id').select_for_update()
resource_name = resource.name
limit = resource.uplimit
data = []
for user in users:
uuid = user.uuid
......
......@@ -31,6 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from synnefo.util import units
from astakos.im.models import Resource, Service, Endpoint, EndpointData
from astakos.im import quotas
import logging
......@@ -82,7 +83,7 @@ def add_resource(resource_dict):
r.service_type = service_type
except Resource.DoesNotExist:
r = Resource(name=name,
uplimit=0,
uplimit=units.PRACTICALLY_INFINITE,
service_type=service_type,
service_origin=service_origin)
exists = False
......@@ -94,7 +95,7 @@ def add_resource(resource_dict):
r.save()
if not exists:
quotas.qh_sync_new_resource(r, 0)
quotas.qh_sync_new_resource(r)
if exists:
logger.info("Updated resource %s." % (name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment