diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-08-25 21:14:04 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-08-25 21:14:52 +0200 |
commit | fed29e7df1abee6eb5bec38ae9b6cff03579a5d6 (patch) | |
tree | f607f63da5f69866991e58008d69380327a2d7f8 /python/vyos/configverify.py | |
parent | 8c7741cbdb1a38561bb0c82e5c8aff2109224c2e (diff) | |
download | vyos-1x-fed29e7df1abee6eb5bec38ae9b6cff03579a5d6.tar.gz vyos-1x-fed29e7df1abee6eb5bec38ae9b6cff03579a5d6.zip |
vyos.configverify: add common verify_common_route_maps() function
Partial backport of commit 421fa38445a, this is required to backport the
complete IS-IS functionality from current.
Diffstat (limited to 'python/vyos/configverify.py')
-rw-r--r-- | python/vyos/configverify.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 524eb6fd7..cff673a6e 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -385,3 +385,29 @@ def verify_diffie_hellman_length(file, min_keysize): return False +def verify_common_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! + """ + # XXX: This function is called in combination with a previous call to: + # tmp = conf.get_config_dict(['policy']) - see protocols_ospf.py as example. + # We should NOT call this with the key_mangling option as this would rename + # route-map hypens '-' to underscores '_' and one could no longer distinguish + # what should have been the "proper" route-map name, as foo-bar and foo_bar + # are two entire different route-map instances! + for route_map in ['route-map', 'route_map']: + if route_map not in config: + continue + tmp = config[route_map] + # Check if the specified route-map exists, if not error out + if dict_search(f'policy.route-map.{tmp}', config) == None: + raise ConfigError(f'Specified route-map "{tmp}" does not exist!') + + if 'redistribute' in config: + for protocol, protocol_config in config['redistribute'].items(): + if 'route_map' in protocol_config: + verify_route_map(protocol_config['route_map'], config) + |