Commit 14fd7a77 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Disable setting user base quota

Remove functionality from management commands `quota' and `user-modify'
for setting base quota. They will now be handled through projects.
parent ae2ad61f
...@@ -43,12 +43,9 @@ from django.contrib.auth.models import Group ...@@ -43,12 +43,9 @@ from django.contrib.auth.models import Group
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import validate_email from django.core.validators import validate_email
from synnefo.util import units from import AstakosUser
from import AstakosUser, Resource
from import quotas
from import activation_backends from import activation_backends
from ._common import (remove_user_permission, add_user_permission, is_uuid, from ._common import (remove_user_permission, add_user_permission, is_uuid)
activation_backend = activation_backends.get_backend() activation_backend = activation_backends.get_backend()
...@@ -143,14 +140,6 @@ class Command(BaseCommand): ...@@ -143,14 +140,6 @@ class Command(BaseCommand):
default=False, default=False,
action='store_true', action='store_true',
help="Sign terms"), help="Sign terms"),
metavar='<resource> <capacity>',
help=("Set base quota for a specified resource. "
"The special value 'default' sets the user base "
"quota to the default value.")
make_option('-f', '--no-confirm', make_option('-f', '--no-confirm',
action='store_true', action='store_true',
default=False, default=False,
...@@ -328,16 +317,6 @@ class Command(BaseCommand): ...@@ -328,16 +317,6 @@ class Command(BaseCommand):
if password: if password:
self.stdout.write('User\'s new password: %s\n' % password) self.stdout.write('User\'s new password: %s\n' % password)
force = options['force']
set_base_quota = options.get('set_base_quota')
if set_base_quota is not None:
if not user.is_accepted():
m = "%s is not an accepted user." % user
raise CommandError(m)
resource, capacity = set_base_quota
self.set_limits([user], resource, capacity, force)
delete = options.get('delete') delete = options.get('delete')
if delete: if delete:
if user.is_accepted(): if user.is_accepted():
...@@ -378,66 +357,5 @@ class Command(BaseCommand): ...@@ -378,66 +357,5 @@ class Command(BaseCommand):
self.stderr.write("Aborted.\n") self.stderr.write("Aborted.\n")
exit() exit()
def handle_limits_user(self, user, res, capacity, style):
default_capacity = res.uplimit
resource =
quota = user.get_resource_policy(resource)
s_default = show_resource_value(default_capacity, resource, style)
s_current = show_resource_value(quota.capacity, resource, style)
s_capacity = (show_resource_value(capacity, resource, style)
if capacity != 'default' else capacity)
self.stdout.write("user: %s (%s)\n" % (user.uuid, user.username))
self.stdout.write("default capacity: %s\n" % s_default)
self.stdout.write("current capacity: %s\n" % s_current)
self.stdout.write("new capacity: %s\n" % s_capacity)
def handle_limits_all(self, res, capacity, exclude, style):
m = "This will set base quota for all users"
app = (" except %s" % ", ".join(exclude)) if exclude else ""
resource =
self.stdout.write("resource: %s\n" % resource)
s_capacity = (show_resource_value(capacity, resource, style)
if capacity != 'default' else capacity)
self.stdout.write("capacity: %s\n" % s_capacity)
def set_limits(self, users, resource, capacity, force=False, exclude=None):
r = Resource.objects.get(name=resource)
except Resource.DoesNotExist:
raise CommandError("No such resource '%s'." % resource)
style = None
if capacity != "default":
capacity, style = units.parse_with_style(capacity)
m = ("Please specify capacity as a decimal integer or "
raise CommandError(m)
if not force:
if len(users) == 1:
self.handle_limits_user(users[0], r, capacity, style)
self.handle_limits_all(r, capacity, exclude, style)
if capacity == "default":
capacity = r.uplimit
quotas.update_base_quota(users, resource, capacity)
def handle_all_users(self, *args, **options): def handle_all_users(self, *args, **options):
force = options["force"] pass
exclude = options["exclude"]
if exclude is not None:
exclude = exclude.split(',')
set_base_quota = options.get('set_base_quota')
if set_base_quota is not None:
users = AstakosUser.objects.accepted().select_for_update()
if exclude:
users = users.exclude(uuid__in=exclude)
resource, capacity = set_base_quota
self.set_limits(users, resource, capacity, force, exclude)
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
# or implied, of GRNET S.A. # or implied, of GRNET S.A.
from import ( from import (
Resource, AstakosUserQuota, AstakosUser, Service, Resource, AstakosUser, Service,
Project, ProjectMembership, ProjectResourceQuota) Project, ProjectMembership, ProjectResourceQuota)
import astakos.quotaholder_app.callpoint as qh import astakos.quotaholder_app.callpoint as qh
from astakos.quotaholder_app.exception import NoCapacityError from astakos.quotaholder_app.exception import NoCapacityError
...@@ -230,14 +230,6 @@ def get_pending_app_quota(user): ...@@ -230,14 +230,6 @@ def get_pending_app_quota(user):
return quota[source][PENDING_APP_RESOURCE] return quota[source][PENDING_APP_RESOURCE]
def update_base_quota(users, resource, value):
userids = [ for user in users]
filter(resource__name=resource, user__pk__in=userids).\
qh_sync_locked_users(users, resource=resource)
def _partition_by(f, l): def _partition_by(f, l):
d = {} d = {}
for x in l: for x in l:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment