Skip to content

Commit e1255d9

Browse files
authored
using re to determine default route interface (#651)
* using re to determine default route interface
1 parent bbace6e commit e1255d9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

testinfra/modules/interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# limitations under the License.
1212

1313
import json
14+
import re
1415

1516
from testinfra.modules.base import Module
1617
from testinfra.utils import cached_property
@@ -147,7 +148,9 @@ def default(cls, family=None):
147148
out = cls.check_output("{} route ls".format(_default._ip))
148149
for line in out.splitlines():
149150
if "default" in line:
150-
_default.name = line.strip().rsplit(" ", 1)[-1]
151+
match = re.search(r"dev\s(\S+)", line)
152+
if match:
153+
_default.name = match.group(1)
151154
return _default
152155

153156
@classmethod

0 commit comments

Comments
 (0)