diff options
author | Christian Breunig <christian@breunig.cc> | 2023-09-05 19:37:04 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-09-05 19:37:04 +0200 |
commit | 5c2b49092ca1fc56cf198ca89630ec97fddd64b3 (patch) | |
tree | 9bb8e159090f2145d02b185b9f836afb1ebc6e7c /python/vyos | |
parent | 6c32e17a75199f9acf9e2c33b3480fc27257622d (diff) | |
download | vyos-1x-5c2b49092ca1fc56cf198ca89630ec97fddd64b3.tar.gz vyos-1x-5c2b49092ca1fc56cf198ca89630ec97fddd64b3.zip |
smoketest: T5241: re-work netns assertions and provide common utility helper
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/utils/network.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 4706dbfb7..abc382766 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -42,11 +42,17 @@ def interface_exists(interface) -> bool: def is_netns_interface(interface, netns): from vyos.utils.process import rc_cmd - rc, out = rc_cmd(f'ip netns exec {netns} ip link show dev {interface}') + rc, out = rc_cmd(f'sudo ip netns exec {netns} ip link show dev {interface}') if rc == 0: return True return False +def get_netns_all() -> list: + from json import loads + from vyos.utils.process import cmd + tmp = loads(cmd('ip --json netns ls')) + return [ netns['name'] for netns in tmp ] + def get_vrf_members(vrf: str) -> list: """ Get list of interface VRF members |