root / kamaki / cli / commands / errors.py @ bb50c4ec
History | View | Annotate | Download (23.7 kB)
1 | e3f01d64 | Stavros Sachtouris | # Copyright 2011-2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | a00de254 | Stavros Sachtouris | #
|
3 | a00de254 | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | a00de254 | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | a00de254 | Stavros Sachtouris | # conditions are met:
|
6 | a00de254 | Stavros Sachtouris | #
|
7 | a00de254 | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | a00de254 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | a00de254 | Stavros Sachtouris | # disclaimer.
|
10 | a00de254 | Stavros Sachtouris | #
|
11 | a00de254 | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | a00de254 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | a00de254 | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | a00de254 | Stavros Sachtouris | # provided with the distribution.
|
15 | a00de254 | Stavros Sachtouris | #
|
16 | a00de254 | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | a00de254 | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | a00de254 | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | a00de254 | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | a00de254 | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | a00de254 | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | a00de254 | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | a00de254 | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | a00de254 | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | a00de254 | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | a00de254 | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | a00de254 | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | a00de254 | Stavros Sachtouris | #
|
29 | a00de254 | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | a00de254 | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | a00de254 | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | a00de254 | Stavros Sachtouris | # or implied, of GRNET S.A.command
|
33 | a00de254 | Stavros Sachtouris | |
34 | a00de254 | Stavros Sachtouris | from traceback import print_stack, print_exc |
35 | e8d3b957 | Stavros Sachtouris | from astakosclient import AstakosClientException |
36 | a00de254 | Stavros Sachtouris | |
37 | a00de254 | Stavros Sachtouris | from kamaki.clients import ClientError |
38 | dc6fc88e | Stavros Sachtouris | from kamaki.cli.errors import CLIError, raiseCLIError, CLISyntaxError |
39 | a00de254 | Stavros Sachtouris | from kamaki.cli import _debug, kloger |
40 | ca092af4 | Stavros Sachtouris | from kamaki.cli.utils import format_size |
41 | a00de254 | Stavros Sachtouris | |
42 | c626151a | Stavros Sachtouris | CLOUDNAME = [ |
43 | 144b3551 | Stavros Sachtouris | 'Note: If you use a named cloud, use its name instead of "default"']
|
44 | c626151a | Stavros Sachtouris | |
45 | a00de254 | Stavros Sachtouris | |
46 | a00de254 | Stavros Sachtouris | class generic(object): |
47 | a00de254 | Stavros Sachtouris | |
48 | a00de254 | Stavros Sachtouris | @classmethod
|
49 | 392d902d | Stavros Sachtouris | def all(this, func): |
50 | a00de254 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
51 | a00de254 | Stavros Sachtouris | try:
|
52 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
53 | a00de254 | Stavros Sachtouris | except Exception as e: |
54 | a00de254 | Stavros Sachtouris | if _debug:
|
55 | a00de254 | Stavros Sachtouris | print_stack() |
56 | a00de254 | Stavros Sachtouris | print_exc(e) |
57 | 99085b30 | Stavros Sachtouris | if isinstance(e, CLIError) or isinstance(e, ClientError): |
58 | 844a6bdb | Stavros Sachtouris | raiseCLIError(e) |
59 | 844a6bdb | Stavros Sachtouris | raiseCLIError(e, details=['%s, -d for debug info' % type(e)]) |
60 | a00de254 | Stavros Sachtouris | return _raise
|
61 | a00de254 | Stavros Sachtouris | |
62 | a03ade9e | Stavros Sachtouris | @classmethod
|
63 | 392d902d | Stavros Sachtouris | def _connection(this, func): |
64 | a03ade9e | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
65 | a03ade9e | Stavros Sachtouris | try:
|
66 | 392d902d | Stavros Sachtouris | func(self, *args, **kwargs)
|
67 | a03ade9e | Stavros Sachtouris | except ClientError as ce: |
68 | 24ff0a35 | Stavros Sachtouris | ce_msg = ('%s' % ce).lower()
|
69 | a03ade9e | Stavros Sachtouris | if ce.status == 401: |
70 | a03ade9e | Stavros Sachtouris | raiseCLIError(ce, 'Authorization failed', details=[
|
71 | a03ade9e | Stavros Sachtouris | 'Make sure a valid token is provided:',
|
72 | 4018326d | Stavros Sachtouris | ' to check if token is valid: /user authenticate',
|
73 | c626151a | Stavros Sachtouris | ' to set token:',
|
74 | 144b3551 | Stavros Sachtouris | ' /config set cloud.default.token <token>',
|
75 | c626151a | Stavros Sachtouris | ' to get current token:',
|
76 | 144b3551 | Stavros Sachtouris | ' /config get cloud.default.token'] + CLOUDNAME)
|
77 | bb50c4ec | Stavros Sachtouris | elif ce.status in range(-12, 200) + [302, 401, 500]: |
78 | a03ade9e | Stavros Sachtouris | raiseCLIError(ce, importance=3, details=[
|
79 | 819311d3 | Stavros Sachtouris | 'Check if service is up'])
|
80 | 24ff0a35 | Stavros Sachtouris | elif ce.status == 404 and 'kamakihttpresponse' in ce_msg: |
81 | 5a673575 | Stavros Sachtouris | client = getattr(self, 'client', None) |
82 | 5a673575 | Stavros Sachtouris | if not client: |
83 | 5a673575 | Stavros Sachtouris | raise
|
84 | 5a673575 | Stavros Sachtouris | url = getattr(client, 'base_url', '<empty>') |
85 | 031ca67d | Stavros Sachtouris | msg = 'Invalid service URL %s' % url
|
86 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=[ |
87 | 031ca67d | Stavros Sachtouris | 'Check if authentication URL is correct',
|
88 | 031ca67d | Stavros Sachtouris | ' check current URL:',
|
89 | 144b3551 | Stavros Sachtouris | ' /config get cloud.default.url',
|
90 | 031ca67d | Stavros Sachtouris | ' set new authentication URL:',
|
91 | 144b3551 | Stavros Sachtouris | ' /config set cloud.default.url'] + CLOUDNAME)
|
92 | a03ade9e | Stavros Sachtouris | raise
|
93 | a03ade9e | Stavros Sachtouris | return _raise
|
94 | a03ade9e | Stavros Sachtouris | |
95 | a00de254 | Stavros Sachtouris | |
96 | 4018326d | Stavros Sachtouris | class user(object): |
97 | a00de254 | Stavros Sachtouris | |
98 | a00de254 | Stavros Sachtouris | _token_details = [ |
99 | 144b3551 | Stavros Sachtouris | 'To check default token: /config get cloud.default.token',
|
100 | a03ade9e | Stavros Sachtouris | 'If set/update a token:',
|
101 | 144b3551 | Stavros Sachtouris | '* (permanent): /config set cloud.default.token <token>',
|
102 | c626151a | Stavros Sachtouris | '* (temporary): re-run with <token> parameter'] + CLOUDNAME
|
103 | a00de254 | Stavros Sachtouris | |
104 | a00de254 | Stavros Sachtouris | @classmethod
|
105 | 392d902d | Stavros Sachtouris | def astakosclient(this, func): |
106 | e8d3b957 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
107 | e8d3b957 | Stavros Sachtouris | try:
|
108 | 392d902d | Stavros Sachtouris | r = func(self, *args, **kwargs)
|
109 | e8d3b957 | Stavros Sachtouris | except AstakosClientException as ace: |
110 | e8d3b957 | Stavros Sachtouris | raiseCLIError(ace, 'Error in synnefo-AstakosClient')
|
111 | e8d3b957 | Stavros Sachtouris | return r
|
112 | e8d3b957 | Stavros Sachtouris | return _raise
|
113 | e8d3b957 | Stavros Sachtouris | |
114 | e8d3b957 | Stavros Sachtouris | @classmethod
|
115 | 392d902d | Stavros Sachtouris | def load(this, func): |
116 | a00de254 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
117 | 392d902d | Stavros Sachtouris | r = func(self, *args, **kwargs)
|
118 | a00de254 | Stavros Sachtouris | try:
|
119 | a00de254 | Stavros Sachtouris | client = getattr(self, 'client') |
120 | a00de254 | Stavros Sachtouris | except AttributeError as ae: |
121 | a00de254 | Stavros Sachtouris | raiseCLIError(ae, 'Client setup failure', importance=3) |
122 | a00de254 | Stavros Sachtouris | if not getattr(client, 'token', False): |
123 | a00de254 | Stavros Sachtouris | kloger.warning( |
124 | c626151a | Stavros Sachtouris | 'No permanent token (try:'
|
125 | 144b3551 | Stavros Sachtouris | ' kamaki config set cloud.default.token <tkn>)')
|
126 | e8d3b957 | Stavros Sachtouris | if not getattr(client, 'astakos_base_url', False): |
127 | c626151a | Stavros Sachtouris | msg = 'Missing synnefo authentication URL'
|
128 | de73876b | Stavros Sachtouris | raise CLIError(msg, importance=3, details=[ |
129 | 031ca67d | Stavros Sachtouris | 'Check if authentication URL is correct',
|
130 | 031ca67d | Stavros Sachtouris | ' check current URL:',
|
131 | 144b3551 | Stavros Sachtouris | ' /config get cloud.default.url',
|
132 | 031ca67d | Stavros Sachtouris | ' set new auth. URL:',
|
133 | 144b3551 | Stavros Sachtouris | ' /config set cloud.default.url'] + CLOUDNAME)
|
134 | a00de254 | Stavros Sachtouris | return r
|
135 | a00de254 | Stavros Sachtouris | return _raise
|
136 | a00de254 | Stavros Sachtouris | |
137 | a00de254 | Stavros Sachtouris | @classmethod
|
138 | 392d902d | Stavros Sachtouris | def authenticate(this, func): |
139 | a00de254 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
140 | a00de254 | Stavros Sachtouris | try:
|
141 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
142 | e8d3b957 | Stavros Sachtouris | except (ClientError, AstakosClientException) as ce: |
143 | a00de254 | Stavros Sachtouris | if ce.status == 401: |
144 | a00de254 | Stavros Sachtouris | token = kwargs.get('custom_token', 0) or self.client.token |
145 | e8d3b957 | Stavros Sachtouris | msg = ('Authorization failed for token %s' % token) if ( |
146 | e8d3b957 | Stavros Sachtouris | token) else 'No token provided', |
147 | de73876b | Stavros Sachtouris | details = [] if token else this._token_details |
148 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=details) |
149 | 82e32e50 | Stavros Sachtouris | raise ce
|
150 | 392d902d | Stavros Sachtouris | self._raise = func
|
151 | a00de254 | Stavros Sachtouris | return _raise
|
152 | dc6fc88e | Stavros Sachtouris | |
153 | dc6fc88e | Stavros Sachtouris | |
154 | dc6fc88e | Stavros Sachtouris | class history(object): |
155 | dc6fc88e | Stavros Sachtouris | @classmethod
|
156 | 392d902d | Stavros Sachtouris | def init(this, func): |
157 | dc6fc88e | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
158 | 392d902d | Stavros Sachtouris | r = func(self, *args, **kwargs)
|
159 | dc6fc88e | Stavros Sachtouris | if not hasattr(self, 'history'): |
160 | dc6fc88e | Stavros Sachtouris | raise CLIError('Failed to load history', importance=2) |
161 | dc6fc88e | Stavros Sachtouris | return r
|
162 | dc6fc88e | Stavros Sachtouris | return _raise
|
163 | dc6fc88e | Stavros Sachtouris | |
164 | dc6fc88e | Stavros Sachtouris | @classmethod
|
165 | 392d902d | Stavros Sachtouris | def _get_cmd_ids(this, func): |
166 | dc6fc88e | Stavros Sachtouris | def _raise(self, cmd_ids, *args, **kwargs): |
167 | dc6fc88e | Stavros Sachtouris | if not cmd_ids: |
168 | de73876b | Stavros Sachtouris | raise CLISyntaxError(
|
169 | de73876b | Stavros Sachtouris | 'Usage: <id1|id1-id2> [id3|id3-id4] ...',
|
170 | dc6fc88e | Stavros Sachtouris | details=self.__doc__.split('\n')) |
171 | 392d902d | Stavros Sachtouris | return func(self, cmd_ids, *args, **kwargs) |
172 | dc6fc88e | Stavros Sachtouris | return _raise
|
173 | dc6fc88e | Stavros Sachtouris | |
174 | a03ade9e | Stavros Sachtouris | |
175 | a03ade9e | Stavros Sachtouris | class cyclades(object): |
176 | b04288f7 | Stavros Sachtouris | about_flavor_id = [ |
177 | b04288f7 | Stavros Sachtouris | 'How to pick a valid flavor id:',
|
178 | b04288f7 | Stavros Sachtouris | '* get a list of flavor ids: /flavor list',
|
179 | b04288f7 | Stavros Sachtouris | '* details of flavor: /flavor info <flavor id>']
|
180 | b04288f7 | Stavros Sachtouris | |
181 | 5a673575 | Stavros Sachtouris | about_network_id = [ |
182 | 5a673575 | Stavros Sachtouris | 'How to pick a valid network id:',
|
183 | 5a673575 | Stavros Sachtouris | '* get a list of network ids: /network list',
|
184 | 5a673575 | Stavros Sachtouris | '* details of network: /network info <network id>']
|
185 | 5a673575 | Stavros Sachtouris | |
186 | cd0927f7 | Stavros Sachtouris | net_types = ('CUSTOM', 'MAC_FILTERED', 'IP_LESS_ROUTED', 'PHYSICAL_VLAN') |
187 | cd0927f7 | Stavros Sachtouris | |
188 | a03ade9e | Stavros Sachtouris | @classmethod
|
189 | 392d902d | Stavros Sachtouris | def connection(this, func): |
190 | 392d902d | Stavros Sachtouris | return generic._connection(func)
|
191 | a03ade9e | Stavros Sachtouris | |
192 | b04288f7 | Stavros Sachtouris | @classmethod
|
193 | 392d902d | Stavros Sachtouris | def date(this, func): |
194 | b04288f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
195 | b04288f7 | Stavros Sachtouris | try:
|
196 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
197 | b04288f7 | Stavros Sachtouris | except ClientError as ce: |
198 | b04288f7 | Stavros Sachtouris | if ce.status == 400 and 'changes-since' in ('%s' % ce): |
199 | b04288f7 | Stavros Sachtouris | raise CLIError(
|
200 | b04288f7 | Stavros Sachtouris | 'Incorrect date format for --since',
|
201 | b04288f7 | Stavros Sachtouris | details=['Accepted date format: d/m/y'])
|
202 | b04288f7 | Stavros Sachtouris | raise
|
203 | b04288f7 | Stavros Sachtouris | return _raise
|
204 | b04288f7 | Stavros Sachtouris | |
205 | b04288f7 | Stavros Sachtouris | @classmethod
|
206 | 392d902d | Stavros Sachtouris | def cluster_size(this, func): |
207 | b8352ce4 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
208 | b8352ce4 | Stavros Sachtouris | size = kwargs.get('size', None) |
209 | b8352ce4 | Stavros Sachtouris | try:
|
210 | b8352ce4 | Stavros Sachtouris | size = int(size)
|
211 | b8352ce4 | Stavros Sachtouris | assert size > 0, 'Cluster size must be a positive integer' |
212 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
213 | b8352ce4 | Stavros Sachtouris | except ValueError as ve: |
214 | b8352ce4 | Stavros Sachtouris | msg = 'Invalid cluster size value %s' % size
|
215 | b8352ce4 | Stavros Sachtouris | raiseCLIError(ve, msg, importance=1, details=[
|
216 | b8352ce4 | Stavros Sachtouris | 'Cluster size must be a positive integer'])
|
217 | b8352ce4 | Stavros Sachtouris | except AssertionError as ae: |
218 | b8352ce4 | Stavros Sachtouris | raiseCLIError( |
219 | b8352ce4 | Stavros Sachtouris | ae, 'Invalid cluster size %s' % size, importance=1) |
220 | b8352ce4 | Stavros Sachtouris | except ClientError:
|
221 | b8352ce4 | Stavros Sachtouris | raise
|
222 | b8352ce4 | Stavros Sachtouris | return _raise
|
223 | b8352ce4 | Stavros Sachtouris | |
224 | b8352ce4 | Stavros Sachtouris | @classmethod
|
225 | 392d902d | Stavros Sachtouris | def network_id(this, func): |
226 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
227 | 5a673575 | Stavros Sachtouris | network_id = kwargs.get('network_id', None) |
228 | 5a673575 | Stavros Sachtouris | try:
|
229 | 5a673575 | Stavros Sachtouris | network_id = int(network_id)
|
230 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
231 | 5a673575 | Stavros Sachtouris | except ValueError as ve: |
232 | de73876b | Stavros Sachtouris | msg = 'Invalid network id %s ' % network_id
|
233 | 81c60832 | Stavros Sachtouris | details = 'network id must be a positive integer'
|
234 | de73876b | Stavros Sachtouris | raiseCLIError(ve, msg, details=details, importance=1)
|
235 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
236 | de73876b | Stavros Sachtouris | if network_id and ce.status == 404 and ( |
237 | de73876b | Stavros Sachtouris | 'network' in ('%s' % ce).lower() |
238 | de73876b | Stavros Sachtouris | ): |
239 | de73876b | Stavros Sachtouris | msg = 'No network with id %s found' % network_id,
|
240 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.about_network_id) |
241 | 5a673575 | Stavros Sachtouris | raise
|
242 | 5a673575 | Stavros Sachtouris | return _raise
|
243 | 5a673575 | Stavros Sachtouris | |
244 | 5a673575 | Stavros Sachtouris | @classmethod
|
245 | 392d902d | Stavros Sachtouris | def network_type(this, func): |
246 | cd0927f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
247 | cd0927f7 | Stavros Sachtouris | network_type = kwargs.get('network_type', None) |
248 | cd0927f7 | Stavros Sachtouris | msg = 'Invalid network type %s.\nValid types: %s' % (
|
249 | 0e27687b | Stavros Sachtouris | network_type, ' '.join(this.net_types))
|
250 | cd0927f7 | Stavros Sachtouris | assert network_type in this.net_types, msg |
251 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
252 | cd0927f7 | Stavros Sachtouris | return _raise
|
253 | cd0927f7 | Stavros Sachtouris | |
254 | cd0927f7 | Stavros Sachtouris | @classmethod
|
255 | 392d902d | Stavros Sachtouris | def network_max(this, func): |
256 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
257 | 5a673575 | Stavros Sachtouris | try:
|
258 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
259 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
260 | 5a673575 | Stavros Sachtouris | if ce.status == 413: |
261 | de73876b | Stavros Sachtouris | msg = 'Cannot create another network',
|
262 | 24ff0a35 | Stavros Sachtouris | details = [ |
263 | 24ff0a35 | Stavros Sachtouris | 'Maximum number of networks reached',
|
264 | de73876b | Stavros Sachtouris | '* to get a list of networks: /network list',
|
265 | de73876b | Stavros Sachtouris | '* to delete a network: /network delete <net id>']
|
266 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=details) |
267 | 5a673575 | Stavros Sachtouris | raise
|
268 | 5a673575 | Stavros Sachtouris | return _raise
|
269 | 5a673575 | Stavros Sachtouris | |
270 | 5a673575 | Stavros Sachtouris | @classmethod
|
271 | 392d902d | Stavros Sachtouris | def network_in_use(this, func): |
272 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
273 | 5a673575 | Stavros Sachtouris | network_id = kwargs.get('network_id', None) |
274 | 5a673575 | Stavros Sachtouris | try:
|
275 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
276 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
277 | ef3488a7 | Stavros Sachtouris | if network_id and ce.status in (400, ): |
278 | de73876b | Stavros Sachtouris | msg = 'Network with id %s does not exist' % network_id,
|
279 | 08aad6db | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.about_network_id) |
280 | ef3488a7 | Stavros Sachtouris | elif network_id or ce.status in (421, ): |
281 | de73876b | Stavros Sachtouris | msg = 'Network with id %s is in use' % network_id,
|
282 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=[ |
283 | 2bd23362 | Stavros Sachtouris | 'Disconnect all nics/servers of this network first',
|
284 | de73876b | Stavros Sachtouris | '* to get nics: /network info %s' % network_id,
|
285 | de73876b | Stavros Sachtouris | '. (under "attachments" section)',
|
286 | de73876b | Stavros Sachtouris | '* to disconnect: /network disconnect <nic id>'])
|
287 | 5a673575 | Stavros Sachtouris | raise
|
288 | 5a673575 | Stavros Sachtouris | return _raise
|
289 | 5a673575 | Stavros Sachtouris | |
290 | 5a673575 | Stavros Sachtouris | @classmethod
|
291 | 392d902d | Stavros Sachtouris | def flavor_id(this, func): |
292 | b04288f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
293 | b04288f7 | Stavros Sachtouris | flavor_id = kwargs.get('flavor_id', None) |
294 | b04288f7 | Stavros Sachtouris | try:
|
295 | b04288f7 | Stavros Sachtouris | flavor_id = int(flavor_id)
|
296 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
297 | b04288f7 | Stavros Sachtouris | except ValueError as ve: |
298 | de73876b | Stavros Sachtouris | msg = 'Invalid flavor id %s ' % flavor_id,
|
299 | 81c60832 | Stavros Sachtouris | details = 'Flavor id must be a positive integer'
|
300 | de73876b | Stavros Sachtouris | raiseCLIError(ve, msg, details=details, importance=1)
|
301 | b04288f7 | Stavros Sachtouris | except ClientError as ce: |
302 | de73876b | Stavros Sachtouris | if flavor_id and ce.status == 404 and ( |
303 | de73876b | Stavros Sachtouris | 'flavor' in ('%s' % ce).lower() |
304 | de73876b | Stavros Sachtouris | ): |
305 | de73876b | Stavros Sachtouris | msg = 'No flavor with id %s found' % flavor_id,
|
306 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.about_flavor_id) |
307 | b04288f7 | Stavros Sachtouris | raise
|
308 | b04288f7 | Stavros Sachtouris | return _raise
|
309 | b04288f7 | Stavros Sachtouris | |
310 | b04288f7 | Stavros Sachtouris | @classmethod
|
311 | 392d902d | Stavros Sachtouris | def server_id(this, func): |
312 | b04288f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
313 | b04288f7 | Stavros Sachtouris | server_id = kwargs.get('server_id', None) |
314 | b04288f7 | Stavros Sachtouris | try:
|
315 | b04288f7 | Stavros Sachtouris | server_id = int(server_id)
|
316 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
317 | b04288f7 | Stavros Sachtouris | except ValueError as ve: |
318 | 2bd23362 | Stavros Sachtouris | msg = 'Invalid virtual server id %s' % server_id,
|
319 | 81c60832 | Stavros Sachtouris | details = 'Server id must be a positive integer'
|
320 | de73876b | Stavros Sachtouris | raiseCLIError(ve, msg, details=details, importance=1)
|
321 | b04288f7 | Stavros Sachtouris | except ClientError as ce: |
322 | 5a673575 | Stavros Sachtouris | err_msg = ('%s' % ce).lower()
|
323 | de73876b | Stavros Sachtouris | if (
|
324 | de73876b | Stavros Sachtouris | ce.status == 404 and 'server' in err_msg |
325 | de73876b | Stavros Sachtouris | ) or (
|
326 | de73876b | Stavros Sachtouris | ce.status == 400 and 'not found' in err_msg |
327 | de73876b | Stavros Sachtouris | ): |
328 | 2bd23362 | Stavros Sachtouris | msg = 'virtual server with id %s not found' % server_id,
|
329 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=[ |
330 | 2bd23362 | Stavros Sachtouris | '* to get ids of all servers: /server list',
|
331 | 2bd23362 | Stavros Sachtouris | '* to get server details: /server info <server id>'])
|
332 | 5a673575 | Stavros Sachtouris | raise
|
333 | 5a673575 | Stavros Sachtouris | return _raise
|
334 | 5a673575 | Stavros Sachtouris | |
335 | 5a673575 | Stavros Sachtouris | @classmethod
|
336 | 392d902d | Stavros Sachtouris | def firewall(this, func): |
337 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
338 | 5a673575 | Stavros Sachtouris | profile = kwargs.get('profile', None) |
339 | 5a673575 | Stavros Sachtouris | try:
|
340 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
341 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
342 | de73876b | Stavros Sachtouris | if ce.status == 400 and profile and ( |
343 | de73876b | Stavros Sachtouris | 'firewall' in ('%s' % ce).lower() |
344 | de73876b | Stavros Sachtouris | ): |
345 | de73876b | Stavros Sachtouris | msg = '%s is an invalid firewall profile term' % profile
|
346 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=[ |
347 | de73876b | Stavros Sachtouris | 'Try one of the following:',
|
348 | de73876b | Stavros Sachtouris | '* DISABLED: Shutdown firewall',
|
349 | de73876b | Stavros Sachtouris | '* ENABLED: Firewall in normal mode',
|
350 | de73876b | Stavros Sachtouris | '* PROTECTED: Firewall in secure mode'])
|
351 | 5a673575 | Stavros Sachtouris | raise
|
352 | 5a673575 | Stavros Sachtouris | return _raise
|
353 | 5a673575 | Stavros Sachtouris | |
354 | 5a673575 | Stavros Sachtouris | @classmethod
|
355 | 392d902d | Stavros Sachtouris | def nic_id(this, func): |
356 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
357 | 5a673575 | Stavros Sachtouris | try:
|
358 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
359 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
360 | 5a673575 | Stavros Sachtouris | nic_id = kwargs.get('nic_id', None) |
361 | de73876b | Stavros Sachtouris | if nic_id and ce.status == 404 and ( |
362 | de73876b | Stavros Sachtouris | 'network interface' in ('%s' % ce).lower() |
363 | de73876b | Stavros Sachtouris | ): |
364 | 5a673575 | Stavros Sachtouris | server_id = kwargs.get('server_id', '<no server>') |
365 | 2bd23362 | Stavros Sachtouris | err_msg = 'No nic %s on virtual server with id %s' % (
|
366 | 5a673575 | Stavros Sachtouris | nic_id, |
367 | 5a673575 | Stavros Sachtouris | server_id) |
368 | 5a673575 | Stavros Sachtouris | raiseCLIError(ce, err_msg, details=[ |
369 | 2bd23362 | Stavros Sachtouris | '* check v. server with id %s: /server info %s' % (
|
370 | 5a673575 | Stavros Sachtouris | server_id, |
371 | 5a673575 | Stavros Sachtouris | server_id), |
372 | 2bd23362 | Stavros Sachtouris | '* list nics for v. server with id %s:' % server_id,
|
373 | 5a673575 | Stavros Sachtouris | ' /server addr %s' % server_id])
|
374 | 5a673575 | Stavros Sachtouris | raise
|
375 | 5a673575 | Stavros Sachtouris | return _raise
|
376 | 5a673575 | Stavros Sachtouris | |
377 | 5a673575 | Stavros Sachtouris | @classmethod
|
378 | 392d902d | Stavros Sachtouris | def nic_format(this, func): |
379 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
380 | 5a673575 | Stavros Sachtouris | try:
|
381 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
382 | 5a673575 | Stavros Sachtouris | except IndexError as ie: |
383 | 5a673575 | Stavros Sachtouris | nic_id = kwargs.get('nic_id', None) |
384 | de73876b | Stavros Sachtouris | msg = 'Invalid format for network interface (nic) %s' % nic_id
|
385 | de73876b | Stavros Sachtouris | raiseCLIError(ie, msg, importance=1, details=[
|
386 | de73876b | Stavros Sachtouris | 'nid_id format: nic-<server id>-<nic id>',
|
387 | de73876b | Stavros Sachtouris | '* get nics of a network: /network info <net id>',
|
388 | de73876b | Stavros Sachtouris | ' (listed the "attachments" section)'])
|
389 | 5a673575 | Stavros Sachtouris | return _raise
|
390 | 5a673575 | Stavros Sachtouris | |
391 | 5a673575 | Stavros Sachtouris | @classmethod
|
392 | 392d902d | Stavros Sachtouris | def metadata(this, func): |
393 | 5a673575 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
394 | 5a673575 | Stavros Sachtouris | key = kwargs.get('key', None) |
395 | 5a673575 | Stavros Sachtouris | try:
|
396 | 392d902d | Stavros Sachtouris | func(self, *args, **kwargs)
|
397 | 5a673575 | Stavros Sachtouris | except ClientError as ce: |
398 | de73876b | Stavros Sachtouris | if key and ce.status == 404 and ( |
399 | de73876b | Stavros Sachtouris | 'metadata' in ('%s' % ce).lower() |
400 | de73876b | Stavros Sachtouris | ): |
401 | 2bd23362 | Stavros Sachtouris | raiseCLIError( |
402 | 0b052394 | Stavros Sachtouris | ce, 'No virtual server metadata with key %s' % key)
|
403 | b04288f7 | Stavros Sachtouris | raise
|
404 | b04288f7 | Stavros Sachtouris | return _raise
|
405 | b04288f7 | Stavros Sachtouris | |
406 | a03ade9e | Stavros Sachtouris | |
407 | a03ade9e | Stavros Sachtouris | class plankton(object): |
408 | a03ade9e | Stavros Sachtouris | |
409 | de73876b | Stavros Sachtouris | about_image_id = [ |
410 | de73876b | Stavros Sachtouris | 'How to pick a suitable image:',
|
411 | b04288f7 | Stavros Sachtouris | '* get a list of image ids: /image list',
|
412 | 67083ca0 | Stavros Sachtouris | '* details of image: /image meta <image id>']
|
413 | a03ade9e | Stavros Sachtouris | |
414 | a03ade9e | Stavros Sachtouris | @classmethod
|
415 | 392d902d | Stavros Sachtouris | def connection(this, func): |
416 | 392d902d | Stavros Sachtouris | return generic._connection(func)
|
417 | a03ade9e | Stavros Sachtouris | |
418 | a03ade9e | Stavros Sachtouris | @classmethod
|
419 | 392d902d | Stavros Sachtouris | def id(this, func): |
420 | b04288f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
421 | b04288f7 | Stavros Sachtouris | image_id = kwargs.get('image_id', None) |
422 | a03ade9e | Stavros Sachtouris | try:
|
423 | 392d902d | Stavros Sachtouris | func(self, *args, **kwargs)
|
424 | a03ade9e | Stavros Sachtouris | except ClientError as ce: |
425 | de73876b | Stavros Sachtouris | if image_id and ( |
426 | de73876b | Stavros Sachtouris | ce.status == 404
|
427 | de73876b | Stavros Sachtouris | or (
|
428 | de73876b | Stavros Sachtouris | ce.status == 400
|
429 | de73876b | Stavros Sachtouris | and 'image not found' in ('%s' % ce).lower()) |
430 | de73876b | Stavros Sachtouris | or ce.status == 411 |
431 | de73876b | Stavros Sachtouris | ): |
432 | de73876b | Stavros Sachtouris | msg = 'No image with id %s found' % image_id
|
433 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.about_image_id) |
434 | 236e7d08 | Stavros Sachtouris | raise
|
435 | 236e7d08 | Stavros Sachtouris | return _raise
|
436 | 236e7d08 | Stavros Sachtouris | |
437 | 236e7d08 | Stavros Sachtouris | @classmethod
|
438 | 392d902d | Stavros Sachtouris | def metadata(this, func): |
439 | b04288f7 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
440 | b04288f7 | Stavros Sachtouris | key = kwargs.get('key', None) |
441 | 236e7d08 | Stavros Sachtouris | try:
|
442 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
443 | 236e7d08 | Stavros Sachtouris | except ClientError as ce: |
444 | 24ff0a35 | Stavros Sachtouris | ce_msg = ('%s' % ce).lower()
|
445 | de73876b | Stavros Sachtouris | if ce.status == 404 or ( |
446 | 2005b18e | Stavros Sachtouris | ce.status == 400 and 'metadata' in ce_msg): |
447 | 2005b18e | Stavros Sachtouris | msg = 'No properties with key %s in this image' % key
|
448 | 2005b18e | Stavros Sachtouris | raiseCLIError(ce, msg) |
449 | a03ade9e | Stavros Sachtouris | raise
|
450 | a03ade9e | Stavros Sachtouris | return _raise
|
451 | 1395c40e | Stavros Sachtouris | |
452 | 1395c40e | Stavros Sachtouris | |
453 | 1395c40e | Stavros Sachtouris | class pithos(object): |
454 | de73876b | Stavros Sachtouris | container_howto = [ |
455 | 24ff0a35 | Stavros Sachtouris | 'To specify a container:',
|
456 | c626151a | Stavros Sachtouris | ' 1. --container=<container> (temporary, overrides all)',
|
457 | c626151a | Stavros Sachtouris | ' 2. Use the container:path format (temporary, overrides 3)',
|
458 | c626151a | Stavros Sachtouris | ' 3. Set pithos_container variable (permanent)',
|
459 | c626151a | Stavros Sachtouris | ' /config set pithos_container <container>',
|
460 | 3ae60112 | Stavros Sachtouris | 'For a list of containers: /file list']
|
461 | 1395c40e | Stavros Sachtouris | |
462 | 1395c40e | Stavros Sachtouris | @classmethod
|
463 | 392d902d | Stavros Sachtouris | def connection(this, func): |
464 | 392d902d | Stavros Sachtouris | return generic._connection(func)
|
465 | 1395c40e | Stavros Sachtouris | |
466 | 1395c40e | Stavros Sachtouris | @classmethod
|
467 | 392d902d | Stavros Sachtouris | def account(this, func): |
468 | 300da0fb | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
469 | 300da0fb | Stavros Sachtouris | try:
|
470 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
471 | 300da0fb | Stavros Sachtouris | except ClientError as ce: |
472 | 300da0fb | Stavros Sachtouris | if ce.status == 403: |
473 | 300da0fb | Stavros Sachtouris | raiseCLIError( |
474 | 300da0fb | Stavros Sachtouris | ce, |
475 | 300da0fb | Stavros Sachtouris | 'Invalid account credentials for this operation',
|
476 | 300da0fb | Stavros Sachtouris | details=['Check user account settings'])
|
477 | 300da0fb | Stavros Sachtouris | raise
|
478 | 300da0fb | Stavros Sachtouris | return _raise
|
479 | 300da0fb | Stavros Sachtouris | |
480 | 300da0fb | Stavros Sachtouris | @classmethod
|
481 | 392d902d | Stavros Sachtouris | def quota(this, func): |
482 | 1395c40e | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
483 | 1395c40e | Stavros Sachtouris | try:
|
484 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
485 | 1395c40e | Stavros Sachtouris | except ClientError as ce: |
486 | 1395c40e | Stavros Sachtouris | if ce.status == 413: |
487 | 1395c40e | Stavros Sachtouris | raiseCLIError(ce, 'User quota exceeded', details=[
|
488 | 1395c40e | Stavros Sachtouris | '* get quotas:',
|
489 | 3ae60112 | Stavros Sachtouris | ' * upper total limit: /file quota',
|
490 | c626151a | Stavros Sachtouris | ' * container limit:',
|
491 | c626151a | Stavros Sachtouris | ' /file containerlimit get <container>',
|
492 | c626151a | Stavros Sachtouris | '* set a higher container limit:',
|
493 | c626151a | Stavros Sachtouris | ' /file containerlimit set <limit> <container>'])
|
494 | 1395c40e | Stavros Sachtouris | raise
|
495 | 1395c40e | Stavros Sachtouris | return _raise
|
496 | 1395c40e | Stavros Sachtouris | |
497 | 1395c40e | Stavros Sachtouris | @classmethod
|
498 | 392d902d | Stavros Sachtouris | def container(this, func): |
499 | 1395c40e | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
500 | 1395c40e | Stavros Sachtouris | dst_cont = kwargs.get('dst_cont', None) |
501 | 1395c40e | Stavros Sachtouris | try:
|
502 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
503 | 1395c40e | Stavros Sachtouris | except ClientError as ce: |
504 | 1395c40e | Stavros Sachtouris | if ce.status == 404 and 'container' in ('%s' % ce).lower(): |
505 | de73876b | Stavros Sachtouris | cont = ('%s or %s' % (
|
506 | de73876b | Stavros Sachtouris | self.container,
|
507 | de73876b | Stavros Sachtouris | dst_cont)) if dst_cont else self.container |
508 | de73876b | Stavros Sachtouris | msg = 'Is container %s in current account?' % (cont),
|
509 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.container_howto) |
510 | 1395c40e | Stavros Sachtouris | raise
|
511 | 1395c40e | Stavros Sachtouris | return _raise
|
512 | 1395c40e | Stavros Sachtouris | |
513 | 1395c40e | Stavros Sachtouris | @classmethod
|
514 | 392d902d | Stavros Sachtouris | def local_path_download(this, func): |
515 | 606f5b54 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
516 | 606f5b54 | Stavros Sachtouris | try:
|
517 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
518 | 606f5b54 | Stavros Sachtouris | except IOError as ioe: |
519 | 60bcb377 | Stavros Sachtouris | msg = 'Failed to access a local file',
|
520 | 606f5b54 | Stavros Sachtouris | raiseCLIError(ioe, msg, importance=2, details=[
|
521 | 606f5b54 | Stavros Sachtouris | 'Check if the file exists. Also check if the remote',
|
522 | 606f5b54 | Stavros Sachtouris | 'directories exist. All directories in a remote path',
|
523 | 606f5b54 | Stavros Sachtouris | 'must exist to succesfully download a container or a',
|
524 | 606f5b54 | Stavros Sachtouris | 'directory.',
|
525 | 606f5b54 | Stavros Sachtouris | 'To create a remote directory:',
|
526 | 606f5b54 | Stavros Sachtouris | ' [kamaki] file mkdir REMOTE_DIRECTORY_PATH'])
|
527 | 606f5b54 | Stavros Sachtouris | return _raise
|
528 | 606f5b54 | Stavros Sachtouris | |
529 | 606f5b54 | Stavros Sachtouris | @classmethod
|
530 | 392d902d | Stavros Sachtouris | def local_path(this, func): |
531 | 68858765 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
532 | edc1182f | Stavros Sachtouris | local_path = kwargs.get('local_path', None) |
533 | 68858765 | Stavros Sachtouris | try:
|
534 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
535 | 68858765 | Stavros Sachtouris | except IOError as ioe: |
536 | de73876b | Stavros Sachtouris | msg = 'Failed to access file %s' % local_path,
|
537 | de73876b | Stavros Sachtouris | raiseCLIError(ioe, msg, importance=2)
|
538 | 68858765 | Stavros Sachtouris | return _raise
|
539 | 68858765 | Stavros Sachtouris | |
540 | 68858765 | Stavros Sachtouris | @classmethod
|
541 | 392d902d | Stavros Sachtouris | def object_path(this, func): |
542 | 1395c40e | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
543 | 1395c40e | Stavros Sachtouris | try:
|
544 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
545 | 1395c40e | Stavros Sachtouris | except ClientError as ce: |
546 | 1395c40e | Stavros Sachtouris | err_msg = ('%s' % ce).lower()
|
547 | de73876b | Stavros Sachtouris | if (
|
548 | de73876b | Stavros Sachtouris | ce.status == 404 or ce.status == 500 |
549 | de73876b | Stavros Sachtouris | ) and 'object' in err_msg and 'not' in err_msg: |
550 | de73876b | Stavros Sachtouris | msg = 'No object %s in container %s' % (
|
551 | de73876b | Stavros Sachtouris | self.path,
|
552 | de73876b | Stavros Sachtouris | self.container)
|
553 | de73876b | Stavros Sachtouris | raiseCLIError(ce, msg, details=this.container_howto) |
554 | 1395c40e | Stavros Sachtouris | raise
|
555 | 1395c40e | Stavros Sachtouris | return _raise
|
556 | ca092af4 | Stavros Sachtouris | |
557 | ca092af4 | Stavros Sachtouris | @classmethod
|
558 | 392d902d | Stavros Sachtouris | def object_size(this, func): |
559 | ca092af4 | Stavros Sachtouris | def _raise(self, *args, **kwargs): |
560 | ca092af4 | Stavros Sachtouris | size = kwargs.get('size', None) |
561 | ca092af4 | Stavros Sachtouris | start = kwargs.get('start', 0) |
562 | ca092af4 | Stavros Sachtouris | end = kwargs.get('end', 0) |
563 | ca092af4 | Stavros Sachtouris | if size:
|
564 | ca092af4 | Stavros Sachtouris | try:
|
565 | ca092af4 | Stavros Sachtouris | size = int(size)
|
566 | ca092af4 | Stavros Sachtouris | except ValueError as ve: |
567 | de73876b | Stavros Sachtouris | msg = 'Invalid file size %s ' % size
|
568 | de73876b | Stavros Sachtouris | details = ['size must be a positive integer']
|
569 | de73876b | Stavros Sachtouris | raiseCLIError(ve, msg, details=details, importance=1)
|
570 | ca092af4 | Stavros Sachtouris | else:
|
571 | ca092af4 | Stavros Sachtouris | try:
|
572 | ca092af4 | Stavros Sachtouris | start = int(start)
|
573 | ca092af4 | Stavros Sachtouris | except ValueError as e: |
574 | de73876b | Stavros Sachtouris | msg = 'Invalid start value %s in range' % start,
|
575 | de73876b | Stavros Sachtouris | details = ['size must be a positive integer'],
|
576 | de73876b | Stavros Sachtouris | raiseCLIError(e, msg, details=details, importance=1)
|
577 | ca092af4 | Stavros Sachtouris | try:
|
578 | ca092af4 | Stavros Sachtouris | end = int(end)
|
579 | ca092af4 | Stavros Sachtouris | except ValueError as e: |
580 | de73876b | Stavros Sachtouris | msg = 'Invalid end value %s in range' % end
|
581 | de73876b | Stavros Sachtouris | details = ['size must be a positive integer']
|
582 | de73876b | Stavros Sachtouris | raiseCLIError(e, msg, details=details, importance=1)
|
583 | ca092af4 | Stavros Sachtouris | if start > end:
|
584 | ca092af4 | Stavros Sachtouris | raiseCLIError( |
585 | ca092af4 | Stavros Sachtouris | 'Invalid range %s-%s' % (start, end),
|
586 | ca092af4 | Stavros Sachtouris | details=['size must be a positive integer'],
|
587 | ca092af4 | Stavros Sachtouris | importance=1)
|
588 | ca092af4 | Stavros Sachtouris | size = end - start |
589 | ca092af4 | Stavros Sachtouris | try:
|
590 | 392d902d | Stavros Sachtouris | return func(self, *args, **kwargs) |
591 | ca092af4 | Stavros Sachtouris | except ClientError as ce: |
592 | ca092af4 | Stavros Sachtouris | err_msg = ('%s' % ce).lower()
|
593 | 24ff0a35 | Stavros Sachtouris | expected = 'object length is smaller than range length'
|
594 | 24ff0a35 | Stavros Sachtouris | if size and ( |
595 | 24ff0a35 | Stavros Sachtouris | ce.status == 416 or ( |
596 | 24ff0a35 | Stavros Sachtouris | ce.status == 400 and expected in err_msg)): |
597 | de73876b | Stavros Sachtouris | raiseCLIError(ce, 'Remote object %s:%s <= %s %s' % (
|
598 | 24ff0a35 | Stavros Sachtouris | self.container, self.path, format_size(size), |
599 | 24ff0a35 | Stavros Sachtouris | ('(%sB)' % size) if size >= 1024 else '')) |
600 | ca092af4 | Stavros Sachtouris | raise
|
601 | ca092af4 | Stavros Sachtouris | return _raise |