Revision 252eef38
b/docs/admin-guide.rst | ||
---|---|---|
1003 | 1003 |
cleanup-full Cleanup sessions and session catalog |
1004 | 1004 |
commission-list List pending commissions |
1005 | 1005 |
commission-show Show details for a pending commission |
1006 |
component-add Register a component |
|
1007 |
component-list List components |
|
1008 |
component-modify Modify component attributes |
|
1006 | 1009 |
project-control Manage projects and applications |
1007 | 1010 |
project-list List projects |
1008 | 1011 |
project-show Show project details |
... | ... | |
1015 | 1018 |
resource-modify Modify a resource's default base quota and boolean flags |
1016 | 1019 |
service-add Register a service |
1017 | 1020 |
service-list List services |
1018 |
service-modify Modify service attributes |
|
1019 | 1021 |
service-show Show service details |
1020 | 1022 |
term-add Add approval terms |
1021 | 1023 |
user-activation-send Send user activation |
b/snf-astakos-app/astakos/im/management/commands/component-add.py | ||
---|---|---|
1 |
# Copyright 2013 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
from django.core.management.base import BaseCommand, CommandError |
|
35 |
from astakos.im.models import Component |
|
36 |
|
|
37 |
|
|
38 |
class Command(BaseCommand): |
|
39 |
args = "<name> <component URL>" |
|
40 |
help = "Register a component" |
|
41 |
|
|
42 |
def handle(self, *args, **options): |
|
43 |
if len(args) < 1: |
|
44 |
raise CommandError("Invalid number of arguments") |
|
45 |
|
|
46 |
name = args[0] |
|
47 |
url = args[1] |
|
48 |
try: |
|
49 |
s = Component.objects.get(name=name) |
|
50 |
m = "There already exists a component named '%s'." % name |
|
51 |
raise CommandError(m) |
|
52 |
except Component.DoesNotExist: |
|
53 |
pass |
|
54 |
|
|
55 |
components = list(Component.objects.filter(url=url)) |
|
56 |
if components: |
|
57 |
m = "Component URL '%s' is registered for another service." % url |
|
58 |
raise CommandError(m) |
|
59 |
|
|
60 |
try: |
|
61 |
c = Component.objects.create(name=name, url=url) |
|
62 |
except BaseException: |
|
63 |
raise CommandError("Failed to register component.") |
|
64 |
else: |
|
65 |
self.stdout.write('Token: %s\n' % c.auth_token) |
b/snf-astakos-app/astakos/im/management/commands/component-list.py | ||
---|---|---|
1 |
# Copyright 2012, 2013 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
from astakos.im.models import Component |
|
35 |
from synnefo.webproject.management.commands import ListCommand |
|
36 |
|
|
37 |
|
|
38 |
class Command(ListCommand): |
|
39 |
help = "List components" |
|
40 |
object_class = Component |
|
41 |
|
|
42 |
FIELDS = { |
|
43 |
"id": ("id", "Component ID"), |
|
44 |
"name": ("name", "Component Name"), |
|
45 |
"url": ("url", "Component URL"), |
|
46 |
"token": ("auth_token", "Authentication token"), |
|
47 |
"token created": ("auth_token_created", "Token creation date"), |
|
48 |
} |
|
49 |
|
|
50 |
fields = ["id", "name", "url", "token"] |
b/snf-astakos-app/astakos/im/management/commands/component-modify.py | ||
---|---|---|
1 |
# Copyright 2012 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
from optparse import make_option |
|
35 |
|
|
36 |
from django.core.management.base import BaseCommand, CommandError |
|
37 |
|
|
38 |
from astakos.im.models import Component |
|
39 |
|
|
40 |
|
|
41 |
class Command(BaseCommand): |
|
42 |
args = "<component ID or name>" |
|
43 |
help = "Modify component attributes" |
|
44 |
|
|
45 |
option_list = BaseCommand.option_list + ( |
|
46 |
make_option('--url', |
|
47 |
dest='url', |
|
48 |
default=None, |
|
49 |
help="Set component url"), |
|
50 |
make_option('--auth-token', |
|
51 |
dest='auth_token', |
|
52 |
default=None, |
|
53 |
help="Set a custom component auth token"), |
|
54 |
make_option('--renew-token', |
|
55 |
action='store_true', |
|
56 |
dest='renew_token', |
|
57 |
default=False, |
|
58 |
help="Renew component auth token"), |
|
59 |
) |
|
60 |
|
|
61 |
def handle(self, *args, **options): |
|
62 |
if len(args) != 1: |
|
63 |
raise CommandError("Please provide a component ID or name") |
|
64 |
|
|
65 |
ident = args[0] |
|
66 |
try: |
|
67 |
try: |
|
68 |
ident = int(ident) |
|
69 |
component = Component.objects.get(id=ident) |
|
70 |
except ValueError: |
|
71 |
component = Component.objects.get(name=ident) |
|
72 |
except Component.DoesNotExist: |
|
73 |
raise CommandError( |
|
74 |
"Component does not exist. You may run snf-manage " |
|
75 |
"component-list for available component IDs.") |
|
76 |
|
|
77 |
url = options.get('url') |
|
78 |
auth_token = options.get('auth_token') |
|
79 |
renew_token = options.get('renew_token') |
|
80 |
|
|
81 |
if url: |
|
82 |
component.url = url |
|
83 |
|
|
84 |
if auth_token: |
|
85 |
component.auth_token = auth_token |
|
86 |
|
|
87 |
if renew_token and not auth_token: |
|
88 |
component.renew_token() |
|
89 |
|
|
90 |
component.save() |
|
91 |
|
|
92 |
if renew_token: |
|
93 |
self.stdout.write( |
|
94 |
'Component\'s new token: %s\n' % component.auth_token |
|
95 |
) |
/dev/null | ||
---|---|---|
1 |
# Copyright 2012 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
from optparse import make_option |
|
35 |
|
|
36 |
from django.core.management.base import BaseCommand, CommandError |
|
37 |
|
|
38 |
from astakos.im.models import Service |
|
39 |
|
|
40 |
|
|
41 |
class Command(BaseCommand): |
|
42 |
args = "<service ID>" |
|
43 |
help = "Modify service attributes" |
|
44 |
|
|
45 |
option_list = BaseCommand.option_list + ( |
|
46 |
make_option('--url', |
|
47 |
dest='url', |
|
48 |
default=None, |
|
49 |
help="Set service url"), |
|
50 |
make_option('--api-url', |
|
51 |
dest='api_url', |
|
52 |
default=None, |
|
53 |
help="Set service API url"), |
|
54 |
make_option('--auth-token', |
|
55 |
dest='auth_token', |
|
56 |
default=None, |
|
57 |
help="Set a custom service auth token"), |
|
58 |
make_option('--renew-token', |
|
59 |
action='store_true', |
|
60 |
dest='renew_token', |
|
61 |
default=False, |
|
62 |
help="Renew service auth token"), |
|
63 |
make_option('--type', |
|
64 |
dest='type', |
|
65 |
default=None, |
|
66 |
help="Modify service type"), |
|
67 |
) |
|
68 |
|
|
69 |
def handle(self, *args, **options): |
|
70 |
if len(args) != 1: |
|
71 |
raise CommandError("Please provide a service ID") |
|
72 |
|
|
73 |
try: |
|
74 |
service = Service.objects.get(id=int(args[0])) |
|
75 |
except Service.DoesNotExist: |
|
76 |
raise CommandError( |
|
77 |
"Service does not exist. You may run snf-manage " |
|
78 |
"service-list for available service IDs.") |
|
79 |
|
|
80 |
api_url = options.get('api_url') |
|
81 |
url = options.get('url') |
|
82 |
auth_token = options.get('auth_token') |
|
83 |
renew_token = options.get('renew_token') |
|
84 |
type = options.get('type') |
|
85 |
|
|
86 |
if api_url: |
|
87 |
service.api_url = api_url |
|
88 |
|
|
89 |
if url: |
|
90 |
service.url = url |
|
91 |
|
|
92 |
if auth_token: |
|
93 |
service.auth_token = auth_token |
|
94 |
|
|
95 |
if renew_token and not auth_token: |
|
96 |
service.renew_token() |
|
97 |
|
|
98 |
if type: |
|
99 |
service.type = type |
|
100 |
|
|
101 |
service.save() |
|
102 |
|
|
103 |
if renew_token: |
|
104 |
self.stdout.write( |
|
105 |
'Service\'s new token: %s\n' % service.auth_token |
|
106 |
) |
Also available in: Unified diff