Skip to content

Commit 46d7dd9

Browse files
author
Kyr Shatskyy
committed
qa/tasks/cephfs/mount: use 'ip r' instead 'route'
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 <[email protected]>
1 parent 388ef10 commit 46d7dd9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

qa/tasks/cephfs/mount.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,11 @@ def _setup_brx_and_nat(self):
296296
self.client_remote.run(args=args, timeout=(5*60), omit_sudo=False)
297297

298298
# Setup the NAT
299-
p = self.client_remote.run(args=['route'], stderr=StringIO(),
300-
stdout=StringIO(), timeout=(5*60))
301-
p = re.findall(r'default .*', p.stdout.getvalue())
302-
if p == False:
299+
routes = self.client_remote.sh('ip r', timeout=(5*60))
300+
defaults = re.findall(r'^default .*', routes)
301+
if defaults == False:
303302
raise RuntimeError("No default gw found")
304-
gw = p[0].split()[7]
303+
gw = defaults[0].split()[4]
305304

306305
self.run_shell_payload(f"""
307306
set -e
@@ -441,12 +440,12 @@ def _cleanup_brx_and_nat(self):
441440
ip = IP(self.ceph_brx_net)[-2]
442441
mask = self.ceph_brx_net.split('/')[1]
443442

444-
p = self.client_remote.run(args=['route'], stderr=StringIO(),
445-
stdout=StringIO(), timeout=(5*60))
446-
p = re.findall(r'default .*', p.stdout.getvalue())
447-
if p == False:
443+
routes = self.client_remote.sh('ip r', timeout=(5*60))
444+
defaults = re.findall(r'^default .*', routes)
445+
if defaults == False:
448446
raise RuntimeError("No default gw found")
449-
gw = p[0].split()[7]
447+
gw = defaults[0].split()[4]
448+
450449
self.run_shell_payload(f"""
451450
set -e
452451
sudo iptables -D FORWARD -o {gw} -i ceph-brx -j ACCEPT

0 commit comments

Comments
 (0)