]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/filesystem.py: backport _write_data_xattr() function 12836/head
authorNathan Cutler <ncutler@suse.com>
Tue, 24 Jan 2017 14:49:24 +0000 (15:49 +0100)
committerNathan Cutler <ncutler@suse.com>
Tue, 24 Jan 2017 14:53:57 +0000 (15:53 +0100)
This is a partial manual backport of 5f77f09b019b607b84e6a8f89ce19065383ca108

It is needed by test_corrupt_backtrace() in qa/tasks/cephfs/test_damage.py

Signed-off-by: Nathan Cutler <ncutler@suse.com>
qa/tasks/cephfs/filesystem.py

index 1b3b71e017d56f0149cca2f81e7c525d7aac3a7b..9f130e3612488f2507e5456bfaca0247580e43b0 100644 (file)
@@ -633,6 +633,30 @@ class Filesystem(MDSCluster):
 
         return json.loads(p.stdout.getvalue().strip())
 
+    def _write_data_xattr(self, ino_no, xattr_name, data, pool=None):
+        """
+        Write to an xattr of the 0th data object of an inode.  Will
+        succeed whether the object and/or xattr already exist or not.
+
+        :param ino_no: integer inode number
+        :param xattr_name: string name of the xattr
+        :param data: byte array data to write to the xattr
+        :param pool: name of data pool or None to use primary data pool
+        :return: None
+        """
+        remote = self.mds_daemons[self.mds_ids[0]].remote
+        if pool is None:
+            pool = self.get_data_pool_name()
+
+        obj_name = "{0:x}.00000000".format(ino_no)
+        args = [
+            os.path.join(self._prefix, "rados"), "-p", pool, "setxattr",
+            obj_name, xattr_name, data
+        ]
+        remote.run(
+            args=args,
+            stdout=StringIO())
+
     def read_backtrace(self, ino_no, pool=None):
         """
         Read the backtrace from the data pool, return a dict in the format