diff options
| author | Mark Stapp <mjs.ietf@gmail.com> | 2024-04-16 11:32:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-16 11:32:18 -0400 |
| commit | 84d1fb19e22a5f0d13d3bbb7c74e9948773e66f3 (patch) | |
| tree | 1d26f809d9e26ba75a92a5e0604368cc1b10af17 | |
| parent | 314e9f9803835f12446692b068ef17ee21325130 (diff) | |
| parent | c1356f0e85e7b8480295d38b843a729d4a491d41 (diff) | |
Merge pull request #15709 from chiragshah6/fdev2
tools: frr-reload strip interface vrf ctx line
| -rwxr-xr-x | tools/frr-reload.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py index ef92e8b59f..b6e67fc7d2 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -220,6 +220,23 @@ def get_normalized_mac_ip_line(line): return line +def get_normalized_interface_vrf(line): + """ + If 'interface <int_name> vrf <vrf_name>' is present in file, + we need to remove the explicit "vrf <vrf_name>" + so that the context information is created + correctly and configurations are matched appropriately. + """ + + intf_vrf = re.search("interface (\S+) vrf (\S+)", line) + if intf_vrf: + old_line = "vrf %s" % intf_vrf.group(2) + new_line = line.replace(old_line, "").strip() + return new_line + + return line + + # This dictionary contains a tree of all commands that we know start a # new multi-line context. All other commands are treated either as # commands inside a multi-line context or as single-line contexts. This @@ -295,6 +312,10 @@ class Config(object): # Compress duplicate whitespaces line = " ".join(line.split()) + # Remove 'vrf <vrf_name>' from 'interface <x> vrf <vrf_name>' + if line.startswith("interface ") and "vrf" in line: + line = get_normalized_interface_vrf(line) + if ":" in line: line = get_normalized_mac_ip_line(line) |
