Skip to content

Commit

Permalink
using re to determine default route interface (#651)
Browse files Browse the repository at this point in the history
* using re to determine default route interface
  • Loading branch information
sealeg committed May 19, 2023
1 parent bbace6e commit e1255d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion testinfra/modules/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

import json
import re

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

@classmethod
Expand Down

0 comments on commit e1255d9

Please sign in to comment.