From f854b55adb51eedc88024d70c950cd633c0986df Mon Sep 17 00:00:00 2001 From: Don Slice Date: Tue, 19 Jan 2021 13:24:49 -0800 Subject: [PATCH] tools: strip 'vrf default' from 'router bgp' line in frr-reload.py Since CUE defines the bgp defines the default bgp instance with an explicit 'vrf default', it causes problems for frr-reload when trying to match up with the the generated config without the 'vrf default' in the config. This patch strips the 'vrf default' when the new config file is read so all match up nicely. Ticket: CM-33044 Signed-off-by: Don Slice --- tools/frr-reload.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/frr-reload.py b/tools/frr-reload.py index 116e1003547b..ac51132f0ff9 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -211,6 +211,16 @@ def get_normalized_es_id(line): return line +def get_normalized_bgp_default(line): + """ + If 'router bgp vrf default' is entered, we need to remove the + explicit "vrf default" so that the context information is created + correctly and configurations are matched appropriately. + """ + new_line = line.replace("vrf default", "").strip() + + return new_line + def get_normalized_mac_ip_line(line): if line.startswith("evpn mh es"): return get_normalized_es_id(line) @@ -317,6 +327,10 @@ def load_from_file(self, filename): if line.startswith("interface ") and "vrf" in line: line = get_normalized_interface_vrf(line) + # remove 'vrf default' from 'router bgp x vrf default' + if line.startswith('router bgp') and "vrf default" in line: + line = get_normalized_bgp_default(line) + if ":" in line: line = get_normalized_mac_ip_line(line)