Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
1395c40e
Commit
1395c40e
authored
Jan 24, 2013
by
Stavros Sachtouris
Browse files
Adjust pithos_cli up to store_move
parent
5a673575
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
MANIFEST.in
View file @
1395c40e
include README.rst COPYRIGHT
recursive-include docs *
prune docs/_build
kamaki/cli/commands/cyclades_cli.py
View file @
1395c40e
...
...
@@ -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'
):
...
...
kamaki/cli/commands/errors.py
View file @
1395c40e
...
...
@@ -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
)
+
[
40
3
,
302
,
500
]:
elif
ce
.
status
in
range
(
-
12
,
200
)
+
[
302
,
40
1
,
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
kamaki/cli/commands/image_cli.py
View file @
1395c40e
...
...
@@ -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
...
...
kamaki/cli/commands/pithos_cli.py
View file @
1395c40e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment