Revision 1395c40e kamaki/cli/commands/errors.py
b/kamaki/cli/commands/errors.py | ||
---|---|---|
70 | 70 |
' to check if token is valid: /astakos authenticate', |
71 | 71 |
' to set token: /config set [.server.]token <token>', |
72 | 72 |
' to get current token: /config get [server.]token']) |
73 |
elif ce.status in range(-12, 200) + [403, 302, 500]:
|
|
73 |
elif ce.status in range(-12, 200) + [302, 401, 403, 500]:
|
|
74 | 74 |
raiseCLIError(ce, importance=3, details=[ |
75 | 75 |
'Check if service is up or set to url %s' % base_url, |
76 | 76 |
' to get url: /config get %s' % base_url, |
... | ... | |
391 | 391 |
'No properties with key %s in this image' % key) |
392 | 392 |
raise |
393 | 393 |
return _raise |
394 |
|
|
395 |
|
|
396 |
class pithos(object): |
|
397 |
container_howto = ['To specify a container:', |
|
398 |
' 1. Set store.container variable (permanent)', |
|
399 |
' /config set store.container <container>', |
|
400 |
' 2. --container=<container> (temporary, overrides 1)', |
|
401 |
' 3. Use the container:path format (temporary, overrides all)'] |
|
402 |
|
|
403 |
@classmethod |
|
404 |
def connection(this, foo): |
|
405 |
return generic._connection(foo, 'store.url') |
|
406 |
|
|
407 |
@classmethod |
|
408 |
def quota(this, foo): |
|
409 |
def _raise(self, *args, **kwargs): |
|
410 |
try: |
|
411 |
return foo(self, *args, **kwargs) |
|
412 |
except ClientError as ce: |
|
413 |
if ce.status == 413: |
|
414 |
raiseCLIError(ce, 'User quota exceeded', details=[ |
|
415 |
'* get quotas:', |
|
416 |
' * upper total limit: /store quota', |
|
417 |
' * container limit: /store quota <container>', |
|
418 |
'* set a higher quota (if permitted):', |
|
419 |
' /store setquota <quota>[unit] <container>' |
|
420 |
' as long as <container quota> <= <total quota>']) |
|
421 |
raise |
|
422 |
return _raise |
|
423 |
|
|
424 |
@classmethod |
|
425 |
def container(this, foo): |
|
426 |
def _raise(self, *args, **kwargs): |
|
427 |
dst_cont = kwargs.get('dst_cont', None) |
|
428 |
try: |
|
429 |
return foo(self, *args, **kwargs) |
|
430 |
except ClientError as ce: |
|
431 |
if ce.status == 404 and 'container' in ('%s' % ce).lower(): |
|
432 |
cont = '%s or %s' if dst_cont else self.container |
|
433 |
raiseCLIError(ce, |
|
434 |
'No container %s in account %s' % ( |
|
435 |
cont, |
|
436 |
self.account), |
|
437 |
details=this.container_howto) |
|
438 |
raise |
|
439 |
return _raise |
|
440 |
|
|
441 |
@classmethod |
|
442 |
def object_path(this, foo): |
|
443 |
def _raise(self, *args, **kwargs): |
|
444 |
try: |
|
445 |
return foo(self, *args, **kwargs) |
|
446 |
except ClientError as ce: |
|
447 |
err_msg = ('%s' % ce).lower() |
|
448 |
if ce.status == 404 and 'object not found' in err_msg: |
|
449 |
raiseCLIError(ce, |
|
450 |
'No object %s in %s\'s container %s'\ |
|
451 |
% (self.path, self.account, self.container), |
|
452 |
details=this.container_howto) |
|
453 |
raise |
|
454 |
return _raise |
Also available in: Unified diff