diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-05-30 09:04:34 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-06-03 00:32:36 +0000 |
commit | e9c9d1a1e4f1bf876892b6e58f7288d36180889f (patch) | |
tree | 043f2f1f2087c4577479f0416a24c292a9149646 /python/vyos/util.py | |
parent | aef116371f786f5d711731fdc712ae83dc4a34e2 (diff) | |
download | vyos-1x-e9c9d1a1e4f1bf876892b6e58f7288d36180889f.tar.gz vyos-1x-e9c9d1a1e4f1bf876892b6e58f7288d36180889f.zip |
T5241: Support netns for veth and dummy interfaces
Add netns configuration for dummy and virtual-ethernet interfaces
Change Interface class to get/set data to netns
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 61ce59324..d83287fd2 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -906,14 +906,16 @@ def get_bridge_fdb(interface): tmp = loads(cmd(f'bridge -j fdb show dev {interface}')) return tmp -def get_interface_config(interface): +def get_interface_config(interface, netns=None): """ Returns the used encapsulation protocol for given interface. If interface does not exist, None is returned. """ - if not os.path.exists(f'/sys/class/net/{interface}'): + from vyos.util import run + netns_exec = f'ip netns exec {netns}' if netns else '' + if run(f'{netns_exec} test -e /sys/class/net/{interface}') != 0: return None from json import loads - tmp = loads(cmd(f'ip -d -j link show {interface}'))[0] + tmp = loads(cmd(f'{netns_exec} ip -d -j link show {interface}'))[0] return tmp def get_interface_address(interface): |