_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)
_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):
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()
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']:
: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):