summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-04 20:55:04 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-04 21:45:41 +0100
commit39dfcfb5077a4024c454f9cd127fc1f65529f591 (patch)
treef2b0e8ed9fa88198721182b574ab78eae9b47237 /src
parent93f7ae7f1ed1e218ef64d2582d11ac0ed769a438 (diff)
downloadvyos-1x-39dfcfb5077a4024c454f9cd127fc1f65529f591.tar.gz
vyos-1x-39dfcfb5077a4024c454f9cd127fc1f65529f591.zip
vrf: T31: create iproute2 table to name mapping reference
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/vrf.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py
index e31285dde..91d8f8432 100755
--- a/src/conf_mode/vrf.py
+++ b/src/conf_mode/vrf.py
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
+import jinja2
from sys import exit
from copy import deepcopy
@@ -23,6 +24,21 @@ from vyos.config import Config
from vyos.configdict import list_diff
from vyos import ConfigError
+config_file = r'/etc/iproute2/rt_tables.d/vyos-vrf.conf'
+
+# Please be careful if you edit the template.
+config_tmpl = """
+### Autogenerated by vrf.py ###
+#
+# Routing table ID to name mapping reference
+
+# id vrf name comment
+{% for vrf in vrf_add -%}
+{{ "%-10s" | format(vrf.table) }} {{ "%-16s" | format(vrf.name) }} # {{ vrf.description }}
+{% endfor -%}
+
+"""
+
default_config_data = {
'bind_to_all': 0,
'deleted': False,
@@ -141,6 +157,11 @@ def verify(vrf_config):
return None
def generate(vrf_config):
+ tmpl = jinja2.Template(config_tmpl)
+ config_text = tmpl.render(vrf_config)
+ with open(config_file, 'w') as f:
+ f.write(config_text)
+
return None
def apply(vrf_config):