summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-04-11 17:39:57 +0200
committerChristian Poessinger <christian@poessinger.com>2021-04-11 18:39:08 +0200
commit2239e47fb3b2ba66d9ec7ff1a4bf5f5cb512ff83 (patch)
treecc9a277edf00db280d09ce2bfcf150da71e15405
parentbfc8b264aae5b48247c28fc4d43d762f090c20dc (diff)
downloadvyos-1x-2239e47fb3b2ba66d9ec7ff1a4bf5f5cb512ff83.tar.gz
vyos-1x-2239e47fb3b2ba66d9ec7ff1a4bf5f5cb512ff83.zip
bgp: T3344: handle FRR vrf daemon configuration more elegant
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 262bb4711..ae210cf20 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -209,11 +209,12 @@ def apply(bgp):
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 bgp:
- vrf = bgp['vrf']
- frr_cfg.modify_section(f'^router bgp \d+ vrf {vrf}$', '')
- else:
- frr_cfg.modify_section('^router bgp \d+$', '')
+ vrf = ' vrf ' + bgp['vrf']
+ frr_cfg.modify_section(f'^router bgp \d+{vrf}$', '')
frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', bgp['new_frr_config'])
frr_cfg.commit_configuration(frr_daemon)