Skip to content

Commit dfa104e

Browse files
committed
Merge PR ceph#62259 into main
* refs/pull/62259/head: qa/tasks/cephfs/mount: introduce _default_gateway method qa/tasks/cephfs/mount: use 'ip r' instead 'route' Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents 1a947b3 + ebf1dbc commit dfa104e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

qa/tasks/cephfs/mount.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ def _set_filemode_on_mntpt(self):
264264
if 'permission denied' in stderr.getvalue().lower():
265265
pass
266266

267+
def _default_gateway(self):
268+
routes = self.client_remote.sh('ip r', timeout=(5*60))
269+
defaults = re.findall(r'^default .*', routes)
270+
if defaults == False:
271+
raise RuntimeError("No default gw found")
272+
return defaults[0].split()[4]
273+
267274
def _setup_brx_and_nat(self):
268275
# The ip for ceph-brx should be
269276
ip = IP(self.ceph_brx_net)[-2]
@@ -296,12 +303,7 @@ def _setup_brx_and_nat(self):
296303
self.client_remote.run(args=args, timeout=(5*60), omit_sudo=False)
297304

298305
# 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:
303-
raise RuntimeError("No default gw found")
304-
gw = p[0].split()[7]
306+
gw = self._default_gateway()
305307

306308
self.run_shell_payload(f"""
307309
set -e
@@ -441,12 +443,8 @@ def _cleanup_brx_and_nat(self):
441443
ip = IP(self.ceph_brx_net)[-2]
442444
mask = self.ceph_brx_net.split('/')[1]
443445

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:
448-
raise RuntimeError("No default gw found")
449-
gw = p[0].split()[7]
446+
gw = self._default_gateway()
447+
450448
self.run_shell_payload(f"""
451449
set -e
452450
sudo iptables -D FORWARD -o {gw} -i ceph-brx -j ACCEPT

0 commit comments

Comments
 (0)