Commit 866a5b5e authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-endpoints' into develop

parents 40bdbfa3 c626151a
......@@ -72,9 +72,10 @@ class user_authenticate(_user_init, _optional_json):
"""Authenticate a user
Get user information (e.g. unique account name) from token
Token should be set in settings:
* check if a token is set /config get token
* permanently set a token /config set token <token>
* check if a token is set /config get remote.default.token
* permanently set a token /config set remote.default.token <token>
Token can also be provided as a parameter
(In case of another named cloud remote, use its name instead of default)
"""
@staticmethod
......
......@@ -44,12 +44,18 @@ _commands = [config_cmds]
about_options = '\nAbout options:\
\n. syntax: [group.]option\
\n. example: file.uuid\
\n. example: global.log_file\
\n. special case: <option> is equivalent to global.<option>\
\n. configuration file syntax:\
\n. [group]\
\n. option=value\
\n. (more options can be set per group)'
\n. (more options can be set per group)\
\n. special case: named cloud remotes.\
\n. E.g. for a cloud "demo":\
\n. [remote "demo"]\
\n. url = <http://single/authentication/url/for/demo/site>\
\n. token = <auth_token_from_demo_site>\
\n. which are referenced as remote.demo.url , remote.demo.token'
@command(config_cmds)
......
......@@ -53,7 +53,7 @@ _commands = [server_cmds, flavor_cmds, network_cmds]
about_authentication = '\nUser Authentication:\
\n* to check authentication: /user authenticate\
\n* to set authentication token: /config set token <token>'
\n* to set authentication token: /config set remote.default.token <token>'
howto_personality = [
'Defines a file to be injected to VMs personality.',
......
......@@ -38,6 +38,10 @@ from kamaki.cli.errors import CLIError, raiseCLIError, CLISyntaxError
from kamaki.cli import _debug, kloger
from kamaki.cli.utils import format_size
CLOUDNAME = [
'Note: If you use a named cloud remote, use its name',
'instead of "default"']
class generic(object):
......@@ -66,8 +70,10 @@ class generic(object):
raiseCLIError(ce, 'Authorization failed', details=[
'Make sure a valid token is provided:',
' to check if token is valid: /user authenticate',
' to set token: /config set [.server.]token <token>',
' to get current token: /config get [server.]token'])
' to set token:',
' /config set remote.default.token <token>',
' to get current token:',
' /config get remote.default.token'] + CLOUDNAME)
elif ce.status in range(-12, 200) + [302, 401, 403, 500]:
raiseCLIError(ce, importance=3, details=[
'Check if service is up'])
......@@ -79,8 +85,10 @@ class generic(object):
msg = 'Invalid service url %s' % url
raiseCLIError(ce, msg, details=[
'Check if authentication url is correct',
' check current url: /config get url',
' set new auth. url: /config set url'])
' check current url:',
' /config get remote.default.url',
' set new auth. url:',
' /config set remote.default.url'] + CLOUDNAME)
raise
return _raise
......@@ -88,10 +96,10 @@ class generic(object):
class user(object):
_token_details = [
'To check default token: /config get token',
'To check default token: /config get remote.default.token',
'If set/update a token:',
'* (permanent): /config set token <token>',
'* (temporary): re-run with <token> parameter']
'* (permanent): /config set remote.default.token <token>',
'* (temporary): re-run with <token> parameter'] + CLOUDNAME
@classmethod
def load(this, foo):
......@@ -103,13 +111,16 @@ class user(object):
raiseCLIError(ae, 'Client setup failure', importance=3)
if not getattr(client, 'token', False):
kloger.warning(
'No permanent token (try: kamaki config set token <tkn>)')
'No permanent token (try:'
' kamaki config set remote.default.token <tkn>)')
if not getattr(client, 'base_url', False):
msg = 'Missing synnefo URL'
msg = 'Missing synnefo authentication URL'
raise CLIError(msg, importance=3, details=[
'Check if authentication url is correct',
' check current url: /config get url',
' set new auth. url: /config set url'])
' check current url:',
' /config get remote.default.url',
' set new auth. url:',
' /config set remote.default.url'] + CLOUDNAME)
return r
return _raise
......@@ -401,10 +412,10 @@ class plankton(object):
class pithos(object):
container_howto = [
'To specify a container:',
' 1. Set file.container variable (permanent)',
' /config set file.container <container>',
' 2. --container=<container> (temporary, overrides 1)',
' 3. Use the container:path format (temporary, overrides all)',
' 1. --container=<container> (temporary, overrides all)',
' 2. Use the container:path format (temporary, overrides 3)',
' 3. Set pithos_container variable (permanent)',
' /config set pithos_container <container>',
'For a list of containers: /file list']
@classmethod
......@@ -435,10 +446,10 @@ class pithos(object):
raiseCLIError(ce, 'User quota exceeded', details=[
'* get quotas:',
' * upper total limit: /file quota',
' * container limit: /file quota <container>',
'* set a higher quota (if permitted):',
' /file setquota <quota>[unit] <container>'
' as long as <container quota> <= <total quota>'])
' * container limit:',
' /file containerlimit get <container>',
'* set a higher container limit:',
' /file containerlimit set <limit> <container>'])
raise
return _raise
......
......@@ -59,7 +59,7 @@ _commands = [image_cmds]
howto_image_file = [
'Kamaki commands to:',
' get current user uuid: /user authenticate',
' get current user id: /user authenticate',
' check available containers: /file list',
' create a new container: /file create <container>',
' check container contents: /file list <container>',
......@@ -153,9 +153,9 @@ def _load_image_meta(filepath):
def _validate_image_location(location):
"""
:param location: (str) pithos://<uuid>/<container>/<img-file-path>
:param location: (str) pithos://<user-id>/<container>/<img-file-path>
:returns: (<uuid>, <container>, <img-file-path>)
:returns: (<user-id>, <container>, <img-file-path>)
:raises AssertionError: if location is invalid
"""
......@@ -163,7 +163,7 @@ def _validate_image_location(location):
msg = 'Invalid prefix for location %s , try: %s' % (location, prefix)
assert location.startswith(prefix), msg
service, sep, rest = location.partition('://')
assert sep and rest, 'Location %s is missing uuid' % location
assert sep and rest, 'Location %s is missing user-id' % location
uuid, sep, rest = rest.partition('/')
assert sep and rest, 'Location %s is missing container' % location
container, sep, img_path = rest.partition('/')
......@@ -380,7 +380,7 @@ class image_register(_init_image, _optional_json):
'No image file location provided',
importance=2, details=[
'An image location is needed. Image location format:',
' pithos://<uuid>/<container>/<path>',
' pithos://<user-id>/<container>/<path>',
' an image file at the above location must exist.'
] + howto_image_file)
try:
......@@ -390,7 +390,7 @@ class image_register(_init_image, _optional_json):
ae, 'Invalid image location format',
importance=1, details=[
'Valid image location format:',
' pithos://<uuid>/<container>/<img-file-path>'
' pithos://<user-id>/<container>/<img-file-path>'
] + howto_image_file)
@errors.generic.all
......
......@@ -1219,7 +1219,7 @@ class file_download(_file_container_command):
If local destination is a directory:
* download <container>:<path> <local dir> -R
will download all files on <container> prefixed as <path>,
to <local dir>/<full path>
to <local dir>/<full path> (or <local dir>\<full path> in windows)
* download <container>:<path> <local dir> --exact-match
will download only one file, exactly matching <path>
ATTENTION: to download cont:dir1/dir2/file there must exist objects
......@@ -1733,7 +1733,7 @@ class file_metadata_get(_file_container_command, _optional_json):
detail=FlagArgument('show detailed output', ('-l', '--details')),
until=DateArgument('show metadata until then', '--until'),
object_version=ValueArgument(
'show specific version \ (applies only for objects)',
'show specific version (applies only for objects)',
('-O', '--object-version'))
)
......
......@@ -82,9 +82,10 @@ class astakos_authenticate(_astakos_init, _optional_json):
"""Authenticate a user
Get user information (e.g. unique account name) from token
Token should be set in settings:
* check if a token is set /config get token
* permanently set a token /config set token <token>
* check if a token is set /config get remote.default.token
* permanently set a token /config set remote.default.token <token>
Token can also be provided as a parameter
(To use a named cloud remote, use its name instead of "default")
"""
arguments = dict(
......
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