From e9bc9f84e55f1c78b542cf7774b40a48069610c4 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Tue, 26 Feb 2019 01:24:58 +0530 Subject: [PATCH] qa: add a method to create an empty file with any user Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/mount.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 3efa624dd57..d187cedd5f8 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()) -- 2.39.5