]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/mount: introduce _default_gateway method 63130/head
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Wed, 12 Mar 2025 12:01:12 +0000 (13:01 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Tue, 6 May 2025 11:47:04 +0000 (13:47 +0200)
Create function for getting default gateway in order to
reduce code duplication.

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
(cherry picked from commit ebf1dbca5f1492cac03ff847cda69839545a7da6)

qa/tasks/cephfs/mount.py

index c00ded82b56ae4f6e37116dc4ce02983aa76e0ef..818e90dd48051ecb9e922cd208190b22605b5f7c 100644 (file)
@@ -264,6 +264,13 @@ class CephFSMountBase(object):
             if 'permission denied' in stderr.getvalue().lower():
                 pass
 
+    def _default_gateway(self):
+        routes = self.client_remote.sh('ip r', timeout=(5*60))
+        defaults = re.findall(r'^default .*', routes)
+        if defaults == False:
+            raise RuntimeError("No default gw found")
+        return defaults[0].split()[4]
+
     def _setup_brx_and_nat(self):
         # The ip for ceph-brx should be
         ip = IP(self.ceph_brx_net)[-2]
@@ -296,11 +303,7 @@ class CephFSMountBase(object):
         self.client_remote.run(args=args, timeout=(5*60), omit_sudo=False)
         
         # Setup the NAT
-        routes = self.client_remote.sh('ip r', timeout=(5*60))
-        defaults = re.findall(r'^default .*', routes)
-        if defaults == False:
-            raise RuntimeError("No default gw found")
-        gw = defaults[0].split()[4]
+        gw = self._default_gateway()
 
         self.run_shell_payload(f"""
             set -e
@@ -440,11 +443,7 @@ class CephFSMountBase(object):
         ip = IP(self.ceph_brx_net)[-2]
         mask = self.ceph_brx_net.split('/')[1]
 
-        routes = self.client_remote.sh('ip r', timeout=(5*60))
-        defaults = re.findall(r'^default .*', routes)
-        if defaults == False:
-            raise RuntimeError("No default gw found")
-        gw = defaults[0].split()[4]
+        gw = self._default_gateway()
 
         self.run_shell_payload(f"""
             set -e