@@ -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,11 +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- routes = self .client_remote .sh ('ip r' , timeout = (5 * 60 ))
300- defaults = re .findall (r'^default .*' , routes )
301- if defaults == False :
302- raise RuntimeError ("No default gw found" )
303- gw = defaults [0 ].split ()[4 ]
306+ gw = self ._default_gateway ()
304307
305308 self .run_shell_payload (f"""
306309 set -e
@@ -440,11 +443,7 @@ def _cleanup_brx_and_nat(self):
440443 ip = IP (self .ceph_brx_net )[- 2 ]
441444 mask = self .ceph_brx_net .split ('/' )[1 ]
442445
443- routes = self .client_remote .sh ('ip r' , timeout = (5 * 60 ))
444- defaults = re .findall (r'^default .*' , routes )
445- if defaults == False :
446- raise RuntimeError ("No default gw found" )
447- gw = defaults [0 ].split ()[4 ]
446+ gw = self ._default_gateway ()
448447
449448 self .run_shell_payload (f"""
450449 set -e
0 commit comments