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

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
qa/tasks/cephfs/mount.py

index 57b3096c3c512f7fc06f69b9b8a4f43ce9eeb17d..3899ad2aa8cde6fde786e48d9c9e361b7c4672e9 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