root / kamaki / cli / commands / astakos.py @ d07e6fc2
History | View | Annotate | Download (28.9 kB)
1 | e3f01d64 | Stavros Sachtouris | # Copyright 2011-2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 7493ccb6 | Stavros Sachtouris | #
|
3 | 7493ccb6 | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | 7493ccb6 | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | 7493ccb6 | Stavros Sachtouris | # conditions are met:
|
6 | 7493ccb6 | Stavros Sachtouris | #
|
7 | 7493ccb6 | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | 7493ccb6 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | 7493ccb6 | Stavros Sachtouris | # disclaimer.
|
10 | 7493ccb6 | Stavros Sachtouris | #
|
11 | 7493ccb6 | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | 7493ccb6 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | 7493ccb6 | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | 7493ccb6 | Stavros Sachtouris | # provided with the distribution.
|
15 | 7493ccb6 | Stavros Sachtouris | #
|
16 | 7493ccb6 | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 7493ccb6 | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 7493ccb6 | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 7493ccb6 | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 7493ccb6 | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 7493ccb6 | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 7493ccb6 | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 7493ccb6 | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 7493ccb6 | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 7493ccb6 | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 7493ccb6 | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 7493ccb6 | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 7493ccb6 | Stavros Sachtouris | #
|
29 | 7493ccb6 | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | 7493ccb6 | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | 7493ccb6 | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | 7493ccb6 | Stavros Sachtouris | # or implied, of GRNET S.A.command
|
33 | 7493ccb6 | Stavros Sachtouris | |
34 | ab863157 | Stavros Sachtouris | from json import load, loads |
35 | c308d73f | Stavros Sachtouris | from os.path import abspath |
36 | c308d73f | Stavros Sachtouris | |
37 | c2be5c96 | Stavros Sachtouris | from kamaki.cli import command |
38 | 5033585e | Stavros Sachtouris | from kamaki.clients.astakos import SynnefoAstakosClient |
39 | b4f69041 | Stavros Sachtouris | from kamaki.cli.commands import ( |
40 | 98c02f22 | Stavros Sachtouris | _command_init, errors, _optional_json, addLogSettings) |
41 | be99b6ad | Stavros Sachtouris | from kamaki.cli.command_tree import CommandTree |
42 | fa7d08b6 | Stavros Sachtouris | from kamaki.cli.errors import CLIBaseUrlError, CLISyntaxError, CLIError |
43 | ab863157 | Stavros Sachtouris | from kamaki.cli.argument import ( |
44 | ab863157 | Stavros Sachtouris | FlagArgument, ValueArgument, IntArgument, CommaSeparatedListArgument) |
45 | e8d3b957 | Stavros Sachtouris | from kamaki.cli.utils import format_size |
46 | 7493ccb6 | Stavros Sachtouris | |
47 | 25f9a991 | Stavros Sachtouris | # Mandatory
|
48 | 25f9a991 | Stavros Sachtouris | |
49 | e8d3b957 | Stavros Sachtouris | user_commands = CommandTree('user', 'Astakos/Identity API commands') |
50 | 25f9a991 | Stavros Sachtouris | quota_commands = CommandTree( |
51 | 25f9a991 | Stavros Sachtouris | 'quota', 'Astakos/Account API commands for quotas') |
52 | 25f9a991 | Stavros Sachtouris | resource_commands = CommandTree( |
53 | 25f9a991 | Stavros Sachtouris | 'resource', 'Astakos/Account API commands for resources') |
54 | e8d3b957 | Stavros Sachtouris | project_commands = CommandTree('project', 'Astakos project API commands') |
55 | 25f9a991 | Stavros Sachtouris | |
56 | 25f9a991 | Stavros Sachtouris | |
57 | 25f9a991 | Stavros Sachtouris | # Optional
|
58 | 25f9a991 | Stavros Sachtouris | |
59 | 25f9a991 | Stavros Sachtouris | endpoint_commands = CommandTree( |
60 | 25f9a991 | Stavros Sachtouris | 'endpoint', 'Astakos/Account API commands for endpoints') |
61 | 25f9a991 | Stavros Sachtouris | service_commands = CommandTree('service', 'Astakos API commands for services') |
62 | 25f9a991 | Stavros Sachtouris | commission_commands = CommandTree( |
63 | 25f9a991 | Stavros Sachtouris | 'commission', 'Astakos API commands for commissions') |
64 | 25f9a991 | Stavros Sachtouris | |
65 | 25f9a991 | Stavros Sachtouris | _commands = [ |
66 | 25f9a991 | Stavros Sachtouris | user_commands, quota_commands, resource_commands, project_commands, |
67 | 25f9a991 | Stavros Sachtouris | service_commands, commission_commands, endpoint_commands] |
68 | 234954d1 | Stavros Sachtouris | |
69 | 234954d1 | Stavros Sachtouris | |
70 | ab863157 | Stavros Sachtouris | def with_temp_token(foo): |
71 | ab863157 | Stavros Sachtouris | """ Set token to self.client.token, run foo, recover old token """
|
72 | ab863157 | Stavros Sachtouris | def wrap(self, *args, **kwargs): |
73 | ab863157 | Stavros Sachtouris | try:
|
74 | ab863157 | Stavros Sachtouris | token = kwargs.pop('token')
|
75 | ab863157 | Stavros Sachtouris | except KeyError: |
76 | ab863157 | Stavros Sachtouris | raise CLISyntaxError('A token is needed for %s' % foo) |
77 | ab863157 | Stavros Sachtouris | token_bu = self.client.token
|
78 | ab863157 | Stavros Sachtouris | try:
|
79 | fa7d08b6 | Stavros Sachtouris | self.client.token = token or token_bu |
80 | ab863157 | Stavros Sachtouris | return foo(self, *args, **kwargs) |
81 | ab863157 | Stavros Sachtouris | finally:
|
82 | ab863157 | Stavros Sachtouris | self.client.token = token_bu
|
83 | ab863157 | Stavros Sachtouris | return wrap
|
84 | ab863157 | Stavros Sachtouris | |
85 | ab863157 | Stavros Sachtouris | |
86 | e8d3b957 | Stavros Sachtouris | class _init_synnefo_astakosclient(_command_init): |
87 | 85115c12 | Stavros Sachtouris | |
88 | a03ade9e | Stavros Sachtouris | @errors.generic.all
|
89 | 4018326d | Stavros Sachtouris | @errors.user.load
|
90 | e8d3b957 | Stavros Sachtouris | @errors.user.astakosclient
|
91 | b4f69041 | Stavros Sachtouris | @addLogSettings
|
92 | 436bd910 | Stavros Sachtouris | def _run(self): |
93 | e8d3b957 | Stavros Sachtouris | if getattr(self, 'cloud', None): |
94 | b4f69041 | Stavros Sachtouris | base_url = self._custom_url('astakos') |
95 | b4f69041 | Stavros Sachtouris | if base_url:
|
96 | f5ff79d9 | Stavros Sachtouris | token = self._custom_token(
|
97 | ab863157 | Stavros Sachtouris | 'astakos') or self.config.get_cloud( |
98 | ab863157 | Stavros Sachtouris | self.cloud, 'token') |
99 | dc897a7e | Stavros Sachtouris | token = token.split()[0] if ' ' in token else token |
100 | e8d3b957 | Stavros Sachtouris | self.client = SynnefoAstakosClient(
|
101 | e8d3b957 | Stavros Sachtouris | auth_url=base_url, token=token) |
102 | b4f69041 | Stavros Sachtouris | return
|
103 | b4f69041 | Stavros Sachtouris | else:
|
104 | b4f69041 | Stavros Sachtouris | self.cloud = 'default' |
105 | e8d3b957 | Stavros Sachtouris | if getattr(self, 'auth_base', None): |
106 | 5033585e | Stavros Sachtouris | self.client = self.auth_base.get_client() |
107 | b4f69041 | Stavros Sachtouris | return
|
108 | b4f69041 | Stavros Sachtouris | raise CLIBaseUrlError(service='astakos') |
109 | 7493ccb6 | Stavros Sachtouris | |
110 | 436bd910 | Stavros Sachtouris | def main(self): |
111 | 5fdccdec | Stavros Sachtouris | self._run()
|
112 | 436bd910 | Stavros Sachtouris | |
113 | 234954d1 | Stavros Sachtouris | |
114 | e8d3b957 | Stavros Sachtouris | @command(user_commands)
|
115 | fa7d08b6 | Stavros Sachtouris | class user_authenticate(_init_synnefo_astakosclient, _optional_json): |
116 | fa7d08b6 | Stavros Sachtouris | """Authenticate a user and get all authentication information"""
|
117 | 7493ccb6 | Stavros Sachtouris | |
118 | a03ade9e | Stavros Sachtouris | @errors.generic.all
|
119 | 4018326d | Stavros Sachtouris | @errors.user.authenticate
|
120 | e8d3b957 | Stavros Sachtouris | @errors.user.astakosclient
|
121 | 5033585e | Stavros Sachtouris | @with_temp_token
|
122 | 5033585e | Stavros Sachtouris | def _run(self): |
123 | fa7d08b6 | Stavros Sachtouris | self._print(self.client.authenticate(), self.print_dict) |
124 | 3185cd6d | Stavros Sachtouris | |
125 | e8d3b957 | Stavros Sachtouris | def main(self, token=None): |
126 | 9a8861d1 | Stavros Sachtouris | super(self.__class__, self)._run() |
127 | 5033585e | Stavros Sachtouris | self._run(token=token)
|
128 | 9a8861d1 | Stavros Sachtouris | |
129 | 9a8861d1 | Stavros Sachtouris | |
130 | e8d3b957 | Stavros Sachtouris | @command(user_commands)
|
131 | 5033585e | Stavros Sachtouris | class user_uuid2name(_init_synnefo_astakosclient, _optional_json): |
132 | 5033585e | Stavros Sachtouris | """Get user name(s) from uuid(s)"""
|
133 | 9a8861d1 | Stavros Sachtouris | |
134 | 9a8861d1 | Stavros Sachtouris | @errors.generic.all
|
135 | e8d3b957 | Stavros Sachtouris | @errors.user.astakosclient
|
136 | e8d3b957 | Stavros Sachtouris | def _run(self, uuids): |
137 | e8d3b957 | Stavros Sachtouris | r = self.client.get_usernames(uuids)
|
138 | e8d3b957 | Stavros Sachtouris | self._print(r, self.print_dict) |
139 | e8d3b957 | Stavros Sachtouris | unresolved = set(uuids).difference(r)
|
140 | e8d3b957 | Stavros Sachtouris | if unresolved:
|
141 | e8d3b957 | Stavros Sachtouris | self.error('Unresolved uuids: %s' % ', '.join(unresolved)) |
142 | e8d3b957 | Stavros Sachtouris | |
143 | e8d3b957 | Stavros Sachtouris | def main(self, uuid, *more_uuids): |
144 | 9a8861d1 | Stavros Sachtouris | super(self.__class__, self)._run() |
145 | e8d3b957 | Stavros Sachtouris | self._run(uuids=((uuid, ) + more_uuids))
|
146 | b91111b9 | Stavros Sachtouris | |
147 | b91111b9 | Stavros Sachtouris | |
148 | e8d3b957 | Stavros Sachtouris | @command(user_commands)
|
149 | 5033585e | Stavros Sachtouris | class user_name2uuid(_init_synnefo_astakosclient, _optional_json): |
150 | 5033585e | Stavros Sachtouris | """Get user uuid(s) from name(s)"""
|
151 | b91111b9 | Stavros Sachtouris | |
152 | b91111b9 | Stavros Sachtouris | @errors.generic.all
|
153 | e8d3b957 | Stavros Sachtouris | @errors.user.astakosclient
|
154 | e8d3b957 | Stavros Sachtouris | def _run(self, usernames): |
155 | e8d3b957 | Stavros Sachtouris | r = self.client.get_uuids(usernames)
|
156 | e8d3b957 | Stavros Sachtouris | self._print(r, self.print_dict) |
157 | e8d3b957 | Stavros Sachtouris | unresolved = set(usernames).difference(r)
|
158 | e8d3b957 | Stavros Sachtouris | if unresolved:
|
159 | e8d3b957 | Stavros Sachtouris | self.error('Unresolved usernames: %s' % ', '.join(unresolved)) |
160 | e8d3b957 | Stavros Sachtouris | |
161 | e8d3b957 | Stavros Sachtouris | def main(self, username, *more_usernames): |
162 | b91111b9 | Stavros Sachtouris | super(self.__class__, self)._run() |
163 | e8d3b957 | Stavros Sachtouris | self._run(usernames=((username, ) + more_usernames))
|
164 | e8d3b957 | Stavros Sachtouris | |
165 | e8d3b957 | Stavros Sachtouris | |
166 | 6893e31c | Stavros Sachtouris | class _quota(_init_synnefo_astakosclient, _optional_json): |
167 | e8d3b957 | Stavros Sachtouris | |
168 | e8d3b957 | Stavros Sachtouris | _to_format = set(['cyclades.disk', 'pithos.diskspace', 'cyclades.ram']) |
169 | fe4940bc | Stavros Sachtouris | |
170 | e8d3b957 | Stavros Sachtouris | arguments = dict(
|
171 | e8d3b957 | Stavros Sachtouris | bytes=FlagArgument('Show data size in bytes', '--bytes') |
172 | e8d3b957 | Stavros Sachtouris | ) |
173 | fe4940bc | Stavros Sachtouris | |
174 | e8d3b957 | Stavros Sachtouris | def _print_quotas(self, quotas, *args, **kwargs): |
175 | e8d3b957 | Stavros Sachtouris | if not self['bytes']: |
176 | e8d3b957 | Stavros Sachtouris | for category in quotas.values(): |
177 | e8d3b957 | Stavros Sachtouris | for service in self._to_format.intersection(category): |
178 | e8d3b957 | Stavros Sachtouris | for attr, v in category[service].items(): |
179 | e8d3b957 | Stavros Sachtouris | category[service][attr] = format_size(v) |
180 | e8d3b957 | Stavros Sachtouris | self.print_dict(quotas, *args, **kwargs)
|
181 | fe4940bc | Stavros Sachtouris | |
182 | 6893e31c | Stavros Sachtouris | |
183 | 6893e31c | Stavros Sachtouris | @command(quota_commands)
|
184 | 6893e31c | Stavros Sachtouris | class quota_info(_quota): |
185 | 6893e31c | Stavros Sachtouris | """Get quota for a service (cyclades, pithos, astakos)"""
|
186 | 6893e31c | Stavros Sachtouris | |
187 | 6893e31c | Stavros Sachtouris | @errors.generic.all
|
188 | 6893e31c | Stavros Sachtouris | @errors.user.astakosclient
|
189 | 6893e31c | Stavros Sachtouris | def _run(self, service): |
190 | 6893e31c | Stavros Sachtouris | r = dict()
|
191 | 6893e31c | Stavros Sachtouris | for k, v in self.client.get_quotas()['system'].items(): |
192 | 6893e31c | Stavros Sachtouris | if (k.startswith(service)):
|
193 | 6893e31c | Stavros Sachtouris | r[k] = v |
194 | 6893e31c | Stavros Sachtouris | self._print({'%s*' % service: r}, self._print_quotas) |
195 | 6893e31c | Stavros Sachtouris | |
196 | 6893e31c | Stavros Sachtouris | def main(self, service): |
197 | 6893e31c | Stavros Sachtouris | super(self.__class__, self)._run() |
198 | 6893e31c | Stavros Sachtouris | self._run(service)
|
199 | 6893e31c | Stavros Sachtouris | |
200 | 6893e31c | Stavros Sachtouris | |
201 | 6893e31c | Stavros Sachtouris | @command(quota_commands)
|
202 | 6893e31c | Stavros Sachtouris | class quota_list(_quota): |
203 | 6893e31c | Stavros Sachtouris | """Get user quotas"""
|
204 | 6893e31c | Stavros Sachtouris | |
205 | fe4940bc | Stavros Sachtouris | @errors.generic.all
|
206 | e8d3b957 | Stavros Sachtouris | @errors.user.astakosclient
|
207 | e8d3b957 | Stavros Sachtouris | def _run(self): |
208 | e8d3b957 | Stavros Sachtouris | self._print(self.client.get_quotas(), self._print_quotas) |
209 | fe4940bc | Stavros Sachtouris | |
210 | e8d3b957 | Stavros Sachtouris | def main(self): |
211 | fe4940bc | Stavros Sachtouris | super(self.__class__, self)._run() |
212 | e8d3b957 | Stavros Sachtouris | self._run()
|
213 | c308d73f | Stavros Sachtouris | |
214 | c308d73f | Stavros Sachtouris | |
215 | fa7d08b6 | Stavros Sachtouris | # command user session
|
216 | fa7d08b6 | Stavros Sachtouris | |
217 | fa7d08b6 | Stavros Sachtouris | |
218 | fa7d08b6 | Stavros Sachtouris | @command(user_commands)
|
219 | 25f9a991 | Stavros Sachtouris | class user_info(_init_synnefo_astakosclient, _optional_json): |
220 | fa7d08b6 | Stavros Sachtouris | """Get info for (current) session user"""
|
221 | fa7d08b6 | Stavros Sachtouris | |
222 | fa7d08b6 | Stavros Sachtouris | arguments = dict(
|
223 | fa7d08b6 | Stavros Sachtouris | uuid=ValueArgument('Query user with uuid', '--uuid'), |
224 | fa7d08b6 | Stavros Sachtouris | name=ValueArgument('Query user with username/email', '--username') |
225 | fa7d08b6 | Stavros Sachtouris | ) |
226 | fa7d08b6 | Stavros Sachtouris | |
227 | fa7d08b6 | Stavros Sachtouris | @errors.generic.all
|
228 | fa7d08b6 | Stavros Sachtouris | @errors.user.astakosclient
|
229 | fa7d08b6 | Stavros Sachtouris | def _run(self): |
230 | fa7d08b6 | Stavros Sachtouris | if self['uuid'] and self['name']: |
231 | fa7d08b6 | Stavros Sachtouris | raise CLISyntaxError(
|
232 | fa7d08b6 | Stavros Sachtouris | 'Arguments uuid and username are mutually exclusive',
|
233 | fa7d08b6 | Stavros Sachtouris | details=['Use either uuid OR username OR none, not both'])
|
234 | fa7d08b6 | Stavros Sachtouris | uuid = self['uuid'] or (self._username2uuid(self['name']) if ( |
235 | fa7d08b6 | Stavros Sachtouris | self['name']) else None) |
236 | fa7d08b6 | Stavros Sachtouris | try:
|
237 | fa7d08b6 | Stavros Sachtouris | token = self.auth_base.get_token(uuid) if uuid else None |
238 | fa7d08b6 | Stavros Sachtouris | except KeyError: |
239 | fa7d08b6 | Stavros Sachtouris | msg = ('id %s' % self['uuid']) if ( |
240 | fa7d08b6 | Stavros Sachtouris | self['uuid']) else 'username %s' % self['name'] |
241 | fa7d08b6 | Stavros Sachtouris | raise CLIError(
|
242 | fa7d08b6 | Stavros Sachtouris | 'No user with %s in the cached session list' % msg, details=[
|
243 | fa7d08b6 | Stavros Sachtouris | 'To see all cached session users',
|
244 | 25f9a991 | Stavros Sachtouris | ' /user list',
|
245 | fa7d08b6 | Stavros Sachtouris | 'To authenticate and add a new user in the session list',
|
246 | 25f9a991 | Stavros Sachtouris | ' /user add <new token>'])
|
247 | fa7d08b6 | Stavros Sachtouris | self._print(self.auth_base.user_info(token), self.print_dict) |
248 | fa7d08b6 | Stavros Sachtouris | |
249 | fa7d08b6 | Stavros Sachtouris | |
250 | fa7d08b6 | Stavros Sachtouris | @command(user_commands)
|
251 | 25f9a991 | Stavros Sachtouris | class user_add(_init_synnefo_astakosclient, _optional_json): |
252 | 25f9a991 | Stavros Sachtouris | """Authenticate a user by token and add to kamaki session (cache)"""
|
253 | fa7d08b6 | Stavros Sachtouris | |
254 | fa7d08b6 | Stavros Sachtouris | @errors.generic.all
|
255 | fa7d08b6 | Stavros Sachtouris | @errors.user.astakosclient
|
256 | fa7d08b6 | Stavros Sachtouris | def _run(self, token=None): |
257 | fa7d08b6 | Stavros Sachtouris | ask = token and token not in self.auth_base._uuids |
258 | fa7d08b6 | Stavros Sachtouris | self._print(self.auth_base.authenticate(token), self.print_dict) |
259 | fa7d08b6 | Stavros Sachtouris | if ask and self.ask_user( |
260 | fa7d08b6 | Stavros Sachtouris | 'Token is temporarily stored in memory. If it is stored in'
|
261 | fa7d08b6 | Stavros Sachtouris | ' kamaki configuration file, it will be available in later'
|
262 | fa7d08b6 | Stavros Sachtouris | ' sessions. Do you want to permanently store this token?'):
|
263 | fa7d08b6 | Stavros Sachtouris | tokens = self.auth_base._uuids.keys()
|
264 | fa7d08b6 | Stavros Sachtouris | tokens.remove(self.auth_base.token)
|
265 | fa7d08b6 | Stavros Sachtouris | self['config'].set_cloud( |
266 | fa7d08b6 | Stavros Sachtouris | self.cloud, 'token', ' '.join([self.auth_base.token] + tokens)) |
267 | fa7d08b6 | Stavros Sachtouris | self['config'].write() |
268 | fa7d08b6 | Stavros Sachtouris | |
269 | fa7d08b6 | Stavros Sachtouris | def main(self, new_token=None): |
270 | fa7d08b6 | Stavros Sachtouris | super(self.__class__, self)._run() |
271 | fa7d08b6 | Stavros Sachtouris | self._run(token=new_token)
|
272 | fa7d08b6 | Stavros Sachtouris | |
273 | fa7d08b6 | Stavros Sachtouris | |
274 | fa7d08b6 | Stavros Sachtouris | @command(user_commands)
|
275 | 25f9a991 | Stavros Sachtouris | class user_list(_init_synnefo_astakosclient, _optional_json): |
276 | 25f9a991 | Stavros Sachtouris | """List (cached) session users"""
|
277 | fa7d08b6 | Stavros Sachtouris | |
278 | fa7d08b6 | Stavros Sachtouris | arguments = dict(
|
279 | fa7d08b6 | Stavros Sachtouris | detail=FlagArgument('Detailed listing', ('-l', '--detail')) |
280 | fa7d08b6 | Stavros Sachtouris | ) |
281 | fa7d08b6 | Stavros Sachtouris | |
282 | fa7d08b6 | Stavros Sachtouris | @errors.generic.all
|
283 | fa7d08b6 | Stavros Sachtouris | @errors.user.astakosclient
|
284 | fa7d08b6 | Stavros Sachtouris | def _run(self): |
285 | fa7d08b6 | Stavros Sachtouris | self._print([u if self['detail'] else (dict( |
286 | fa7d08b6 | Stavros Sachtouris | id=u['id'], name=u['name'])) for u in self.auth_base.list_users()]) |
287 | fa7d08b6 | Stavros Sachtouris | |
288 | fa7d08b6 | Stavros Sachtouris | def main(self): |
289 | fa7d08b6 | Stavros Sachtouris | super(self.__class__, self)._run() |
290 | fa7d08b6 | Stavros Sachtouris | self._run()
|
291 | fa7d08b6 | Stavros Sachtouris | |
292 | fa7d08b6 | Stavros Sachtouris | |
293 | fa7d08b6 | Stavros Sachtouris | @command(user_commands)
|
294 | 25f9a991 | Stavros Sachtouris | class user_select(_init_synnefo_astakosclient): |
295 | 25f9a991 | Stavros Sachtouris | """Select a user from the (cached) list as the current session user"""
|
296 | fa7d08b6 | Stavros Sachtouris | |
297 | fa7d08b6 | Stavros Sachtouris | @errors.generic.all
|
298 | fa7d08b6 | Stavros Sachtouris | @errors.user.astakosclient
|
299 | fa7d08b6 | Stavros Sachtouris | def _run(self, uuid): |
300 | fa7d08b6 | Stavros Sachtouris | try:
|
301 | fa7d08b6 | Stavros Sachtouris | first_token = self.auth_base.get_token(uuid)
|
302 | fa7d08b6 | Stavros Sachtouris | except KeyError: |
303 | fa7d08b6 | Stavros Sachtouris | raise CLIError(
|
304 | fa7d08b6 | Stavros Sachtouris | 'No user with uuid %s in the cached session list' % uuid,
|
305 | fa7d08b6 | Stavros Sachtouris | details=[ |
306 | fa7d08b6 | Stavros Sachtouris | 'To see all cached session users',
|
307 | 25f9a991 | Stavros Sachtouris | ' /user list',
|
308 | fa7d08b6 | Stavros Sachtouris | 'To authenticate and add a new user in the session list',
|
309 | 25f9a991 | Stavros Sachtouris | ' /user add <new token>'])
|
310 | fa7d08b6 | Stavros Sachtouris | if self.auth_base.token != first_token: |
311 | fa7d08b6 | Stavros Sachtouris | self.auth_base.token = first_token
|
312 | fa7d08b6 | Stavros Sachtouris | msg = 'User with id %s is now the current session user.\n' % uuid
|
313 | fa7d08b6 | Stavros Sachtouris | msg += 'Do you want future sessions to also start with this user?'
|
314 | fa7d08b6 | Stavros Sachtouris | if self.ask_user(msg): |
315 | fa7d08b6 | Stavros Sachtouris | tokens = self.auth_base._uuids.keys()
|
316 | fa7d08b6 | Stavros Sachtouris | tokens.remove(self.auth_base.token)
|
317 | fa7d08b6 | Stavros Sachtouris | tokens.insert(0, self.auth_base.token) |
318 | fa7d08b6 | Stavros Sachtouris | self['config'].set_cloud( |
319 | fa7d08b6 | Stavros Sachtouris | self.cloud, 'token', ' '.join(tokens)) |
320 | fa7d08b6 | Stavros Sachtouris | self['config'].write() |
321 | fa7d08b6 | Stavros Sachtouris | self.error('User is selected for next sessions') |
322 | fa7d08b6 | Stavros Sachtouris | else:
|
323 | fa7d08b6 | Stavros Sachtouris | self.error('User is not permanently selected') |
324 | fa7d08b6 | Stavros Sachtouris | else:
|
325 | fa7d08b6 | Stavros Sachtouris | self.error('User was already the selected session user') |
326 | fa7d08b6 | Stavros Sachtouris | |
327 | fa7d08b6 | Stavros Sachtouris | def main(self, user_uuid): |
328 | fa7d08b6 | Stavros Sachtouris | super(self.__class__, self)._run() |
329 | fa7d08b6 | Stavros Sachtouris | self._run(uuid=user_uuid)
|
330 | fa7d08b6 | Stavros Sachtouris | |
331 | fa7d08b6 | Stavros Sachtouris | |
332 | fa7d08b6 | Stavros Sachtouris | @command(user_commands)
|
333 | 25f9a991 | Stavros Sachtouris | class user_delete(_init_synnefo_astakosclient): |
334 | 25f9a991 | Stavros Sachtouris | """Delete a user (token) from the (cached) list of session users"""
|
335 | fa7d08b6 | Stavros Sachtouris | |
336 | fa7d08b6 | Stavros Sachtouris | @errors.generic.all
|
337 | fa7d08b6 | Stavros Sachtouris | @errors.user.astakosclient
|
338 | fa7d08b6 | Stavros Sachtouris | def _run(self, uuid): |
339 | fa7d08b6 | Stavros Sachtouris | if uuid == self.auth_base.user_term('id'): |
340 | fa7d08b6 | Stavros Sachtouris | raise CLIError('Cannot remove current session user', details=[ |
341 | fa7d08b6 | Stavros Sachtouris | 'To see all cached session users',
|
342 | 25f9a991 | Stavros Sachtouris | ' /user list',
|
343 | fa7d08b6 | Stavros Sachtouris | 'To see current session user',
|
344 | 25f9a991 | Stavros Sachtouris | ' /user info',
|
345 | fa7d08b6 | Stavros Sachtouris | 'To select a different session user',
|
346 | 25f9a991 | Stavros Sachtouris | ' /user select <user uuid>'])
|
347 | fa7d08b6 | Stavros Sachtouris | try:
|
348 | fa7d08b6 | Stavros Sachtouris | self.auth_base.remove_user(uuid)
|
349 | fa7d08b6 | Stavros Sachtouris | except KeyError: |
350 | fa7d08b6 | Stavros Sachtouris | raise CLIError('No user with uuid %s in session list' % uuid, |
351 | fa7d08b6 | Stavros Sachtouris | details=[ |
352 | fa7d08b6 | Stavros Sachtouris | 'To see all cached session users',
|
353 | 25f9a991 | Stavros Sachtouris | ' /user list',
|
354 | fa7d08b6 | Stavros Sachtouris | 'To authenticate and add a new user in the session list',
|
355 | 25f9a991 | Stavros Sachtouris | ' /user add <new token>'])
|
356 | fa7d08b6 | Stavros Sachtouris | if self.ask_user( |
357 | fa7d08b6 | Stavros Sachtouris | 'User is removed from current session, but will be restored in'
|
358 | fa7d08b6 | Stavros Sachtouris | ' the next session. Remove the user from future sessions?'):
|
359 | fa7d08b6 | Stavros Sachtouris | self['config'].set_cloud( |
360 | fa7d08b6 | Stavros Sachtouris | self.cloud, 'token', ' '.join(self.auth_base._uuids.keys())) |
361 | fa7d08b6 | Stavros Sachtouris | self['config'].write() |
362 | fa7d08b6 | Stavros Sachtouris | |
363 | fa7d08b6 | Stavros Sachtouris | def main(self, user_uuid): |
364 | fa7d08b6 | Stavros Sachtouris | super(self.__class__, self)._run() |
365 | fa7d08b6 | Stavros Sachtouris | self._run(uuid=user_uuid)
|
366 | fa7d08b6 | Stavros Sachtouris | |
367 | fa7d08b6 | Stavros Sachtouris | |
368 | ab863157 | Stavros Sachtouris | # command admin
|
369 | ab863157 | Stavros Sachtouris | |
370 | 25f9a991 | Stavros Sachtouris | @command(service_commands)
|
371 | 25f9a991 | Stavros Sachtouris | class service_list(_init_synnefo_astakosclient, _optional_json): |
372 | ab863157 | Stavros Sachtouris | """List available services"""
|
373 | ab863157 | Stavros Sachtouris | |
374 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
375 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
376 | ab863157 | Stavros Sachtouris | def _run(self): |
377 | ab863157 | Stavros Sachtouris | self._print(self.client.get_services()) |
378 | ab863157 | Stavros Sachtouris | |
379 | ab863157 | Stavros Sachtouris | def main(self): |
380 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
381 | ab863157 | Stavros Sachtouris | self._run()
|
382 | ab863157 | Stavros Sachtouris | |
383 | ab863157 | Stavros Sachtouris | |
384 | 25f9a991 | Stavros Sachtouris | @command(service_commands)
|
385 | 25f9a991 | Stavros Sachtouris | class service_uuid2username(_init_synnefo_astakosclient, _optional_json): |
386 | ab863157 | Stavros Sachtouris | """Get service username(s) from uuid(s)"""
|
387 | ab863157 | Stavros Sachtouris | |
388 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
389 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
390 | ab863157 | Stavros Sachtouris | @with_temp_token
|
391 | ab863157 | Stavros Sachtouris | def _run(self, uuids): |
392 | ab863157 | Stavros Sachtouris | if 1 == len(uuids): |
393 | ab863157 | Stavros Sachtouris | self._print(self.client.service_get_username(uuids[0])) |
394 | ab863157 | Stavros Sachtouris | else:
|
395 | ab863157 | Stavros Sachtouris | self._print(
|
396 | ab863157 | Stavros Sachtouris | self.client.service_get_usernames(uuids),
|
397 | ab863157 | Stavros Sachtouris | self.print_dict)
|
398 | ab863157 | Stavros Sachtouris | |
399 | ab863157 | Stavros Sachtouris | def main(self, service_token, uuid, *more_uuids): |
400 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
401 | ab863157 | Stavros Sachtouris | self._run([uuid] + list(more_uuids), token=service_token) |
402 | ab863157 | Stavros Sachtouris | |
403 | ab863157 | Stavros Sachtouris | |
404 | 25f9a991 | Stavros Sachtouris | @command(service_commands)
|
405 | 25f9a991 | Stavros Sachtouris | class service_username2uuid(_init_synnefo_astakosclient, _optional_json): |
406 | ab863157 | Stavros Sachtouris | """Get service uuid(s) from username(s)"""
|
407 | ab863157 | Stavros Sachtouris | |
408 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
409 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
410 | ab863157 | Stavros Sachtouris | @with_temp_token
|
411 | ab863157 | Stavros Sachtouris | def _run(self, usernames): |
412 | ab863157 | Stavros Sachtouris | if 1 == len(usernames): |
413 | ab863157 | Stavros Sachtouris | self._print(self.client.service_get_uuid(usernames[0])) |
414 | ab863157 | Stavros Sachtouris | else:
|
415 | ab863157 | Stavros Sachtouris | self._print(
|
416 | ab863157 | Stavros Sachtouris | self.client.service_get_uuids(usernames),
|
417 | ab863157 | Stavros Sachtouris | self.print_dict)
|
418 | ab863157 | Stavros Sachtouris | |
419 | ab863157 | Stavros Sachtouris | def main(self, service_token, usernames, *more_usernames): |
420 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
421 | ab863157 | Stavros Sachtouris | self._run([usernames] + list(more_usernames), token=service_token) |
422 | ab863157 | Stavros Sachtouris | |
423 | ab863157 | Stavros Sachtouris | |
424 | 25f9a991 | Stavros Sachtouris | @command(service_commands)
|
425 | 25f9a991 | Stavros Sachtouris | class service_quotas(_init_synnefo_astakosclient, _optional_json): |
426 | ab863157 | Stavros Sachtouris | """Get service quotas"""
|
427 | ab863157 | Stavros Sachtouris | |
428 | ab863157 | Stavros Sachtouris | arguments = dict(
|
429 | ab863157 | Stavros Sachtouris | uuid=ValueArgument('A user uuid to get quotas for', '--uuid') |
430 | ab863157 | Stavros Sachtouris | ) |
431 | ab863157 | Stavros Sachtouris | |
432 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
433 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
434 | ab863157 | Stavros Sachtouris | @with_temp_token
|
435 | ab863157 | Stavros Sachtouris | def _run(self): |
436 | ab863157 | Stavros Sachtouris | self._print(self.client.service_get_quotas(self['uuid'])) |
437 | ab863157 | Stavros Sachtouris | |
438 | ab863157 | Stavros Sachtouris | def main(self, service_token): |
439 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
440 | ab863157 | Stavros Sachtouris | self._run(token=service_token)
|
441 | ab863157 | Stavros Sachtouris | |
442 | ab863157 | Stavros Sachtouris | |
443 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
444 | 25f9a991 | Stavros Sachtouris | class commission_pending(_init_synnefo_astakosclient, _optional_json): |
445 | ab863157 | Stavros Sachtouris | """List pending commissions (special privileges required)"""
|
446 | ab863157 | Stavros Sachtouris | |
447 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
448 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
449 | ab863157 | Stavros Sachtouris | def _run(self): |
450 | ab863157 | Stavros Sachtouris | self._print(self.client.get_pending_commissions()) |
451 | ab863157 | Stavros Sachtouris | |
452 | ab863157 | Stavros Sachtouris | def main(self): |
453 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
454 | ab863157 | Stavros Sachtouris | self._run()
|
455 | ab863157 | Stavros Sachtouris | |
456 | ab863157 | Stavros Sachtouris | |
457 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
458 | 25f9a991 | Stavros Sachtouris | class commission_info(_init_synnefo_astakosclient, _optional_json): |
459 | ab863157 | Stavros Sachtouris | """Get commission info (special privileges required)"""
|
460 | ab863157 | Stavros Sachtouris | |
461 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
462 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
463 | ab863157 | Stavros Sachtouris | def _run(self, commission_id): |
464 | ab863157 | Stavros Sachtouris | commission_id = int(commission_id)
|
465 | ab863157 | Stavros Sachtouris | self._print(
|
466 | ab863157 | Stavros Sachtouris | self.client.get_commission_info(commission_id), self.print_dict) |
467 | ab863157 | Stavros Sachtouris | |
468 | ab863157 | Stavros Sachtouris | def main(self, commission_id): |
469 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
470 | ab863157 | Stavros Sachtouris | self._run(commission_id)
|
471 | ab863157 | Stavros Sachtouris | |
472 | ab863157 | Stavros Sachtouris | |
473 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
474 | 25f9a991 | Stavros Sachtouris | class commission_accept(_init_synnefo_astakosclient): |
475 | ab863157 | Stavros Sachtouris | """Accept a pending commission (special privileges required)"""
|
476 | ab863157 | Stavros Sachtouris | |
477 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
478 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
479 | ab863157 | Stavros Sachtouris | def _run(self, commission_id): |
480 | ab863157 | Stavros Sachtouris | commission_id = int(commission_id)
|
481 | ab863157 | Stavros Sachtouris | self.client.accept_commission(commission_id)
|
482 | ab863157 | Stavros Sachtouris | |
483 | ab863157 | Stavros Sachtouris | def main(self, commission_id): |
484 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
485 | ab863157 | Stavros Sachtouris | self._run(commission_id)
|
486 | ab863157 | Stavros Sachtouris | |
487 | ab863157 | Stavros Sachtouris | |
488 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
489 | 25f9a991 | Stavros Sachtouris | class commission_reject(_init_synnefo_astakosclient): |
490 | ab863157 | Stavros Sachtouris | """Reject a pending commission (special privileges required)"""
|
491 | ab863157 | Stavros Sachtouris | |
492 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
493 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
494 | ab863157 | Stavros Sachtouris | def _run(self, commission_id): |
495 | ab863157 | Stavros Sachtouris | commission_id = int(commission_id)
|
496 | ab863157 | Stavros Sachtouris | self.client.reject_commission(commission_id)
|
497 | ab863157 | Stavros Sachtouris | |
498 | ab863157 | Stavros Sachtouris | def main(self, commission_id): |
499 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
500 | ab863157 | Stavros Sachtouris | self._run(commission_id)
|
501 | ab863157 | Stavros Sachtouris | |
502 | ab863157 | Stavros Sachtouris | |
503 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
504 | 25f9a991 | Stavros Sachtouris | class commission_resolve(_init_synnefo_astakosclient, _optional_json): |
505 | ab863157 | Stavros Sachtouris | """Resolve multiple commissions (special privileges required)"""
|
506 | ab863157 | Stavros Sachtouris | |
507 | ab863157 | Stavros Sachtouris | arguments = dict(
|
508 | ab863157 | Stavros Sachtouris | accept=CommaSeparatedListArgument( |
509 | ab863157 | Stavros Sachtouris | 'commission ids to accept (e.g., --accept=11,12,13,...',
|
510 | ab863157 | Stavros Sachtouris | '--accept'),
|
511 | ab863157 | Stavros Sachtouris | reject=CommaSeparatedListArgument( |
512 | ab863157 | Stavros Sachtouris | 'commission ids to reject (e.g., --reject=11,12,13,...',
|
513 | ab863157 | Stavros Sachtouris | '--reject')
|
514 | ab863157 | Stavros Sachtouris | ) |
515 | ab863157 | Stavros Sachtouris | |
516 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
517 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
518 | ab863157 | Stavros Sachtouris | def _run(self): |
519 | ab863157 | Stavros Sachtouris | self.writeln('accepted ', self['accept']) |
520 | ab863157 | Stavros Sachtouris | self.writeln('rejected ', self['reject']) |
521 | ab863157 | Stavros Sachtouris | self._print(
|
522 | ab863157 | Stavros Sachtouris | self.client.resolve_commissions(self['accept'], self['reject']), |
523 | ab863157 | Stavros Sachtouris | self.print_dict)
|
524 | ab863157 | Stavros Sachtouris | |
525 | ab863157 | Stavros Sachtouris | def main(self): |
526 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
527 | ab863157 | Stavros Sachtouris | self._run()
|
528 | ab863157 | Stavros Sachtouris | |
529 | ab863157 | Stavros Sachtouris | |
530 | 25f9a991 | Stavros Sachtouris | @command(commission_commands)
|
531 | 25f9a991 | Stavros Sachtouris | class commission_issue(_init_synnefo_astakosclient, _optional_json): |
532 | ab863157 | Stavros Sachtouris | """Issue commissions as a json string (special privileges required)
|
533 | ab863157 | Stavros Sachtouris | Parameters:
|
534 | ab863157 | Stavros Sachtouris | holder -- user's id (string)
|
535 | ab863157 | Stavros Sachtouris | source -- commission's source (ex system) (string)
|
536 | ab863157 | Stavros Sachtouris | provisions -- resources with their quantity (json-dict from string to int)
|
537 | ab863157 | Stavros Sachtouris | name -- description of the commission (string)
|
538 | ab863157 | Stavros Sachtouris | """
|
539 | ab863157 | Stavros Sachtouris | |
540 | ab863157 | Stavros Sachtouris | arguments = dict(
|
541 | ab863157 | Stavros Sachtouris | force=FlagArgument('Force commission', '--force'), |
542 | ab863157 | Stavros Sachtouris | accept=FlagArgument('Do not wait for verification', '--accept') |
543 | ab863157 | Stavros Sachtouris | ) |
544 | ab863157 | Stavros Sachtouris | |
545 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
546 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
547 | ab863157 | Stavros Sachtouris | def _run(self, holder, source, provisions, name=''): |
548 | ab863157 | Stavros Sachtouris | provisions = loads(provisions) |
549 | ab863157 | Stavros Sachtouris | self._print(self.client.issue_one_commission( |
550 | ab863157 | Stavros Sachtouris | holder, source, provisions, name, |
551 | ab863157 | Stavros Sachtouris | self['force'], self['accept'])) |
552 | ab863157 | Stavros Sachtouris | |
553 | ab863157 | Stavros Sachtouris | def main(self, user_uuid, source, provisions_file, name=''): |
554 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
555 | ab863157 | Stavros Sachtouris | self._run(user_uuid, source, provisions_file, name)
|
556 | ab863157 | Stavros Sachtouris | |
557 | ab863157 | Stavros Sachtouris | |
558 | 25f9a991 | Stavros Sachtouris | @command(resource_commands)
|
559 | 25f9a991 | Stavros Sachtouris | class resource_list(_init_synnefo_astakosclient, _optional_json): |
560 | ab863157 | Stavros Sachtouris | """List user resources"""
|
561 | ab863157 | Stavros Sachtouris | |
562 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
563 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
564 | ab863157 | Stavros Sachtouris | def _run(self): |
565 | ab863157 | Stavros Sachtouris | self._print(self.client.get_resources(), self.print_dict) |
566 | ab863157 | Stavros Sachtouris | |
567 | ab863157 | Stavros Sachtouris | def main(self): |
568 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
569 | ab863157 | Stavros Sachtouris | self._run()
|
570 | ab863157 | Stavros Sachtouris | |
571 | ab863157 | Stavros Sachtouris | |
572 | 25f9a991 | Stavros Sachtouris | @command(endpoint_commands)
|
573 | 25f9a991 | Stavros Sachtouris | class endpoint_list(_init_synnefo_astakosclient, _optional_json): |
574 | ab863157 | Stavros Sachtouris | """Get endpoints service endpoints"""
|
575 | ab863157 | Stavros Sachtouris | |
576 | ab863157 | Stavros Sachtouris | @errors.generic.all
|
577 | ab863157 | Stavros Sachtouris | @errors.user.astakosclient
|
578 | ab863157 | Stavros Sachtouris | def _run(self): |
579 | fa7d08b6 | Stavros Sachtouris | self._print(self.client.get_endpoints(), self.print_dict) |
580 | ab863157 | Stavros Sachtouris | |
581 | ab863157 | Stavros Sachtouris | def main(self): |
582 | ab863157 | Stavros Sachtouris | super(self.__class__, self)._run() |
583 | ab863157 | Stavros Sachtouris | self._run()
|
584 | ab863157 | Stavros Sachtouris | |
585 | ab863157 | Stavros Sachtouris | |
586 | c308d73f | Stavros Sachtouris | # command project
|
587 | c308d73f | Stavros Sachtouris | |
588 | c308d73f | Stavros Sachtouris | |
589 | 6893e31c | Stavros Sachtouris | _project_specs = """{
|
590 | 6893e31c | Stavros Sachtouris | "name": name,
|
591 | 6893e31c | Stavros Sachtouris | "owner": uuid,
|
592 | 6893e31c | Stavros Sachtouris | "homepage": homepage, # optional
|
593 | 6893e31c | Stavros Sachtouris | "description": description, # optional
|
594 | 6893e31c | Stavros Sachtouris | "comments": comments, # optional
|
595 | 6893e31c | Stavros Sachtouris | "start_date": date, # optional
|
596 | 6893e31c | Stavros Sachtouris | "end_date": date,
|
597 | 6893e31c | Stavros Sachtouris | "join_policy": "auto" | "moderated" | "closed", # default: "moderated"
|
598 | 6893e31c | Stavros Sachtouris | "leave_policy": "auto" | "moderated" | "closed", # default: "auto"
|
599 | 6893e31c | Stavros Sachtouris | "resources": {
|
600 | 6893e31c | Stavros Sachtouris | "cyclades.vm": {
|
601 | 6893e31c | Stavros Sachtouris | "project_capacity": int or null,
|
602 | 6893e31c | Stavros Sachtouris | "member_capacity": int
|
603 | c308d73f | Stavros Sachtouris | }
|
604 | c308d73f | Stavros Sachtouris | }
|
605 | 6893e31c | Stavros Sachtouris | }
|
606 | 6893e31c | Stavros Sachtouris | """
|
607 | c308d73f | Stavros Sachtouris | |
608 | c308d73f | Stavros Sachtouris | |
609 | c308d73f | Stavros Sachtouris | def apply_notification(foo): |
610 | c308d73f | Stavros Sachtouris | def wrap(self, *args, **kwargs): |
611 | c308d73f | Stavros Sachtouris | r = foo(self, *args, **kwargs)
|
612 | c308d73f | Stavros Sachtouris | self.writeln('Application is submitted successfully') |
613 | c308d73f | Stavros Sachtouris | return r
|
614 | c308d73f | Stavros Sachtouris | return wrap
|
615 | c308d73f | Stavros Sachtouris | |
616 | c308d73f | Stavros Sachtouris | |
617 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
618 | c308d73f | Stavros Sachtouris | class project_list(_init_synnefo_astakosclient, _optional_json): |
619 | c308d73f | Stavros Sachtouris | """List all projects"""
|
620 | c308d73f | Stavros Sachtouris | |
621 | c308d73f | Stavros Sachtouris | arguments = dict(
|
622 | c308d73f | Stavros Sachtouris | name=ValueArgument('Filter by name', ('--with-name', )), |
623 | c308d73f | Stavros Sachtouris | state=ValueArgument('Filter by state', ('--with-state', )), |
624 | c308d73f | Stavros Sachtouris | owner=ValueArgument('Filter by owner', ('--with-owner', )) |
625 | c308d73f | Stavros Sachtouris | ) |
626 | c308d73f | Stavros Sachtouris | |
627 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
628 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
629 | c308d73f | Stavros Sachtouris | def _run(self): |
630 | c308d73f | Stavros Sachtouris | self._print(self.client.get_projects( |
631 | c308d73f | Stavros Sachtouris | self['name'], self['state'], self['owner'])) |
632 | c308d73f | Stavros Sachtouris | |
633 | c308d73f | Stavros Sachtouris | def main(self): |
634 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
635 | c308d73f | Stavros Sachtouris | self._run()
|
636 | c308d73f | Stavros Sachtouris | |
637 | c308d73f | Stavros Sachtouris | |
638 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
639 | c308d73f | Stavros Sachtouris | class project_info(_init_synnefo_astakosclient, _optional_json): |
640 | c308d73f | Stavros Sachtouris | """Get details for a project"""
|
641 | c308d73f | Stavros Sachtouris | |
642 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
643 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
644 | c308d73f | Stavros Sachtouris | def _run(self, project_id): |
645 | c308d73f | Stavros Sachtouris | self._print(
|
646 | c308d73f | Stavros Sachtouris | self.client.get_project(project_id), self.print_dict) |
647 | c308d73f | Stavros Sachtouris | |
648 | c308d73f | Stavros Sachtouris | def main(self, project_id): |
649 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
650 | c308d73f | Stavros Sachtouris | self._run(project_id)
|
651 | c308d73f | Stavros Sachtouris | |
652 | c308d73f | Stavros Sachtouris | |
653 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
654 | c308d73f | Stavros Sachtouris | class project_create(_init_synnefo_astakosclient, _optional_json): |
655 | 6893e31c | Stavros Sachtouris | """Apply for a new project (enter data though standard input or file path)
|
656 | 6893e31c | Stavros Sachtouris | Project details must be provided as a json-formated dict from the
|
657 | 6893e31c | Stavros Sachtouris | standard input, or through a file
|
658 | c308d73f | Stavros Sachtouris | """
|
659 | c308d73f | Stavros Sachtouris | |
660 | c308d73f | Stavros Sachtouris | __doc__ += _project_specs |
661 | c308d73f | Stavros Sachtouris | |
662 | c308d73f | Stavros Sachtouris | arguments = dict(
|
663 | c308d73f | Stavros Sachtouris | specs_path=ValueArgument( |
664 | c308d73f | Stavros Sachtouris | 'Specification file path (content must be in json)', '--spec-file') |
665 | c308d73f | Stavros Sachtouris | ) |
666 | c308d73f | Stavros Sachtouris | |
667 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
668 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
669 | c308d73f | Stavros Sachtouris | @apply_notification
|
670 | c308d73f | Stavros Sachtouris | def _run(self): |
671 | c308d73f | Stavros Sachtouris | input_stream = open(abspath(self['specs_path'])) if ( |
672 | c308d73f | Stavros Sachtouris | self['specs_path']) else self._in |
673 | c308d73f | Stavros Sachtouris | specs = load(input_stream) |
674 | c308d73f | Stavros Sachtouris | self._print(
|
675 | c308d73f | Stavros Sachtouris | self.client.create_project(specs), self.print_dict) |
676 | c308d73f | Stavros Sachtouris | |
677 | c308d73f | Stavros Sachtouris | def main(self): |
678 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
679 | c308d73f | Stavros Sachtouris | self._run()
|
680 | c308d73f | Stavros Sachtouris | |
681 | c308d73f | Stavros Sachtouris | |
682 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
683 | c308d73f | Stavros Sachtouris | class project_modify(_init_synnefo_astakosclient, _optional_json): |
684 | c308d73f | Stavros Sachtouris | """Modify a project (input a json-dict)
|
685 | c308d73f | Stavros Sachtouris | Project details must be provided as a json-formated dict from the standard
|
686 | c308d73f | Stavros Sachtouris | input, or through a file
|
687 | c308d73f | Stavros Sachtouris | """
|
688 | c308d73f | Stavros Sachtouris | |
689 | c308d73f | Stavros Sachtouris | __doc__ += _project_specs |
690 | c308d73f | Stavros Sachtouris | |
691 | c308d73f | Stavros Sachtouris | arguments = dict(
|
692 | c308d73f | Stavros Sachtouris | specs_path=ValueArgument( |
693 | c308d73f | Stavros Sachtouris | 'Specification file path (content must be in json)', '--spec-file') |
694 | c308d73f | Stavros Sachtouris | ) |
695 | c308d73f | Stavros Sachtouris | |
696 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
697 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
698 | c308d73f | Stavros Sachtouris | @apply_notification
|
699 | c308d73f | Stavros Sachtouris | def _run(self, project_id): |
700 | c308d73f | Stavros Sachtouris | input_stream = open(abspath(self['specs_path'])) if ( |
701 | c308d73f | Stavros Sachtouris | self['specs_path']) else self._in |
702 | c308d73f | Stavros Sachtouris | specs = load(input_stream) |
703 | c308d73f | Stavros Sachtouris | self._print(
|
704 | c308d73f | Stavros Sachtouris | self.client.modify_project(project_id, specs),
|
705 | c308d73f | Stavros Sachtouris | self.print_dict)
|
706 | c308d73f | Stavros Sachtouris | |
707 | c308d73f | Stavros Sachtouris | def main(self, project_id): |
708 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
709 | c308d73f | Stavros Sachtouris | self._run(project_id)
|
710 | c308d73f | Stavros Sachtouris | |
711 | c308d73f | Stavros Sachtouris | |
712 | c308d73f | Stavros Sachtouris | class _project_action(_init_synnefo_astakosclient): |
713 | c308d73f | Stavros Sachtouris | |
714 | c308d73f | Stavros Sachtouris | action = ''
|
715 | c308d73f | Stavros Sachtouris | |
716 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
717 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
718 | c308d73f | Stavros Sachtouris | def _run(self, project_id, quote_a_reason): |
719 | c308d73f | Stavros Sachtouris | self.client.project_action(project_id, self.action, quote_a_reason) |
720 | c308d73f | Stavros Sachtouris | |
721 | c308d73f | Stavros Sachtouris | def main(self, project_id, quote_a_reason=''): |
722 | c308d73f | Stavros Sachtouris | super(_project_action, self)._run() |
723 | c308d73f | Stavros Sachtouris | self._run(project_id, quote_a_reason)
|
724 | c308d73f | Stavros Sachtouris | |
725 | c308d73f | Stavros Sachtouris | |
726 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
727 | c308d73f | Stavros Sachtouris | class project_suspend(_project_action): |
728 | c308d73f | Stavros Sachtouris | """Suspend a project (special privileges needed)"""
|
729 | c308d73f | Stavros Sachtouris | action = 'suspend'
|
730 | c308d73f | Stavros Sachtouris | |
731 | c308d73f | Stavros Sachtouris | |
732 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
733 | c308d73f | Stavros Sachtouris | class project_unsuspend(_project_action): |
734 | c308d73f | Stavros Sachtouris | """Resume a suspended project (special privileges needed)"""
|
735 | c308d73f | Stavros Sachtouris | action = 'unsuspend'
|
736 | c308d73f | Stavros Sachtouris | |
737 | c308d73f | Stavros Sachtouris | |
738 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
739 | c308d73f | Stavros Sachtouris | class project_terminate(_project_action): |
740 | c308d73f | Stavros Sachtouris | """Terminate a project (special privileges needed)"""
|
741 | c308d73f | Stavros Sachtouris | action = 'terminate'
|
742 | c308d73f | Stavros Sachtouris | |
743 | c308d73f | Stavros Sachtouris | |
744 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
745 | c308d73f | Stavros Sachtouris | class project_reinstate(_project_action): |
746 | c308d73f | Stavros Sachtouris | """Reinstate a terminated project (special privileges needed)"""
|
747 | c308d73f | Stavros Sachtouris | action = 'reinstate'
|
748 | c308d73f | Stavros Sachtouris | |
749 | c308d73f | Stavros Sachtouris | |
750 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
751 | c308d73f | Stavros Sachtouris | class project_application(_init_synnefo_astakosclient): |
752 | c308d73f | Stavros Sachtouris | """Application management commands"""
|
753 | c308d73f | Stavros Sachtouris | |
754 | c308d73f | Stavros Sachtouris | |
755 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
756 | c308d73f | Stavros Sachtouris | class project_application_list(_init_synnefo_astakosclient, _optional_json): |
757 | c308d73f | Stavros Sachtouris | """List all applications (old and new)"""
|
758 | c308d73f | Stavros Sachtouris | |
759 | c308d73f | Stavros Sachtouris | arguments = dict(
|
760 | c308d73f | Stavros Sachtouris | project=IntArgument('Filter by project id', '--with-project-id') |
761 | c308d73f | Stavros Sachtouris | ) |
762 | c308d73f | Stavros Sachtouris | |
763 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
764 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
765 | c308d73f | Stavros Sachtouris | def _run(self): |
766 | c308d73f | Stavros Sachtouris | self._print(self.client.get_applications(self['project'])) |
767 | c308d73f | Stavros Sachtouris | |
768 | c308d73f | Stavros Sachtouris | def main(self): |
769 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
770 | c308d73f | Stavros Sachtouris | self._run()
|
771 | c308d73f | Stavros Sachtouris | |
772 | c308d73f | Stavros Sachtouris | |
773 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
774 | c308d73f | Stavros Sachtouris | class project_application_info(_init_synnefo_astakosclient, _optional_json): |
775 | c308d73f | Stavros Sachtouris | """Get details on an application"""
|
776 | c308d73f | Stavros Sachtouris | |
777 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
778 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
779 | c308d73f | Stavros Sachtouris | def _run(self, app_id): |
780 | c308d73f | Stavros Sachtouris | self._print(
|
781 | c308d73f | Stavros Sachtouris | self.client.get_application(app_id), self.print_dict) |
782 | c308d73f | Stavros Sachtouris | |
783 | c308d73f | Stavros Sachtouris | def main(self, application_id): |
784 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
785 | c308d73f | Stavros Sachtouris | self._run(application_id)
|
786 | c308d73f | Stavros Sachtouris | |
787 | c308d73f | Stavros Sachtouris | |
788 | c308d73f | Stavros Sachtouris | class _application_action(_init_synnefo_astakosclient): |
789 | c308d73f | Stavros Sachtouris | |
790 | c308d73f | Stavros Sachtouris | action = ''
|
791 | c308d73f | Stavros Sachtouris | |
792 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
793 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
794 | c308d73f | Stavros Sachtouris | def _run(self, app_id, quote_a_reason): |
795 | c308d73f | Stavros Sachtouris | self.client.application_action(app_id, self.action, quote_a_reason) |
796 | c308d73f | Stavros Sachtouris | |
797 | c308d73f | Stavros Sachtouris | def main(self, application_id, quote_a_reason=''): |
798 | c308d73f | Stavros Sachtouris | super(_application_action, self)._run() |
799 | c308d73f | Stavros Sachtouris | self._run(application_id, quote_a_reason)
|
800 | c308d73f | Stavros Sachtouris | |
801 | c308d73f | Stavros Sachtouris | |
802 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
803 | c308d73f | Stavros Sachtouris | class project_application_approve(_application_action): |
804 | c308d73f | Stavros Sachtouris | """Approve an application (special privileges needed)"""
|
805 | c308d73f | Stavros Sachtouris | action = 'approve'
|
806 | c308d73f | Stavros Sachtouris | |
807 | c308d73f | Stavros Sachtouris | |
808 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
809 | c308d73f | Stavros Sachtouris | class project_application_deny(_application_action): |
810 | c308d73f | Stavros Sachtouris | """Deny an application (special privileges needed)"""
|
811 | c308d73f | Stavros Sachtouris | action = 'deny'
|
812 | c308d73f | Stavros Sachtouris | |
813 | c308d73f | Stavros Sachtouris | |
814 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
815 | c308d73f | Stavros Sachtouris | class project_application_dismiss(_application_action): |
816 | c308d73f | Stavros Sachtouris | """Dismiss your denied application"""
|
817 | c308d73f | Stavros Sachtouris | action = 'dismiss'
|
818 | c308d73f | Stavros Sachtouris | |
819 | c308d73f | Stavros Sachtouris | |
820 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
821 | c308d73f | Stavros Sachtouris | class project_application_cancel(_application_action): |
822 | c308d73f | Stavros Sachtouris | """Cancel your application"""
|
823 | c308d73f | Stavros Sachtouris | action = 'cancel'
|
824 | c308d73f | Stavros Sachtouris | |
825 | c308d73f | Stavros Sachtouris | |
826 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
827 | c308d73f | Stavros Sachtouris | class project_membership(_init_synnefo_astakosclient): |
828 | c308d73f | Stavros Sachtouris | """Project membership management commands"""
|
829 | c308d73f | Stavros Sachtouris | |
830 | c308d73f | Stavros Sachtouris | |
831 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
832 | c308d73f | Stavros Sachtouris | class project_membership_list(_init_synnefo_astakosclient, _optional_json): |
833 | c308d73f | Stavros Sachtouris | """List all memberships"""
|
834 | c308d73f | Stavros Sachtouris | |
835 | c308d73f | Stavros Sachtouris | arguments = dict(
|
836 | c308d73f | Stavros Sachtouris | project=IntArgument('Filter by project id', '--with-project-id') |
837 | c308d73f | Stavros Sachtouris | ) |
838 | c308d73f | Stavros Sachtouris | |
839 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
840 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
841 | c308d73f | Stavros Sachtouris | def _run(self): |
842 | c308d73f | Stavros Sachtouris | self._print(self.client.get_memberships(self['project'])) |
843 | c308d73f | Stavros Sachtouris | |
844 | c308d73f | Stavros Sachtouris | def main(self): |
845 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
846 | c308d73f | Stavros Sachtouris | self._run()
|
847 | c308d73f | Stavros Sachtouris | |
848 | c308d73f | Stavros Sachtouris | |
849 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
850 | c308d73f | Stavros Sachtouris | class project_membership_info(_init_synnefo_astakosclient, _optional_json): |
851 | c308d73f | Stavros Sachtouris | """Details on a membership"""
|
852 | c308d73f | Stavros Sachtouris | |
853 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
854 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
855 | c308d73f | Stavros Sachtouris | def _run(self, memb_id): |
856 | c308d73f | Stavros Sachtouris | self._print(
|
857 | c308d73f | Stavros Sachtouris | self.client.get_membership(memb_id), self.print_dict) |
858 | c308d73f | Stavros Sachtouris | |
859 | c308d73f | Stavros Sachtouris | def main(self, membership_id): |
860 | c308d73f | Stavros Sachtouris | super(self.__class__, self)._run() |
861 | c308d73f | Stavros Sachtouris | self._run(membership_id)
|
862 | c308d73f | Stavros Sachtouris | |
863 | c308d73f | Stavros Sachtouris | |
864 | c308d73f | Stavros Sachtouris | class _membership_action(_init_synnefo_astakosclient, _optional_json): |
865 | c308d73f | Stavros Sachtouris | |
866 | c308d73f | Stavros Sachtouris | action = ''
|
867 | c308d73f | Stavros Sachtouris | |
868 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
869 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
870 | c308d73f | Stavros Sachtouris | def _run(self, memb_id, quote_a_reason): |
871 | c308d73f | Stavros Sachtouris | self._print(self.client.membership_action( |
872 | c308d73f | Stavros Sachtouris | memb_id, self.action, quote_a_reason))
|
873 | c308d73f | Stavros Sachtouris | |
874 | c308d73f | Stavros Sachtouris | def main(self, membership_id, quote_a_reason=''): |
875 | c308d73f | Stavros Sachtouris | super(_membership_action, self)._run() |
876 | c308d73f | Stavros Sachtouris | self._run(membership_id, quote_a_reason)
|
877 | c308d73f | Stavros Sachtouris | |
878 | c308d73f | Stavros Sachtouris | |
879 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
880 | c308d73f | Stavros Sachtouris | class project_membership_leave(_membership_action): |
881 | c308d73f | Stavros Sachtouris | """Leave a project you have membership to"""
|
882 | c308d73f | Stavros Sachtouris | action = 'leave'
|
883 | c308d73f | Stavros Sachtouris | |
884 | c308d73f | Stavros Sachtouris | |
885 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
886 | c308d73f | Stavros Sachtouris | class project_membership_cancel(_membership_action): |
887 | c308d73f | Stavros Sachtouris | """Cancel your (probably pending) membership to a project"""
|
888 | c308d73f | Stavros Sachtouris | action = 'cancel'
|
889 | c308d73f | Stavros Sachtouris | |
890 | c308d73f | Stavros Sachtouris | |
891 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
892 | c308d73f | Stavros Sachtouris | class project_membership_accept(_membership_action): |
893 | c308d73f | Stavros Sachtouris | """Accept a membership for a project you manage"""
|
894 | c308d73f | Stavros Sachtouris | action = 'accept'
|
895 | c308d73f | Stavros Sachtouris | |
896 | c308d73f | Stavros Sachtouris | |
897 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
898 | c308d73f | Stavros Sachtouris | class project_membership_reject(_membership_action): |
899 | c308d73f | Stavros Sachtouris | """Reject a membership for a project you manage"""
|
900 | c308d73f | Stavros Sachtouris | action = 'reject'
|
901 | c308d73f | Stavros Sachtouris | |
902 | c308d73f | Stavros Sachtouris | |
903 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
904 | c308d73f | Stavros Sachtouris | class project_membership_remove(_membership_action): |
905 | c308d73f | Stavros Sachtouris | """Remove a membership for a project you manage"""
|
906 | c308d73f | Stavros Sachtouris | action = 'remove'
|
907 | c308d73f | Stavros Sachtouris | |
908 | c308d73f | Stavros Sachtouris | |
909 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
910 | c308d73f | Stavros Sachtouris | class project_membership_join(_init_synnefo_astakosclient): |
911 | c308d73f | Stavros Sachtouris | """Join a project"""
|
912 | c308d73f | Stavros Sachtouris | |
913 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
914 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
915 | c308d73f | Stavros Sachtouris | def _run(self, project_id): |
916 | c308d73f | Stavros Sachtouris | self.writeln(self.client.join_project(project_id)) |
917 | c308d73f | Stavros Sachtouris | |
918 | c308d73f | Stavros Sachtouris | def main(self, project_id): |
919 | c308d73f | Stavros Sachtouris | super(project_membership_join, self)._run() |
920 | c308d73f | Stavros Sachtouris | self._run(project_id)
|
921 | c308d73f | Stavros Sachtouris | |
922 | c308d73f | Stavros Sachtouris | |
923 | c308d73f | Stavros Sachtouris | @command(project_commands)
|
924 | c308d73f | Stavros Sachtouris | class project_membership_enroll(_init_synnefo_astakosclient): |
925 | c308d73f | Stavros Sachtouris | """Enroll somebody to a project you manage"""
|
926 | c308d73f | Stavros Sachtouris | |
927 | c308d73f | Stavros Sachtouris | @errors.generic.all
|
928 | c308d73f | Stavros Sachtouris | @errors.user.astakosclient
|
929 | c308d73f | Stavros Sachtouris | def _run(self, project_id, email): |
930 | c308d73f | Stavros Sachtouris | self.writeln(self.client.enroll_member(project_id, email)) |
931 | c308d73f | Stavros Sachtouris | |
932 | c308d73f | Stavros Sachtouris | def main(self, project_id, email): |
933 | c308d73f | Stavros Sachtouris | super(project_membership_join, self)._run() |
934 | c308d73f | Stavros Sachtouris | self._run(project_id, email) |