From: Kyr Shatskyy Date: Wed, 12 Mar 2025 12:01:12 +0000 (+0100) Subject: qa/tasks/cephfs/mount: introduce _default_gateway method X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F63130%2Fhead;p=ceph.git qa/tasks/cephfs/mount: introduce _default_gateway method Create function for getting default gateway in order to reduce code duplication. Signed-off-by: Kyr Shatskyy (cherry picked from commit ebf1dbca5f1492cac03ff847cda69839545a7da6) --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index c00ded82b56..818e90dd480 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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