Commit cb4a5d9c authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Implement --cloud arg to switch between clouds

Refs: #3913

Config file can (optionaly) contain:

[remotes]
 example = https://www.example.org/astakos/identity/v2.0/
 old_version = https://www.example.org/astakos/identity/v1.0/
 ...

Now, user can explicitely request for a remote cloud authentication URI:

kamaki --cloud=<remote>
parent 74d443db
......@@ -4,7 +4,7 @@ Bug Fixes:
Changes:
- Adjust astakos authenticate to the new url shchem of synnefo >= 0.14 [#3832, #3874]
- Adjust astakos authenticate to the new url scheme of synnefo >= 0.14 [#3832, #3874]
as a side effect, some renamings in astakos.AstakosClient:
info --> user_info, user --> list_users
......
......@@ -201,15 +201,30 @@ def _init_session(arguments):
_include = arguments['include'].value
global _verbose
_verbose = arguments['verbose'].value
_cnf = arguments['config']
global _colors
_colors = arguments['config'].get('global', 'colors')
_colors = _cnf.get('global', 'colors')
if not (stdout.isatty() and _colors == 'on'):
from kamaki.cli.utils import remove_colors
remove_colors()
_silent = arguments['silent'].value
_setup_logging(_silent, _debug, _verbose, _include)
global_url = arguments['config'].get('global', 'url')
global_token = arguments['config'].get('global', 'token')
picked_cloud = arguments['cloud'].value
if picked_cloud:
global_url = _cnf.get('remotes', picked_cloud)
if not global_url:
raise CLIError(
'No remote cloud "%s" in kamaki configuration' % picked_cloud,
importance=3, details=[
'To check if this remote cloud alias is declared:',
' /config get remotes.%s' % picked_cloud,
'To set a remote authentication URI aliased as "%s"' % (
picked_cloud),
' /config set remotes.%s <URI>' % picked_cloud
])
else:
global_url = _cnf.get('global', 'auth_url')
global_token = _cnf.get('global', 'token')
from kamaki.clients.astakos import AstakosClient as AuthCachedClient
return AuthCachedClient(global_url, global_token)
......
......@@ -398,31 +398,20 @@ class ProgressBarArgument(FlagArgument):
_arguments = dict(
config=_config_arg,
cloud=ValueArgument('Chose a remote cloud to connect to', ('--cloud')),
help=Argument(0, 'Show help message', ('-h', '--help')),
debug=FlagArgument('Include debug output', ('-d', '--debug')),
include=FlagArgument(
'Include raw connection data in the output',
('-i', '--include')),
'Include raw connection data in the output', ('-i', '--include')),
silent=FlagArgument('Do not output anything', ('-s', '--silent')),
verbose=FlagArgument('More info at response', ('-v', '--verbose')),
version=VersionArgument('Print current version', ('-V', '--version')),
options=CmdLineConfigArgument(
_config_arg,
'Override a config value',
('-o', '--options'))
_config_arg, 'Override a config value', ('-o', '--options'))
)
"""Initial command line interface arguments"""
"""
Mechanism:
init_parser
parse_known_args
manage top-level user arguments input
find user-requested command
add command-specific arguments to dict
update_arguments
"""
# Initial command line interface arguments
class ArgumentParseManager(object):
......
......@@ -81,9 +81,9 @@ class _init_image(_command_init):
self.config.get('plankton', 'type'),
self.config.get('plankton', 'version'))
base_url = plankton_endpoints['publicURL']
base_url = self.config.get('image', 'url')\
or self.config.get('compute', 'url')\
or self.config.get('global', 'url')
#base_url = self.config.get('image', 'url')\
# or self.config.get('compute', 'url')\
# or self.config.get('global', 'url')
self.client = ImageClient(base_url=base_url, token=token)
self._set_log_params()
self._update_max_threads()
......@@ -303,8 +303,9 @@ class image_register(_init_image, _optional_json):
def _get_uuid(self):
atoken = self.client.token
user = AstakosClient(self.config.get('user', 'url'), atoken)
return user.term('uuid')
#user = AstakosClient(self.config.get('user', 'url'), atoken)
#return user.term('uuid')
self.auth_base.term('uuid', atoken)
def _get_pithos_client(self, container):
if self['no_metafile_upload']:
......
......@@ -53,7 +53,7 @@ class AstakosClient(Client):
:returns: (dict) authentication information
"""
self.token = token or self.token
self._cache[self.token] = self.get('/tokens').json
self._cache[self.token] = self.post('/tokens').json
return self._cache[self.token]
def get_services(self, token=None):
......
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