Skip to content

Commit

Permalink
Merge pull request #15709 from chiragshah6/fdev2
Browse files Browse the repository at this point in the history
tools: frr-reload strip interface vrf ctx line
  • Loading branch information
mjstapp authored Apr 16, 2024
2 parents 314e9f9 + c1356f0 commit 84d1fb1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/frr-reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -295,6 +312,10 @@ def load_from_file(self, filename):
# 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)

Expand Down

0 comments on commit 84d1fb1

Please sign in to comment.