Revision 92101413

b/kamaki/cli/commands/astakos.py
36 36
from kamaki.cli.commands import _command_init, errors, _optional_json
37 37
from kamaki.cli.command_tree import CommandTree
38 38
from kamaki.cli.errors import CLIBaseUrlError
39
from kamaki.cli.utils import print_dict
39 40

  
40 41
user_cmds = CommandTree('user', 'Astakos API commands')
41 42
_commands = [user_cmds]
......
46 47
    @errors.generic.all
47 48
    @errors.user.load
48 49
    def _run(self):
49
        #token = self.config.get('user', 'token')\
50
        #    or self.config.get('global', 'token')
51
        #base_url = self.config.get('global', 'url')
52
        #self.client = AstakosClient(base_url=base_url, token=token)
53 50
        if getattr(self, 'auth_base', False):
54 51
            self.client = self.auth_base
55 52
        else:
56
            token = self.config.get('astakos', 'token')\
53
            token = self.config.get('user', 'token')\
54
                or self.config.get('astakos', 'token')\
57 55
                or self.config.get('global', 'token')
58
            base_url = self.config.get('astakos', 'url')
56
            base_url = self.config.get('user', 'url')\
57
                or self.config.get('astakos', 'url')
59 58
            if not base_url:
60 59
                raise CLIBaseUrlError(service='astakos')
61 60
            self.client = AstakosClient(base_url=base_url, token=token)
......
77 76
    Token can also be provided as a parameter
78 77
    """
79 78

  
79
    @staticmethod
80
    def _print_access(r):
81
        print_dict(r['access'])
82

  
80 83
    @errors.generic.all
81 84
    @errors.user.authenticate
82 85
    def _run(self, custom_token=None):
83 86
        super(self.__class__, self)._run()
84 87
        r = self.client.authenticate(custom_token)
85
        self._print([r], title=('uuid', 'name',), with_redundancy=True)
88
        self._print(r, self._print_access)
86 89

  
87 90
    def main(self, custom_token=None):
88 91
        self._run(custom_token)
b/kamaki/cli/commands/cyclades.py
77 77
                self.config.get('cyclades', 'version'))
78 78
            base_url = cyclades_endpoints['publicURL']
79 79
        else:
80
            base_url = self.config.get('cyclades', 'url')
80
            base_url = self.config.get('compute', 'url')\
81
                or self.config.get('cyclades', 'url')
81 82
        if not base_url:
82 83
            raise CLIBaseUrlError(service='cyclades')
83 84

  
b/kamaki/cli/commands/image.py
75 75
    @errors.generic.all
76 76
    def _run(self):
77 77
        token = self.config.get('image', 'token')\
78
            or self.config.get('plankton', 'token')\
78 79
            or self.config.get('global', 'token')
79 80

  
80 81
        if getattr(self, 'auth_base', False):
81 82
            plankton_endpoints = self.auth_base.get_service_endpoints(
82
                self.config.get('plankton', 'type'),
83
                self.config.get('plankton', 'version'))
83
                self.config.get('image', 'type'),
84
                self.config.get('image', 'version'))
84 85
            base_url = plankton_endpoints['publicURL']
85 86
        else:
86
            base_url = self.config.get('plankton', 'url')
87
            base_url = self.config.get('image', 'url')\
88
                or self.config.get('plankton', 'url')
87 89
        if not base_url:
88 90
            raise CLIBaseUrlError(service='plankton')
89 91

  
......
304 306

  
305 307
    )
306 308

  
307
    def _get_uuid(self):
309
    def _get_user_id(self):
308 310
        atoken = self.client.token
309
        #user = AstakosClient(self.config.get('user', 'url'), atoken)
310
        #return user.term('uuid')
311 311
        if getattr(self, 'auth_base', False):
312 312
            return self.auth_base.term('id', atoken)
313 313
        else:
314
            astakos_url = self.config.get('astakos', 'url')
314
            astakos_url = self.config.get('user', 'url')\
315
                or self.config.get('astakos', 'url')
315 316
            if not astakos_url:
316 317
                raise CLIBaseUrlError(service='astakos')
317 318
            user = AstakosClient(astakos_url, atoken)
......
327 328
                self.config.get('pithos', 'version'))
328 329
            purl = pithos_endpoints['publicURL']
329 330
        else:
330
            purl = self.config.get('pithos', 'url')
331
            purl = self.config.get('file', 'url')\
332
                or self.config.get('pithos', 'url')
331 333
            if not purl:
332 334
                raise CLIBaseUrlError(service='pithos')
333
        return PithosClient(purl, ptoken, self._get_uuid(), container)
335
        return PithosClient(purl, ptoken, self._get_user_id(), container)
334 336

  
335 337
    def _store_remote_metafile(self, pclient, remote_path, metadata):
336 338
        return pclient.upload_from_string(
b/kamaki/cli/commands/pithos.py
160 160
                self.config.get('pithos', 'version'))
161 161
            self.base_url = pithos_endpoints['publicURL']
162 162
        else:
163
            self.base_url = self.config.get('pithos', 'url')
163
            self.base_url = self.config.get('file', 'url')\
164
                or self.config.get('store', 'url')\
165
                or self.config.get('pithos', 'url')
164 166
        if not self.base_url:
165 167
            raise CLIBaseUrlError(service='pithos')
166 168

  
167 169
        self._set_account()
168 170
        self.container = self.config.get('file', 'container')\
171
            or self.config.get('store', 'container')\
172
            or self.config.get('pithos', 'container')\
169 173
            or self.config.get('global', 'container')
170 174
        self.client = PithosClient(
171 175
            base_url=self.base_url,
......
179 183
        self._run()
180 184

  
181 185
    def _set_account(self):
182
        if getattr(self, 'base_url', False):
186
        if getattr(self, 'auth_base', False):
183 187
            self.account = self.auth_base.user_term('id', self.token)
184 188
        else:
185
            astakos_url = self.config('astakos', 'get')
189
            astakos_url = self.config.get('user', 'url')\
190
                or self.config.get('astakos', 'url')
186 191
            if not astakos_url:
187 192
                raise CLIBaseUrlError(service='astakos')
188 193
            astakos = AstakosClient(astakos_url, self.token)
b/kamaki/cli/config.py
50 50
CONFIG_ENV = 'KAMAKI_CONFIG'
51 51

  
52 52
HEADER = """
53
# Kamaki configuration file v3
53
# Kamaki configuration file v3 (kamaki >= v0.9)
54 54
"""
55 55

  
56 56
DEFAULTS = {
......
72 72
        'image': 'image',
73 73
        'config': 'config',
74 74
        'history': 'history'
75
        #  Optional command specs:
76
        #  'livetest': 'livetest',
77
        #  'astakos': 'snf-astakos'
75 78
    },
76 79
    'history': {
77 80
        'file': HISTORY_PATH

Also available in: Unified diff