summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-08-23 20:14:14 +0200
committerChristian Breunig <christian@breunig.cc>2023-08-23 20:18:23 +0200
commitec23c669710a1f98fd1bd2095ffb861007374bda (patch)
tree92bdcf009a1720ea3934b38343e46d832ff975ae /src/conf_mode
parentb88b11ee73601155a485956be80971a697a7f4d6 (diff)
downloadvyos-1x-ec23c669710a1f98fd1bd2095ffb861007374bda.tar.gz
vyos-1x-ec23c669710a1f98fd1bd2095ffb861007374bda.zip
vrf: T5428: move helpers to common vyos.utils.network module
Helper functions can and will be re-use din different code places.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/vrf.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py
index be867b208..6ac79b9fa 100755
--- a/src/conf_mode/vrf.py
+++ b/src/conf_mode/vrf.py
@@ -28,6 +28,7 @@ from vyos.template import render
from vyos.template import render_to_string
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
+from vyos.utils.network import interface_exists
from vyos.utils.process import call
from vyos.utils.process import cmd
from vyos.utils.process import popen
@@ -143,7 +144,7 @@ def verify(vrf):
raise ConfigError(f'VRF "{name}" table id is mandatory!')
# routing table id can't be changed - OS restriction
- if os.path.isdir(f'/sys/class/net/{name}'):
+ if interface_exists(name):
tmp = str(dict_search('linkinfo.info_data.table', get_interface_config(name)))
if tmp and tmp != vrf_config['table']:
raise ConfigError(f'VRF "{name}" table id modification not possible!')
@@ -245,7 +246,7 @@ def apply(vrf):
for name, config in vrf['name'].items():
table = config['table']
- if not os.path.isdir(f'/sys/class/net/{name}'):
+ if not interface_exists(name):
# For each VRF apart from your default context create a VRF
# interface with a separate routing table
call(f'ip link add {name} type vrf table {table}')