From 4400d11709a86fddf63a98cadc4241776afa3e35 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 1 May 2022 20:23:51 +0200
Subject: nhrp: T4353: fix Jinja2 linting errors

---
 data/templates/nhrp/opennhrp.conf.j2   | 42 ++++++++++++++++++++++++++++++++++
 data/templates/nhrp/opennhrp.conf.tmpl | 41 ---------------------------------
 src/conf_mode/protocols_nhrp.py        |  2 +-
 3 files changed, 43 insertions(+), 42 deletions(-)
 create mode 100644 data/templates/nhrp/opennhrp.conf.j2
 delete mode 100644 data/templates/nhrp/opennhrp.conf.tmpl

diff --git a/data/templates/nhrp/opennhrp.conf.j2 b/data/templates/nhrp/opennhrp.conf.j2
new file mode 100644
index 000000000..c040a8f14
--- /dev/null
+++ b/data/templates/nhrp/opennhrp.conf.j2
@@ -0,0 +1,42 @@
+{# j2lint: disable=jinja-variable-format #}
+# Created by VyOS - manual changes will be overwritten
+
+{% if tunnel is vyos_defined %}
+{%     for name, tunnel_conf in tunnel.items() %}
+{%         set type = 'spoke' if tunnel_conf.map is vyos_defined or tunnel_conf.dynamic_map is vyos_defined else 'hub' %}
+{%         set profile_name = profile_map[name] if profile_map is vyos_defined and name in profile_map else '' %}
+interface {{ name }} #{{ type }} {{ profile_name }}
+{%         if tunnel_conf.map is vyos_defined %}
+{%             for map, map_conf in tunnel_conf.map.items() %}
+{%                 set cisco = ' cisco' if map_conf.cisco is vyos_defined else '' %}
+{%                 set register = ' register' if map_conf.register is vyos_defined else '' %}
+    map {{ map }} {{ map_conf.nbma_address }}{{ register }}{{ cisco }}
+{%             endfor %}
+{%         endif %}
+{%         if tunnel_conf.dynamic_map is vyos_defined %}
+{%             for map, map_conf in tunnel_conf.dynamic_map.items() %}
+    dynamic-map {{ map }} {{ map_conf.nbma_domain_name }}
+{%             endfor %}
+{%         endif %}
+{%         if tunnel_conf.cisco_authentication is vyos_defined %}
+    cisco-authentication {{ tunnel_conf.cisco_authentication }}
+{%         endif %}
+{%         if tunnel_conf.holding_time is vyos_defined %}
+    holding-time {{ tunnel_conf.holding_time }}
+{%         endif %}
+{%         if tunnel_conf.multicast is vyos_defined %}
+    multicast {{ tunnel_conf.multicast }}
+{%         endif %}
+{%         for key in ['non_caching', 'redirect', 'shortcut', 'shortcut_destination'] %}
+{%             if key in tunnel_conf %}
+    {{ key | replace("_", "-") }}
+{%             endif %}
+{%         endfor %}
+{%         if tunnel_conf.shortcut_target is vyos_defined %}
+{%             for target, shortcut_conf in tunnel_conf.shortcut_target.items() %}
+    shortcut-target {{ target }}{{ ' holding-time ' + shortcut_conf.holding_time if shortcut_conf.holding_time is vyos_defined }}
+{%             endfor %}
+{%         endif %}
+
+{%     endfor %}
+{% endif %}
diff --git a/data/templates/nhrp/opennhrp.conf.tmpl b/data/templates/nhrp/opennhrp.conf.tmpl
deleted file mode 100644
index 721d41e49..000000000
--- a/data/templates/nhrp/opennhrp.conf.tmpl
+++ /dev/null
@@ -1,41 +0,0 @@
-# Created by VyOS - manual changes will be overwritten
-
-{% if tunnel is vyos_defined %}
-{%   for name, tunnel_conf in tunnel.items() %}
-{%     set type = 'spoke' if tunnel_conf.map is vyos_defined or tunnel_conf.dynamic_map is vyos_defined else 'hub' %}
-{%     set profile_name = profile_map[name] if profile_map is vyos_defined and name in profile_map else '' %}
-interface {{ name }} #{{ type }} {{ profile_name }}
-{%     if tunnel_conf.map is vyos_defined %}
-{%       for map, map_conf in tunnel_conf.map.items() %}
-{%         set cisco = ' cisco' if map_conf.cisco is vyos_defined else '' %}
-{%         set register = ' register' if map_conf.register is vyos_defined else '' %}
-    map {{ map }} {{ map_conf.nbma_address }}{{ register }}{{ cisco }}
-{%       endfor %}
-{%     endif %}
-{%     if tunnel_conf.dynamic_map is vyos_defined %}
-{%       for map, map_conf in tunnel_conf.dynamic_map.items() %}
-    dynamic-map {{ map }} {{ map_conf.nbma_domain_name }}
-{%       endfor %}
-{%     endif %}
-{%     if tunnel_conf.cisco_authentication is vyos_defined %}
-    cisco-authentication {{ tunnel_conf.cisco_authentication }}
-{%     endif %}
-{%     if tunnel_conf.holding_time is vyos_defined %}
-    holding-time {{ tunnel_conf.holding_time }}
-{%     endif %}
-{%     if tunnel_conf.multicast is vyos_defined %}
-    multicast {{ tunnel_conf.multicast }}
-{%     endif %}
-{%     for key in ['non_caching', 'redirect', 'shortcut', 'shortcut_destination'] %}
-{%       if key in tunnel_conf %}
-    {{ key | replace("_", "-") }}
-{%       endif %}
-{%     endfor %}
-{%     if tunnel_conf.shortcut_target is vyos_defined %}
-{%       for target, shortcut_conf in tunnel_conf.shortcut_target.items() %}
-    shortcut-target {{ target }}{{ ' holding-time ' + shortcut_conf.holding_time if shortcut_conf.holding_time is vyos_defined }}
-{%       endfor %}
-{%     endif %}
-
-{%   endfor %}
-{% endif %}
diff --git a/src/conf_mode/protocols_nhrp.py b/src/conf_mode/protocols_nhrp.py
index ff8ae8eeb..92b335085 100755
--- a/src/conf_mode/protocols_nhrp.py
+++ b/src/conf_mode/protocols_nhrp.py
@@ -84,7 +84,7 @@ def verify(nhrp):
     return None
 
 def generate(nhrp):
-    render(opennhrp_conf, 'nhrp/opennhrp.conf.tmpl', nhrp)
+    render(opennhrp_conf, 'nhrp/opennhrp.conf.j2', nhrp)
     return None
 
 def apply(nhrp):
-- 
cgit v1.2.3