From bbae4221e39d81e81136c047dfa487a21d0022a9 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 17 Dec 2024 20:17:02 +0100 Subject: frrender: T6746: ensure there are no empty lines in the rendered FRR configuration --- python/vyos/frrender.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py index 95d6c7243..7221d5053 100644 --- a/python/vyos/frrender.py +++ b/python/vyos/frrender.py @@ -136,7 +136,7 @@ class FRRender: output += '\n' if 'vrf' in config and 'name' in config['vrf']: - output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf']) + '\n' + output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf']) for vrf, vrf_config in config['vrf']['name'].items(): if 'protocols' not in vrf_config: continue @@ -145,6 +145,12 @@ class FRRender: output += inline_helper(vrf_config['protocols']) + # remove any accidently added empty newline to not confuse FRR + output = os.linesep.join([s for s in output.splitlines() if s]) + + if '!!' in output: + raise ConfigError('FRR configuration contains "!!" which is not allowed') + debug(output) debug('======< RENDERING CONFIG COMPLETE >======') write_file(self._frr_conf, output) -- cgit v1.2.3