From: Rishabh Dave Date: Mon, 25 Feb 2019 19:54:58 +0000 (+0530) Subject: qa: add a method to create an empty file with any user X-Git-Tag: v15.1.0~2911^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e9bc9f84e55f1c78b542cf7774b40a48069610c4;p=ceph.git qa: add a method to create an empty file with any user Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 3efa624dd572..d187cedd5f86 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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())