Allow Custom From-Account to pithos copy
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Tue, 26 Feb 2013 17:08:06 +0000 (19:08 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Tue, 26 Feb 2013 17:08:06 +0000 (19:08 +0200)
kamaki/cli/commands/pithos_cli.py
kamaki/clients/livetest/pithos.py
kamaki/clients/pithos.py

index 3bda57a..8e2ed10 100644 (file)
@@ -529,6 +529,7 @@ class store_create(_store_container_command):
 class _source_destination_command(_store_container_command):
 
     arguments = dict(
+        source_account=ValueArgument('', '--src-account'),
         recursive=FlagArgument('', ('-r', '--recursive')),
         prefix=FlagArgument('', '--with-prefix', default=''),
         suffix=ValueArgument('', '--with-suffix', default=''),
@@ -654,6 +655,7 @@ class store_copy(_source_destination_command):
     """
 
     arguments = dict(
+        source_account=ValueArgument('Account to copy from', '--src-account'),
         destination_container=ValueArgument(
             'use it if destination container name contains a : character',
             '--dst-container'),
@@ -692,13 +694,14 @@ class store_copy(_source_destination_command):
     @errors.pithos.container
     def _run(self, dst_cont, dst_path):
         no_source_object = True
-        for src_object, dst_object in self.src_dst_pairs(dst_cont, dst_path):
+        for src_obj, dst_obj in self.src_dst_pairs(dst_cont, dst_path):
             no_source_object = False
             self.client.copy_object(
                 src_container=self.container,
-                src_object=src_object,
+                src_object=src_obj,
                 dst_container=dst_cont,
-                dst_object=dst_object,
+                dst_object=self.client.account,
+                source_account=self['source_account'],
                 source_version=self['source_version'],
                 public=self['public'],
                 content_type=self['content_type'])
index 0d76db4..18a5771 100644 (file)
@@ -835,6 +835,7 @@ class Pithos(livetest.Generic):
         self._test_0110_object_copy()
 
     def _test_0110_object_copy(self):
+        #  TODO: check with source_account option
         self.client.container = self.c2
         obj = 'test2'
 
index e8b4b6d..690da05 100644 (file)
@@ -1072,6 +1072,7 @@ class PithosClient(PithosRestAPI):
             self, src_container, src_object, dst_container,
             dst_object=False,
             source_version=None,
+            source_account=None,
             public=False,
             content_type=None,
             delimiter=None):
@@ -1086,6 +1087,8 @@ class PithosClient(PithosRestAPI):
 
         :param source_version: (str) source object version
 
+        :param source_account: (str) account to copy from
+
         :param public: (bool)
 
         :param content_type: (str)
@@ -1102,6 +1105,7 @@ class PithosClient(PithosRestAPI):
             copy_from=src_path,
             content_length=0,
             source_version=source_version,
+            source_account=source_account,
             public=public,
             content_type=content_type,
             delimiter=delimiter)