From 3c346c9153b7395013643db2657263392b0e4569 Mon Sep 17 00:00:00 2001 From: Stavros Sachtouris Date: Mon, 3 Jun 2013 14:37:26 +0300 Subject: [PATCH] Apply servce.url options to cross-sercice calls Refs: #3874 Let cross-service initializations to use explicit service endpoint urls if there is no single authentication url. - In Image commands, there are calls that use astakos and pithos clients - In pithos there are calls that use astakos client --- kamaki/cli/commands/image.py | 22 +++++++++++++++++----- kamaki/cli/commands/pithos.py | 9 ++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/kamaki/cli/commands/image.py b/kamaki/cli/commands/image.py index 1006656..34070a2 100644 --- a/kamaki/cli/commands/image.py +++ b/kamaki/cli/commands/image.py @@ -308,16 +308,28 @@ class image_register(_init_image, _optional_json): atoken = self.client.token #user = AstakosClient(self.config.get('user', 'url'), atoken) #return user.term('uuid') - self.auth_base.term('uuid', atoken) + if getattr(self, 'auth_base', False): + return self.auth_base.term('uuid', atoken) + else: + astakos_url = self.config.get('astakos', 'url') + if not astakos_url: + raise CLIBaseUrlError(service='astakos') + user = AstakosClient(astakos_url, atoken) + return user.term('uuid') def _get_pithos_client(self, container): if self['no_metafile_upload']: return None - pithos_endpoints = self.auth_base.get_service_endpoints( - self.config.get('pithos', 'type'), - self.config.get('pithos', 'version')) - purl = pithos_endpoints['publicURL'] ptoken = self.client.token + if getattr(self, 'auth_base', False): + pithos_endpoints = self.auth_base.get_service_endpoints( + self.config.get('pithos', 'type'), + self.config.get('pithos', 'version')) + purl = pithos_endpoints['publicURL'] + else: + purl = self.config.get('pithos', 'url') + if not purl: + raise CLIBaseUrlError(service='pithos') return PithosClient(purl, ptoken, self._get_uuid(), container) def _store_remote_metafile(self, pclient, remote_path, metadata): diff --git a/kamaki/cli/commands/pithos.py b/kamaki/cli/commands/pithos.py index 72a99fb..280a91d 100644 --- a/kamaki/cli/commands/pithos.py +++ b/kamaki/cli/commands/pithos.py @@ -179,7 +179,14 @@ class _pithos_init(_command_init): self._run() def _set_account(self): - self.account = self.auth_base.user_term('uuid', self.token) + if getattr(self, 'base_url', False): + self.account = self.auth_base.user_term('uuid', self.token) + else: + astakos_url = self.config('astakos', 'get') + if not astakos_url: + raise CLIBaseUrlError(service='astakos') + astakos = AstakosClient(astakos_url, self.token) + self.account = astakos.user_term('uuid') class _file_account_command(_pithos_init): -- 1.7.10.4