From e32ce63b52eff0255d602b475d90cd97d3b282c1 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 6 Jan 2023 08:14:44 +0100 Subject: static: T4883: fix KeyError: 'table' Commit dafb0da2 ("static: T4883: add a description field for routing tables") added an iproute2 description table but lacked checking if the key exists. This has been fixed and also converted to Jinja2 to keep the "common" style inside the routing protocols. It might feel overengineered indeed. --- data/templates/iproute2/static.conf.j2 | 8 ++++++++ data/templates/iproute2/vrf.conf.j2 | 9 +++++++++ data/templates/vrf/vrf.conf.j2 | 9 --------- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 data/templates/iproute2/static.conf.j2 create mode 100644 data/templates/iproute2/vrf.conf.j2 delete mode 100644 data/templates/vrf/vrf.conf.j2 (limited to 'data/templates') diff --git a/data/templates/iproute2/static.conf.j2 b/data/templates/iproute2/static.conf.j2 new file mode 100644 index 000000000..10c9bdab7 --- /dev/null +++ b/data/templates/iproute2/static.conf.j2 @@ -0,0 +1,8 @@ +# Generated by VyOS (protocols_static.py), do not edit by hand +{% if table is vyos_defined %} +{% for t, t_options in table.items() %} +{% if t_options.description is vyos_defined %} +{{ "%-6s" | format(t) }} {{ "%-40s" | format(t_options.description) }} +{% endif %} +{% endfor %} +{% endif %} diff --git a/data/templates/iproute2/vrf.conf.j2 b/data/templates/iproute2/vrf.conf.j2 new file mode 100644 index 000000000..d31d23574 --- /dev/null +++ b/data/templates/iproute2/vrf.conf.j2 @@ -0,0 +1,9 @@ +### Autogenerated by vrf.py ### +# +# Routing table ID to name mapping reference +# id vrf name comment +{% if name is vyos_defined %} +{% for vrf, vrf_config in name.items() %} +{{ "%-10s" | format(vrf_config.table) }} {{ "%-16s" | format(vrf) }} {{ '# ' ~ vrf_config.description if vrf_config.description is vyos_defined }} +{% endfor %} +{% endif %} diff --git a/data/templates/vrf/vrf.conf.j2 b/data/templates/vrf/vrf.conf.j2 deleted file mode 100644 index d31d23574..000000000 --- a/data/templates/vrf/vrf.conf.j2 +++ /dev/null @@ -1,9 +0,0 @@ -### Autogenerated by vrf.py ### -# -# Routing table ID to name mapping reference -# id vrf name comment -{% if name is vyos_defined %} -{% for vrf, vrf_config in name.items() %} -{{ "%-10s" | format(vrf_config.table) }} {{ "%-16s" | format(vrf) }} {{ '# ' ~ vrf_config.description if vrf_config.description is vyos_defined }} -{% endfor %} -{% endif %} -- cgit v1.2.3