summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-05 20:24:56 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-05 20:24:56 +0100
commitff52634f1d24356ffcd694a226f5313919b996e5 (patch)
tree97433bc24d9b5a2b6bcaf598f25d928ba732f2b1
parent5de6cd0247d77b2a679d7e1071e1f48a3e7c7a9d (diff)
downloadvyos-1x-ff52634f1d24356ffcd694a226f5313919b996e5.tar.gz
vyos-1x-ff52634f1d24356ffcd694a226f5313919b996e5.zip
vrf: T31: use vyos.ifconfig to set ifalias
-rwxr-xr-xsrc/conf_mode/vrf.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py
index 565db23d5..116d87455 100755
--- a/src/conf_mode/vrf.py
+++ b/src/conf_mode/vrf.py
@@ -20,8 +20,10 @@ import jinja2
from sys import exit
from copy import deepcopy
from subprocess import check_call, CalledProcessError
+
from vyos.config import Config
from vyos.configdict import list_diff
+from vyos.ifconfig import Interface
from vyos import ConfigError
config_file = r'/etc/iproute2/rt_tables.d/vyos-vrf.conf'
@@ -94,7 +96,7 @@ def get_config():
# configuration
for name in conf.list_nodes(cfg_base + ['name']):
vrf_inst = {
- 'description' : '\0',
+ 'description' : '',
'members': [],
'name' : name,
'table' : '',
@@ -196,8 +198,7 @@ def apply(vrf_config):
_cmd(f'ip -6 route add vrf {name} unreachable default metric 4278198272')
# set VRF description for e.g. SNMP monitoring
- with open(f'/sys/class/net/{name}/ifalias', 'w') as f:
- f.write(vrf['description'])
+ Interface(name).set_alias(vrf['description'])
# Linux routing uses rules to find tables - routing targets are then
# looked up in those tables. If the lookup got a matching route, the