]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: add a method to create an empty file with any user
authorRishabh Dave <ridave@redhat.com>
Mon, 25 Feb 2019 19:54:58 +0000 (01:24 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 17 Apr 2019 18:28:22 +0000 (23:58 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/mount.py

index 3efa624dd57253990e5cde9aa1cf3df3ff051723..d187cedd5f86dd5c43a922589b4df252258831e5 100644 (file)
@@ -111,6 +111,28 @@ class CephFSMount(object):
                 return True
         return False
 
+    def create_file(self, filename='testfile', dirname=None, user=None,
+                    check_status=True):
+        assert(self.is_mounted())
+
+        if not os.path.isabs(filename):
+            if dirname:
+                if os.path.isabs(dirname):
+                    path = os.path.join(dirname, filename)
+                else:
+                    path = os.path.join(self.mountpoint, dirname, filename)
+            else:
+                path = os.path.join(self.mountpoint, filename)
+        else:
+            path = filename
+
+        if user:
+            args = ['sudo', '-u', user, '-s', '/bin/bash', '-c', 'touch ' + path]
+        else:
+            args = 'touch ' + path
+
+        return self.client_remote.run(args=args, check_status=check_status)
+
     def create_files(self):
         assert(self.is_mounted())