diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-21 13:52:25 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-03-21 13:52:25 +0100 |
commit | 7547b699c1afdf3e37f288eb8805b8fb559e5105 (patch) | |
tree | 12d27bf1308b703e77ae3f2e190e344795647ec8 /src | |
parent | a234f616b9fff24b74f2b33dc83cf7c7edef3342 (diff) | |
download | vyos-1x-7547b699c1afdf3e37f288eb8805b8fb559e5105.tar.gz vyos-1x-7547b699c1afdf3e37f288eb8805b8fb559e5105.zip |
ospf: vrf: T2271: ease FRR interaction for config reload
Instead of multiple if/else paths, use a common vrf string variable which is
either populated or not. In addtion when interfaces are configured for a given
VRF, harden the regex for config reload.
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/protocols_ospf.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index 08347aa52..a655eaeca 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -154,11 +154,10 @@ def verify(ospf): f'concurrently for {interface}!') if 'vrf' in ospf: - # If interface specific options are set, we must ensure that - # the interface is bound to our requesting VRF. Due to the VyOS - # priorities the interface is bound to the VRF after creation - # of the VRF itself, and before any routing protocol is - # configured. + # If interface specific options are set, we must ensure that the + # interface is bound to our requesting VRF. Due to the VyOS + # priorities the interface is bound to the VRF after creation of + # the VRF itself, and before any routing protocol is configured. vrf = ospf['vrf'] tmp = get_interface_config(interface) if 'master' not in tmp or tmp['master'] != vrf: @@ -179,17 +178,18 @@ def apply(ospf): frr_cfg = frr.FRRConfig() frr_cfg.load_configuration(frr_daemon) + # Generate empty helper string which can be ammended to FRR commands, + # it will be either empty (default VRF) or contain the "vrf <name" statement + vrf = '' if 'vrf' in ospf: - vrf = ospf['vrf'] - frr_cfg.modify_section(f'^router ospf vrf {vrf}$', '') - else: - frr_cfg.modify_section('^router ospf$', '') + vrf = ' vrf ' + ospf['vrf'] + frr_cfg.modify_section(f'^router ospf{vrf}$', '') for key in ['interface', 'interface_removed']: if key not in ospf: continue for interface in ospf[key]: - frr_cfg.modify_section(f'^interface {interface}$', '') + frr_cfg.modify_section(f'^interface {interface}{vrf}$', '') frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ospf['new_frr_config']) frr_cfg.commit_configuration(frr_daemon) |