From 5c2b49092ca1fc56cf198ca89630ec97fddd64b3 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 5 Sep 2023 19:37:04 +0200 Subject: smoketest: T5241: re-work netns assertions and provide common utility helper --- python/vyos/utils/network.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'python') 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 -- cgit v1.2.3