From 73cc357b757eb6129db286709812996ebcc4fd19 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 24 Jan 2021 19:27:45 +0100 Subject: ospf(v3): T3236: T3244: adjust to route-map converted name (_ for -) A hyphen in a route-map name will be converted to _, take care about this effect during validation. --- python/vyos/configverify.py | 4 +++- smoketest/scripts/cli/test_protocols_ospf.py | 6 +++--- src/conf_mode/protocols_ospf.py | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index de88310e8..abd91583d 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -323,7 +323,9 @@ def verify_route_maps(config): if 'redistribute' in config: for protocol, protocol_config in config['redistribute'].items(): if 'route_map' in protocol_config: - route_map = protocol_config['route_map'] + # A hyphen in a route-map name will be converted to _, take care + # about this effect during validation + route_map = protocol_config['route_map'].replace('-','_') # 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}" ' \ diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py index d78528365..d47838d8c 100755 --- a/smoketest/scripts/cli/test_protocols_ospf.py +++ b/smoketest/scripts/cli/test_protocols_ospf.py @@ -25,8 +25,7 @@ from vyos.util import process_named_running PROCESS_NAME = 'ospfd' base_path = ['protocols', 'ospf'] -route_map = 'foobarbaz' -route_map_seq = '10' +route_map = 'foo-bar-baz10' def getFRROSPFconfig(): return cmd('vtysh -c "show run" | sed -n "/router ospf/,/^!/p"') @@ -34,7 +33,8 @@ def getFRROSPFconfig(): class TestProtocolsOSPF(unittest.TestCase): def setUp(self): self.session = ConfigSession(os.getpid()) - self.session.set(['policy', 'route-map', route_map, 'rule', route_map_seq, 'action', 'permit']) + self.session.set(['policy', 'route-map', route_map, 'rule', '10', 'action', 'permit']) + self.session.set(['policy', 'route-map', route_map, 'rule', '20', 'action', 'permit']) def tearDown(self): # Check for running process diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index 9842d26cd..7c0ffbd27 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -94,6 +94,13 @@ def get_config(config=None): ospf['area'][area]['virtual_link'][virtual_link] = dict_merge( default_values, ospf['area'][area]['virtual_link'][virtual_link]) + # We also need some additional information from the config, prefix-lists + # and route-maps for instance. They will be used in verify() + base = ['policy'] + tmp = conf.get_config_dict(base, key_mangling=('-', '_')) + # Merge policy dict into OSPF dict + ospf = dict_merge(tmp, ospf) + return ospf def verify(ospf): -- cgit v1.2.3