Selaa lähdekoodia

SDN/bird: Move bool->string translation into template

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 2 vuotta sitten
vanhempi
commit
1fa7f5166b
3 muutettua tiedostoa jossa 9 lisäystä ja 16 poistoa
  1. 3 0
      _modules/ffho.py
  2. 0 5
      _modules/ffho_net.py
  3. 6 11
      bird/IGP.conf

+ 3 - 0
_modules/ffho.py

@@ -5,3 +5,6 @@ def re_replace (pattern, replacement, string):
 
 def re_search (pattern, string, flags = 0):
 	return re.search (pattern, string, flags)
+
+def is_bool (value):
+	return type (value) == bool

+ 0 - 5
_modules/ffho_net.py

@@ -1334,11 +1334,6 @@ def get_ospf_interface_config (node_config, grains_id):
 		for attr, val in ospf_config_pillar.items ():
 			ospf_config[attr] = val
 
-		# Convert boolean values to 'yes' / 'no' string values
-		for attr, val in ospf_config.items ():
-			if type (val) == bool:
-				ospf_config[attr] = 'yes' if val else 'no'
-
 		# Store interface configuration
 		ospf_interfaces[iface] = ospf_config
 

+ 6 - 11
bird/IGP.conf

@@ -56,16 +56,6 @@ protocol ospf IGP {
 			stub yes;
 		};
 
-{#-
- # Wired / Wireless IP-Backbone links
- #
- # Prefer direct Layer2 connections (via Ethernet cable or WBBL) between nodes
- # Vlan 10xy are direct wired Ethernet connection
- # Vlan 20xy are AF-X based WBBL
- # Vlan 22xy are non-AF-X based WBBL
- #
- # Watch management interfaces as stub interfaces.
- #}
 {%- set ospf_interface_config = salt['ffho_net.get_ospf_interface_config'](node_config, grains['id']) %}
 {%- for iface in ospf_interface_config|sort %}
   {%- set config = ospf_interface_config.get (iface) %}
@@ -79,7 +69,12 @@ protocol ospf IGP {
 			# {{ config.get ('desc') }}
     {%- endif %}
     {%- for attr in config|sort if attr not in ['desc'] %}
-			{{ attr }} {{ config.get (attr) }};
+      {%- set value = config.get (attr) %}
+      {#- 'is bool' only introduced in Jinja 2.11 #}
+      {%- if salt['ffho.is_bool'](value) %}
+        {%- set value = 'yes' if value else 'no' %}
+      {%- endif %}
+			{{ attr }} {{ value }};
     {%- endfor %}
 		};