Commit 94c8abbf authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Add confirmation step in service-add

Since there is no way to delete a registered service, confirmation
is needed to register a service.

Add also a `--no-confirm' option to bypass this check in service-add
as well as in user-modify.
parent 2a6501c6
......@@ -32,6 +32,7 @@
# or implied, of GRNET S.A.
from optparse import make_option
import string
from import BaseCommand, CommandError
from django.db.utils import IntegrityError
......@@ -47,6 +48,11 @@ class Command(BaseCommand):
help="Service type"),
make_option('-f', '--no-confirm',
help="Do not ask for confirmation"),
def handle(self, *args, **options):
......@@ -57,8 +63,9 @@ class Command(BaseCommand):
url = args[1]
api_url = args[2]
kwargs = dict(name=name, url=url, api_url=api_url)
if options['type']:
kwargs['type'] = options['type']
s_type = options['type']
if s_type:
kwargs['type'] = s_type
s = Service.objects.get(name=name)
......@@ -77,6 +84,18 @@ class Command(BaseCommand):
m = "API URL '%s' is registered for another service." % api_url
raise CommandError(m)
force = options['force']
if not force:
tp = (' of type %s' % s_type) if s_type else ''
self.stdout.write("Add service %s%s with:\n" % (name, tp))
self.stdout.write("service URL: %s\n" % url)
self.stdout.write("API URL: %s\n" % api_url)
self.stdout.write("Confirm? (y/n) ")
response = raw_input()
if string.lower(response) not in ['y', 'yes']:
s = Service.objects.create(**kwargs)
except BaseException:
......@@ -135,7 +135,11 @@ class Command(BaseCommand):
"The special value 'default' sets the user base "
"quota to the default value.")
make_option('-f', '--no-confirm',
help="Do not ask for confirmation"),
......@@ -286,10 +290,12 @@ class Command(BaseCommand):
if 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:
resource, capacity = set_base_quota
self.set_limit(user, resource, capacity, False)
self.set_limit(user, resource, capacity, force)
def set_limit(self, user, resource, capacity, force):
style = None
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