Revision 2e46be99

b/snf-astakos-app/astakos/im/management/commands/service-import.py
113 113
                if exists:
114 114
                    m = "Resource '%s' updated in database.\n" % (r.name)
115 115
                else:
116
                    m = ("Resource '%s' created in database with default "
117
                         "quota limit 0.\n" % (r.name))
116
                    m = ("Resource '%s' created in database with unlimited "
117
                         "quota.\n" % (r.name))
118 118
                output.append(m)
119 119

  
120 120
        for line in output:
b/snf-astakos-app/astakos/im/quotas.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
import copy
35
from synnefo.util import units
35 36
from astakos.im.models import (
36 37
    Resource, AstakosUserQuota, AstakosUser, Service,
37 38
    Project, ProjectMembership, ProjectResourceGrant, ProjectApplication)
......
202 203
    return SYSTEM
203 204

  
204 205

  
206
def add_limits(x, y):
207
    return min(x+y, units.PRACTICALLY_INFINITE)
208

  
209

  
205 210
def astakos_users_quotas(users):
206 211
    users = list(users)
207 212
    quotas = initial_quotas(users)
......
236 241

  
237 242
            resource = grant.resource.full_name()
238 243
            prev = source_quotas.get(resource, 0)
239
            new = prev + grant.member_capacity
244
            new = add_limits(prev, grant.member_capacity)
240 245
            source_quotas[resource] = new
241 246
            userquotas[source] = source_quotas
242 247
        quotas[uuid] = userquotas
......
319 324
    _set_user_quota(quota)
320 325

  
321 326

  
322
def qh_sync_new_resource(resource, limit):
327
def qh_sync_new_resource(resource):
323 328
    users = AstakosUser.objects.filter(
324 329
        moderated=True, is_rejected=False).order_by('id').select_for_update()
325 330

  
326 331
    resource_name = resource.name
332
    limit = resource.uplimit
327 333
    data = []
328 334
    for user in users:
329 335
        uuid = user.uuid
b/snf-astakos-app/astakos/im/register.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from synnefo.util import units
34 35
from astakos.im.models import Resource, Service, Endpoint, EndpointData
35 36
from astakos.im import quotas
36 37
import logging
......
82 83
        r.service_type = service_type
83 84
    except Resource.DoesNotExist:
84 85
        r = Resource(name=name,
85
                     uplimit=0,
86
                     uplimit=units.PRACTICALLY_INFINITE,
86 87
                     service_type=service_type,
87 88
                     service_origin=service_origin)
88 89
        exists = False
......
94 95

  
95 96
    r.save()
96 97
    if not exists:
97
        quotas.qh_sync_new_resource(r, 0)
98
        quotas.qh_sync_new_resource(r)
98 99

  
99 100
    if exists:
100 101
        logger.info("Updated resource %s." % (name))

Also available in: Unified diff