Просмотр исходного кода

Allow override for loopback IP generator.

  Every rule has an exception. If there is a loopback_overwrite configuration
  for a node, use this instead of the generated IPs.

  This may come in handy when a node is only connected to the external VRF
  (or anything alike) and a router before this node takes care of connecting
  the external node to the rest of the network.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm 7 лет назад
Родитель
Сommit
8dd7a3286e
2 измененных файлов с 33 добавлено и 0 удалено
  1. 9 0
      _modules/ffho_net.py
  2. 24 0
      zz_EXAMPLE_PILLAR/nodes/mail.sls

+ 9 - 0
_modules/ffho_net.py

@@ -825,9 +825,18 @@ def get_loopback_ip (node_config, node_id, proto):
 	if not 'id' in node_config:
 		raise Exception ("get_loopback_ip(): No 'id' configured in pillar for node \"%s\"!" % node_id)
 
+	# Every rule has an exception.
+	# If there is a loopback_overwrite configuration for this node, use this instead of
+	# the generated IPs.
+	if 'loopback_override' in node_config:
+		if proto not in node_config['loopback_override']:
+			raise Exception ("get_loopback_ip(): No loopback_prefix configured for IP%s in node config / loopback_override!" % proto)
+
+		return node_config['loopback_override'][proto]
 
 	return "%s%s" % (loopback_prefix.get (proto), node_config.get ('id'))
 
+
 #
 # Get the router id (read: IPv4 Lo-IP) out of the given node config.
 def get_router_id (node_config, node_id):

+ 24 - 0
zz_EXAMPLE_PILLAR/nodes/mail.sls

@@ -0,0 +1,24 @@
+mail.in.ffho.net:
+  id: 30
+
+  loopback_override:
+    v4: 80.70.181.59
+    v6: 2a02:450:1::25
+
+  sysLocation: Vega
+
+  mailname: mail.ffho.net
+
+  roles:
+    - mx
+
+  ifaces:
+    eth0:
+      desc: "Upstream Vega"
+      prefixes:
+        - 80.70.181.59/32
+        - 2a02:450:1::25/64
+      pointopoint: 80.70.181.56
+      gateway:
+        - 80.70.181.56
+        - 2a02:450:1::1