From 114f8a9a66e49449e09ac3a1721db42626e54212 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 3 Sep 2023 14:34:08 +0200 Subject: netns: T5241: use common interface_exists() helper --- python/vyos/utils/network.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index fa86795eb..8b4385cfb 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -78,8 +78,7 @@ def get_interface_config(interface): """ Returns the used encapsulation protocol for given interface. If interface does not exist, None is returned. """ - import os - if not os.path.exists(f'/sys/class/net/{interface}'): + if not interface_exists(interface): return None from json import loads from vyos.utils.process import cmd @@ -90,8 +89,7 @@ def get_interface_address(interface): """ Returns the used encapsulation protocol for given interface. If interface does not exist, None is returned. """ - import os - if not os.path.exists(f'/sys/class/net/{interface}'): + if not interface_exists(interface): return None from json import loads from vyos.utils.process import cmd @@ -141,8 +139,7 @@ def is_wwan_connected(interface): def get_bridge_fdb(interface): """ Returns the forwarding database entries for a given interface """ - import os - if not os.path.exists(f'/sys/class/net/{interface}'): + if not interface_exists(interface): return None from json import loads from vyos.utils.process import cmd -- cgit v1.2.3