]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: move common and generic methods mount.py
authorRishabh Dave <ridave@redhat.com>
Mon, 19 Oct 2020 11:46:02 +0000 (17:16 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 5 Mar 2021 04:33:12 +0000 (10:03 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/fuse_mount.py
qa/tasks/cephfs/kernel_mount.py
qa/tasks/cephfs/mount.py

index c58a427e837273b706e9ee947895ce5f867a6d91..202a69b2ab65d1e93b3c782a6780954f0bbde346 100644 (file)
@@ -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(
index c4cd1591fb5b3c69ab6b45a0af6882ceb0983ee2..e02d2b1be71ff4224787bdbab45f5f17adad0858 100644 (file)
@@ -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()
index 2bf3aec60e10ec19fdbc82f4710496cc58383398..cf1d229ca8d462136b0d533819998a6ef6d1bfd1 100644 (file)
@@ -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]