From: Rishabh Dave Date: Mon, 19 Oct 2020 11:46:02 +0000 (+0530) Subject: qa/cephfs: move common and generic methods mount.py X-Git-Tag: v17.1.0~2684^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5e71e9b065b690ede5644b12937dfdb9eec93147;p=ceph.git qa/cephfs: move common and generic methods mount.py Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index c58a427e8372..202a69b2ab65 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -62,7 +62,7 @@ class FuseMount(CephFSMount): log.info("Client client.%s config is %s" % (self.client_id, self.client_config)) - self._create_mntpt() + self._create_mntpt(cwd=self.test_dir) retval = self._run_mount_cmd(mntopts, check_status) if retval: @@ -72,18 +72,6 @@ class FuseMount(CephFSMount): self.mounted = True - def _create_mntpt(self): - stderr = StringIO() - # Use 0000 mode to prevent undesired modifications to the mountpoint on - # the local file system. - script = f'mkdir -m 0000 -p -v {self.hostfs_mntpt}'.split() - try: - self.client_remote.run(args=script, timeout=(15*60), - stderr=stderr) - except CommandFailedError: - if 'file exists' not in stderr.getvalue().lower(): - raise - def _run_mount_cmd(self, mntopts, check_status): mount_cmd = self._get_mount_cmd(mntopts) mountcmd_stdout, mountcmd_stderr = StringIO(), StringIO() @@ -133,10 +121,6 @@ class FuseMount(CephFSMount): return mount_cmd - @property - def _nsenter_args(self): - return ['nsenter', f'--net=/var/run/netns/{self.netns_name}'] - def _add_valgrind_args(self, mount_cmd): if self.client_config.get('valgrind') is not None: mount_cmd = get_valgrind_args( diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index c4cd1591fb5b..e02d2b1be71f 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -51,15 +51,6 @@ class KernelMount(CephFSMount): self.mounted = True - def _create_mntpt(self): - stderr = StringIO() - try: - self.client_remote.run(args=['mkdir', '-p', self.hostfs_mntpt], - timeout=(5*60), stderr=stderr) - except CommandFailedError: - if 'file exists' not in stderr.getvalue().lower(): - raise - def _run_mount_cmd(self, mntopts, check_status): mount_cmd = self._get_mount_cmd(mntopts) mountcmd_stdout, mountcmd_stderr = StringIO(), StringIO() @@ -101,22 +92,6 @@ class KernelMount(CephFSMount): return mount_cmd - @property - def _nsenter_args(self): - return ['nsenter', f'--net=/var/run/netns/{self.netns_name}'] - - def _set_filemode_on_mntpt(self): - stderr = StringIO() - try: - self.client_remote.run( - args=['sudo', 'chmod', '1777', self.hostfs_mntpt], - stderr=stderr, timeout=(5*60)) - except CommandFailedError: - # the client does not have write permissions in the caps it holds - # for the Ceph FS that was just mounted. - if 'permission denied' in stderr.getvalue().lower(): - pass - def umount(self, force=False): if not self.is_mounted(): self.cleanup() diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 2bf3aec60e10..cf1d229ca8d4 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -175,6 +175,34 @@ class CephFSMount(object): self.fs.wait_for_daemons() log.info('Ready to start {}...'.format(type(self).__name__)) + def _create_mntpt(self, cwd=None): + stderr = StringIO() + # Use 0000 mode to prevent undesired modifications to the mountpoint on + # the local file system. + script = f'mkdir -m 0000 -p -v {self.hostfs_mntpt}'.split() + try: + self.client_remote.run(args=script, timeout=(15*60), + stderr=stderr) + except CommandFailedError: + if 'file exists' not in stderr.getvalue().lower(): + raise + + @property + def _nsenter_args(self): + return ['nsenter', f'--net=/var/run/netns/{self.netns_name}'] + + def _set_filemode_on_mntpt(self): + stderr = StringIO() + try: + self.client_remote.run( + args=['sudo', 'chmod', '1777', self.hostfs_mntpt], + stderr=stderr, timeout=(5*60)) + except CommandFailedError: + # the client does not have write permissions in the caps it holds + # for the Ceph FS that was just mounted. + if 'permission denied' in stderr.getvalue().lower(): + pass + def _setup_brx_and_nat(self): # The ip for ceph-brx should be ip = IP(self.ceph_brx_net)[-2]