Revision df456124
b/snf-astakos-app/astakos/im/management/commands/service-add.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from optparse import make_option |
35 |
import string |
|
35 | 36 |
|
36 | 37 |
from django.core.management.base import BaseCommand, CommandError |
37 | 38 |
from django.db.utils import IntegrityError |
... | ... | |
47 | 48 |
make_option('--type', |
48 | 49 |
dest='type', |
49 | 50 |
help="Service type"), |
51 |
make_option('-f', '--no-confirm', |
|
52 |
action='store_true', |
|
53 |
default=False, |
|
54 |
dest='force', |
|
55 |
help="Do not ask for confirmation"), |
|
50 | 56 |
) |
51 | 57 |
|
52 | 58 |
def handle(self, *args, **options): |
... | ... | |
57 | 63 |
url = args[1] |
58 | 64 |
api_url = args[2] |
59 | 65 |
kwargs = dict(name=name, url=url, api_url=api_url) |
60 |
if options['type']: |
|
61 |
kwargs['type'] = options['type'] |
|
66 |
s_type = options['type'] |
|
67 |
if s_type: |
|
68 |
kwargs['type'] = s_type |
|
62 | 69 |
|
63 | 70 |
try: |
64 | 71 |
s = Service.objects.get(name=name) |
... | ... | |
77 | 84 |
m = "API URL '%s' is registered for another service." % api_url |
78 | 85 |
raise CommandError(m) |
79 | 86 |
|
87 |
force = options['force'] |
|
88 |
if not force: |
|
89 |
tp = (' of type %s' % s_type) if s_type else '' |
|
90 |
self.stdout.write("Add service %s%s with:\n" % (name, tp)) |
|
91 |
self.stdout.write("service URL: %s\n" % url) |
|
92 |
self.stdout.write("API URL: %s\n" % api_url) |
|
93 |
self.stdout.write("Confirm? (y/n) ") |
|
94 |
response = raw_input() |
|
95 |
if string.lower(response) not in ['y', 'yes']: |
|
96 |
self.stdout.write("Aborted.\n") |
|
97 |
return |
|
98 |
|
|
80 | 99 |
try: |
81 | 100 |
s = Service.objects.create(**kwargs) |
82 | 101 |
except BaseException: |
b/snf-astakos-app/astakos/im/management/commands/user-modify.py | ||
---|---|---|
135 | 135 |
"The special value 'default' sets the user base " |
136 | 136 |
"quota to the default value.") |
137 | 137 |
), |
138 |
|
|
138 |
make_option('-f', '--no-confirm', |
|
139 |
action='store_true', |
|
140 |
default=False, |
|
141 |
dest='force', |
|
142 |
help="Do not ask for confirmation"), |
|
139 | 143 |
) |
140 | 144 |
|
141 | 145 |
@commit_on_success_strict() |
... | ... | |
286 | 290 |
if password: |
287 | 291 |
self.stdout.write('User\'s new password: %s\n' % password) |
288 | 292 |
|
293 |
force = options['force'] |
|
294 |
|
|
289 | 295 |
set_base_quota = options.get('set_base_quota') |
290 | 296 |
if set_base_quota is not None: |
291 | 297 |
resource, capacity = set_base_quota |
292 |
self.set_limit(user, resource, capacity, False)
|
|
298 |
self.set_limit(user, resource, capacity, force)
|
|
293 | 299 |
|
294 | 300 |
def set_limit(self, user, resource, capacity, force): |
295 | 301 |
style = None |
Also available in: Unified diff