Commit 1395c40e authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Adjust pithos_cli up to store_move

parent 5a673575
include README.rst COPYRIGHT
recursive-include docs *
prune docs/_build
......@@ -69,21 +69,6 @@ howto_personality = [
' MODEL: permition in octal (e.g. 0777 or o+rwx)']
def raise_if_connection_error(err, base_url='compute.url'):
if err.status == 401:
raiseCLIError(err, 'Authorization failed', details=[
'Make sure a valid token is provided:',
' to check if the token is valid: /astakos authenticate',
' to set a token: /config set [.server.]token <token>',
' to get current token: /config get [server.]token'])
elif err.status in range(-12, 200) + [403, 500]:
raiseCLIError(err, details=[
'Check if service is up or set to %s' % base_url,
' to get service url: /config get %s' % base_url,
' to set service url: /config set %s <URL>' % base_url]
)
class _init_cyclades(_command_init):
@errors.generic.all
def _run(self, service='compute'):
......
......@@ -70,7 +70,7 @@ class generic(object):
' to check if token is valid: /astakos authenticate',
' to set token: /config set [.server.]token <token>',
' to get current token: /config get [server.]token'])
elif ce.status in range(-12, 200) + [403, 302, 500]:
elif ce.status in range(-12, 200) + [302, 401, 403, 500]:
raiseCLIError(ce, importance=3, details=[
'Check if service is up or set to url %s' % base_url,
' to get url: /config get %s' % base_url,
......@@ -391,3 +391,64 @@ class plankton(object):
'No properties with key %s in this image' % key)
raise
return _raise
class pithos(object):
container_howto = ['To specify a container:',
' 1. Set store.container variable (permanent)',
' /config set store.container <container>',
' 2. --container=<container> (temporary, overrides 1)',
' 3. Use the container:path format (temporary, overrides all)']
@classmethod
def connection(this, foo):
return generic._connection(foo, 'store.url')
@classmethod
def quota(this, foo):
def _raise(self, *args, **kwargs):
try:
return foo(self, *args, **kwargs)
except ClientError as ce:
if ce.status == 413:
raiseCLIError(ce, 'User quota exceeded', details=[
'* get quotas:',
' * upper total limit: /store quota',
' * container limit: /store quota <container>',
'* set a higher quota (if permitted):',
' /store setquota <quota>[unit] <container>'
' as long as <container quota> <= <total quota>'])
raise
return _raise
@classmethod
def container(this, foo):
def _raise(self, *args, **kwargs):
dst_cont = kwargs.get('dst_cont', None)
try:
return foo(self, *args, **kwargs)
except ClientError as ce:
if ce.status == 404 and 'container' in ('%s' % ce).lower():
cont = '%s or %s' if dst_cont else self.container
raiseCLIError(ce,
'No container %s in account %s' % (
cont,
self.account),
details=this.container_howto)
raise
return _raise
@classmethod
def object_path(this, foo):
def _raise(self, *args, **kwargs):
try:
return foo(self, *args, **kwargs)
except ClientError as ce:
err_msg = ('%s' % ce).lower()
if ce.status == 404 and 'object not found' in err_msg:
raiseCLIError(ce,
'No object %s in %s\'s container %s'\
% (self.path, self.account, self.container),
details=this.container_howto)
raise
return _raise
......@@ -33,13 +33,11 @@
from kamaki.cli import command
from kamaki.cli.command_tree import CommandTree
from kamaki.cli.errors import raiseCLIError
from kamaki.cli.utils import print_dict, print_items
from kamaki.clients.image import ImageClient, ClientError
from kamaki.clients.image import ImageClient
from kamaki.cli.argument import FlagArgument, ValueArgument, KeyValueArgument
from kamaki.cli.argument import IntArgument
from kamaki.cli.commands.cyclades_cli import _init_cyclades
from kamaki.cli.commands.cyclades_cli import raise_if_connection_error
from kamaki.cli.commands import _command_init, errors
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment