summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-04-03 00:01:13 +0200
committerChristian Breunig <christian@breunig.cc>2024-04-03 00:01:13 +0200
commit4c7c168fe970b807750a05ceb66b70c0d8652535 (patch)
tree945345f3f465d9647d10f7fde742756d2c77e435 /python
parent86b632874288aa5707a94a4f28ca816e543823b9 (diff)
downloadvyos-1x-4c7c168fe970b807750a05ceb66b70c0d8652535.tar.gz
vyos-1x-4c7c168fe970b807750a05ceb66b70c0d8652535.zip
T6199: replace netifaces.interfaces() with common custom helpers
* Use interface_exists() outside of verify() * Use verify_interface_exists() in verify() to drop common error message
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configverify.py4
-rw-r--r--python/vyos/ifconfig/bridge.py7
2 files changed, 5 insertions, 6 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index 300647d21..55978ec9d 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -275,7 +275,7 @@ def verify_source_interface(config):
required by e.g. peth/MACvlan, MACsec ...
"""
import re
- from netifaces import interfaces
+ from vyos.utils.network import interface_exists
ifname = config['ifname']
if 'source_interface' not in config:
@@ -287,7 +287,7 @@ def verify_source_interface(config):
if tmp.match(src_ifname):
raise ConfigError(f'Can not source "{ifname}" from dynamic interface "{src_ifname}"!')
- if src_ifname not in interfaces():
+ if not interface_exists(src_ifname):
raise ConfigError(f'Specified source-interface {src_ifname} does not exist')
if 'source_interface_is_bridge_member' in config:
diff --git a/python/vyos/ifconfig/bridge.py b/python/vyos/ifconfig/bridge.py
index 7936e3da5..917f962b7 100644
--- a/python/vyos/ifconfig/bridge.py
+++ b/python/vyos/ifconfig/bridge.py
@@ -13,13 +13,12 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-from netifaces import interfaces
-
from vyos.ifconfig.interface import Interface
from vyos.utils.assertion import assert_boolean
from vyos.utils.assertion import assert_list
from vyos.utils.assertion import assert_positive
from vyos.utils.dict import dict_search
+from vyos.utils.network import interface_exists
from vyos.configdict import get_vlan_ids
from vyos.configdict import list_diff
@@ -314,7 +313,7 @@ class BridgeIf(Interface):
# remove interface from bridge
tmp = dict_search('member.interface_remove', config)
for member in (tmp or []):
- if member in interfaces():
+ if interface_exists(member):
self.del_port(member)
# enable/disable VLAN Filter
@@ -345,7 +344,7 @@ class BridgeIf(Interface):
for interface, interface_config in tmp.items():
# if interface does yet not exist bail out early and
# add it later
- if interface not in interfaces():
+ if not interface_exists(interface):
continue
# Bridge lower "physical" interface