Use UUID when calling pithos client
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 7 Feb 2013 16:43:55 +0000 (18:43 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 7 Feb 2013 16:43:55 +0000 (18:43 +0200)
In kamaki.clients.pithos context, the variable is still called account
Only the callers change their behavior, as they should retrive the
account by calling kamaki.clients.astakos.AstakosClient().term('uuid')
Tests are also adjusted

kamaki/cli/commands/pithos_cli.py
kamaki/clients/tests/pithos.py

index a96b145..4889236 100644 (file)
@@ -53,6 +53,7 @@ from kamaki.cli.argument import KeyValueArgument, DateArgument
 from kamaki.cli.argument import ProgressBarArgument
 from kamaki.cli.commands import _command_init, errors
 from kamaki.clients.pithos import PithosClient, ClientError
+from kamaki.clients.astakos import AstakosClient
 
 
 kloger = getLogger('kamaki')
@@ -79,7 +80,7 @@ def raise_connection_errors(e):
             '  to get the service url: /config get store.url',
             '  to set the service url: /config set store.url <url>',
             ' ',
-            '  to get user the account: /config get store.account',
+            '  to get user account:     /config get store.account',
             '           or              /config get account',
             '  to set the user account: /config set store.account <account>',
             ' ',
@@ -189,8 +190,7 @@ class _pithos_init(_command_init):
             or self.config.get('global', 'token')
         self.base_url = self.config.get('store', 'url')\
             or self.config.get('global', 'url')
-        self.account = self.config.get('store', 'account')\
-            or self.config.get('global', 'account')
+        self._set_account()
         self.container = self.config.get('store', 'container')\
             or self.config.get('global', 'container')
         self.client = PithosClient(base_url=self.base_url,
@@ -201,6 +201,10 @@ class _pithos_init(_command_init):
     def main(self):
         self._run()
 
+    def _set_account(self):
+        astakos = AstakosClient(self.config.get('astakos', 'url'), self.token)
+        self.account = astakos.term('uuid')
+
 
 class _store_account_command(_pithos_init):
     """Base class for account level storage commands"""
index bd3cb61..a43b965 100644 (file)
@@ -38,6 +38,7 @@ from tempfile import NamedTemporaryFile
 
 from kamaki.clients import tests, ClientError
 from kamaki.clients.pithos import PithosClient
+from kamaki.clients.astakos import AstakosClient
 
 
 class Pithos(tests.Generic):
@@ -48,7 +49,10 @@ class Pithos(tests.Generic):
         self.client = PithosClient(
             self['store', 'url'],
             self['store', 'token'],
-            self['store', 'account'])
+            AstakosClient(
+                self['astakos', 'url'],
+                self['store', 'token']
+            ).term('uuid'))
 
         self.now = time.mktime(time.gmtime())
         self.now_unformated = datetime.datetime.utcnow()
@@ -58,7 +62,7 @@ class Pithos(tests.Generic):
         self.client.container = self.c1
         self.client.object_post('test',
             update=True,
-            permissions={'read': 'someUser'})
+            permissions={'read': [self.client.account]})
 
         self.create_remote_object(self.c1, 'another.test')