]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/mount: use 'ip r' instead 'route'
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 11 Mar 2025 16:14:28 +0000 (17:14 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 11 Mar 2025 16:14:28 +0000 (17:14 +0100)
Some linux host may not have 'route' installed. So, maybe,
prefer 'ip r' to find out which default gateway is configured.

Addresses error if there is no net-tools installed on ubuntu
remote hosts:
  route: command not found

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

index ddf6c2657a0334676872fb70383857abafb8d139..57b3096c3c512f7fc06f69b9b8a4f43ce9eeb17d 100644 (file)
@@ -296,12 +296,11 @@ class CephFSMountBase(object):
         self.client_remote.run(args=args, timeout=(5*60), omit_sudo=False)
         
         # Setup the NAT
-        p = self.client_remote.run(args=['route'], stderr=StringIO(),
-                                   stdout=StringIO(), timeout=(5*60))
-        p = re.findall(r'default .*', p.stdout.getvalue())
-        if p == False:
+        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 = p[0].split()[7]
+        gw = defaults[0].split()[4]
 
         self.run_shell_payload(f"""
             set -e
@@ -441,12 +440,12 @@ class CephFSMountBase(object):
         ip = IP(self.ceph_brx_net)[-2]
         mask = self.ceph_brx_net.split('/')[1]
 
-        p = self.client_remote.run(args=['route'], stderr=StringIO(),
-                                   stdout=StringIO(), timeout=(5*60))
-        p = re.findall(r'default .*', p.stdout.getvalue())
-        if p == False:
+        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 = p[0].split()[7]
+        gw = defaults[0].split()[4]
+
         self.run_shell_payload(f"""
             set -e
             sudo iptables -D FORWARD -o {gw} -i ceph-brx -j ACCEPT