summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-24 15:38:38 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-24 15:38:38 +0100
commit9b6b9f6cdfa7b911b79a312c4bdca0562f79b6f9 (patch)
tree6f932f0aaca50c144a9ea4c03799e5e5c20c61e2 /python
parent5ab6882f88036722f533f37331d9e5b63631f4b2 (diff)
downloadvyos-1x-9b6b9f6cdfa7b911b79a312c4bdca0562f79b6f9.tar.gz
vyos-1x-9b6b9f6cdfa7b911b79a312c4bdca0562f79b6f9.zip
ospf(v3): T3236: T3244: add verify() for used route-map existence
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configverify.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index bcaec55be..de88310e8 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -307,3 +307,24 @@ def verify_diffie_hellman_length(file, min_keysize):
return False
+def verify_route_maps(config):
+ """
+ Common helper function used by routing protocol implementations to perform
+ recurring validation if the specified route-map for either zebra to kernel
+ installation exists (this is the top-level route_map key) or when a route
+ is redistributed with a route-map that it exists!
+ """
+ if 'route_map' in config:
+ route_map = config['route_map']
+ # Check if the specified route-map exists, if not error out
+ if dict_search(f'policy.route_map.{route_map}', config) == None:
+ raise ConfigError(f'Specified route-map "{route_map}" does not exist!')
+
+ if 'redistribute' in config:
+ for protocol, protocol_config in config['redistribute'].items():
+ if 'route_map' in protocol_config:
+ route_map = protocol_config['route_map']
+ # Check if the specified route-map exists, if not error out
+ if dict_search(f'policy.route_map.{route_map}', config) == None:
+ raise ConfigError(f'Redistribution route-map "{route_map}" ' \
+ f'for "{protocol}" does not exist!')