Apply servce.url options to cross-sercice calls
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Mon, 3 Jun 2013 11:37:26 +0000 (14:37 +0300)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Mon, 3 Jun 2013 11:40:31 +0000 (14:40 +0300)
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
kamaki/cli/commands/pithos.py

index 1006656..34070a2 100644 (file)
@@ -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):
index 72a99fb..280a91d 100644 (file)
@@ -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):