summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-11-27 10:32:01 +0100
committerChristian Poessinger <christian@poessinger.com>2021-11-27 10:32:01 +0100
commitea3c7785d06ed341487efb800c141fa7a7797ba7 (patch)
tree059a597089379c38de08d724ec2094015e4e8ee7
parent1c15e9de76f81383a32e60d2af54444dbb0474a1 (diff)
downloadvyos-1x-ea3c7785d06ed341487efb800c141fa7a7797ba7.tar.gz
vyos-1x-ea3c7785d06ed341487efb800c141fa7a7797ba7.zip
frr: T3753: add default_add_before mnemonic for routing protocols to re-use code
-rw-r--r--python/vyos/frr.py1
-rwxr-xr-xsrc/conf_mode/policy.py4
-rwxr-xr-xsrc/conf_mode/protocols_bfd.py2
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py4
-rwxr-xr-xsrc/conf_mode/protocols_isis.py4
-rwxr-xr-xsrc/conf_mode/protocols_ospf.py4
-rwxr-xr-xsrc/conf_mode/protocols_ospfv3.py2
-rwxr-xr-xsrc/conf_mode/protocols_rip.py2
-rwxr-xr-xsrc/conf_mode/protocols_ripng.py2
-rwxr-xr-xsrc/conf_mode/protocols_rpki.py2
-rwxr-xr-xsrc/conf_mode/vrf_vni.py2
11 files changed, 15 insertions, 14 deletions
diff --git a/python/vyos/frr.py b/python/vyos/frr.py
index 616e4b3c9..2e515a9e4 100644
--- a/python/vyos/frr.py
+++ b/python/vyos/frr.py
@@ -91,6 +91,7 @@ path_vtysh = '/usr/bin/vtysh'
path_frr_reload = '/usr/lib/frr/frr-reload.py'
path_config = '/run/frr'
+default_add_before = r'(ip prefix-list .*|route-map .*|line vty|end)'
class FrrError(Exception):
pass
diff --git a/src/conf_mode/policy.py b/src/conf_mode/policy.py
index 1a03d520b..5c592a599 100755
--- a/src/conf_mode/policy.py
+++ b/src/conf_mode/policy.py
@@ -191,7 +191,7 @@ def apply(policy):
frr_cfg.modify_section(r'^bgp extcommunity-list .*')
frr_cfg.modify_section(r'^bgp large-community-list .*')
frr_cfg.modify_section(r'^route-map .*')
- frr_cfg.add_before('^line vty', policy['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, policy['new_frr_config'])
frr_cfg.commit_configuration(bgp_daemon)
# The route-map used for the FIB (zebra) is part of the zebra daemon
@@ -201,7 +201,7 @@ def apply(policy):
frr_cfg.modify_section(r'^ip prefix-list .*')
frr_cfg.modify_section(r'^ipv6 prefix-list .*')
frr_cfg.modify_section(r'^route-map .*')
- frr_cfg.add_before('^line vty', policy['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, policy['new_frr_config'])
frr_cfg.commit_configuration(zebra_daemon)
# If FRR config is blank, rerun the blank commit x times due to frr-reload
diff --git a/src/conf_mode/protocols_bfd.py b/src/conf_mode/protocols_bfd.py
index 59083efb8..f698e30d9 100755
--- a/src/conf_mode/protocols_bfd.py
+++ b/src/conf_mode/protocols_bfd.py
@@ -101,7 +101,7 @@ def apply(bfd):
frr_cfg = frr.FRRConfig()
frr_cfg.load_configuration(bfd_daemon)
frr_cfg.modify_section('^bfd', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', bfd['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, bfd['new_frr_config'])
frr_cfg.commit_configuration(bfd_daemon)
return None
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 68284e0f9..084198251 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -288,7 +288,7 @@ def apply(bgp):
# The route-map used for the FIB (zebra) is part of the zebra daemon
frr_cfg.load_configuration(zebra_daemon)
frr_cfg.modify_section(r'(\s+)?ip protocol bgp route-map [-a-zA-Z0-9.]+$', '', '(\s|!)')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', bgp['frr_zebra_config'])
+ frr_cfg.add_before(frr.default_add_before, bgp['frr_zebra_config'])
frr_cfg.commit_configuration(zebra_daemon)
# Generate empty helper string which can be ammended to FRR commands, it
@@ -299,7 +299,7 @@ def apply(bgp):
frr_cfg.load_configuration(bgp_daemon)
frr_cfg.modify_section(f'^router bgp \d+{vrf}$', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', bgp['frr_bgpd_config'])
+ frr_cfg.add_before(frr.default_add_before, bgp['frr_bgpd_config'])
frr_cfg.commit_configuration(bgp_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_isis.py b/src/conf_mode/protocols_isis.py
index 4505e2496..120fc68a0 100755
--- a/src/conf_mode/protocols_isis.py
+++ b/src/conf_mode/protocols_isis.py
@@ -215,7 +215,7 @@ def apply(isis):
# The route-map used for the FIB (zebra) is part of the zebra daemon
frr_cfg.load_configuration(zebra_daemon)
frr_cfg.modify_section(r'(\s+)?ip protocol isis route-map [-a-zA-Z0-9.]+$', '', '(\s|!)')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', isis['frr_zebra_config'])
+ frr_cfg.add_before(frr.default_add_before, isis['frr_zebra_config'])
frr_cfg.commit_configuration(zebra_daemon)
# Generate empty helper string which can be ammended to FRR commands, it
@@ -233,7 +233,7 @@ def apply(isis):
for interface in isis[key]:
frr_cfg.modify_section(f'^interface {interface}{vrf}$', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', isis['frr_isisd_config'])
+ frr_cfg.add_before(frr.default_add_before, isis['frr_isisd_config'])
frr_cfg.commit_configuration(isis_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py
index 6ccda2e5a..71eb39205 100755
--- a/src/conf_mode/protocols_ospf.py
+++ b/src/conf_mode/protocols_ospf.py
@@ -210,7 +210,7 @@ def apply(ospf):
# The route-map used for the FIB (zebra) is part of the zebra daemon
frr_cfg.load_configuration(zebra_daemon)
frr_cfg.modify_section(r'(\s+)?ip protocol ospf route-map [-a-zA-Z0-9.]+$', '', '(\s|!)')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ospf['frr_zebra_config'])
+ frr_cfg.add_before(frr.default_add_before, ospf['frr_zebra_config'])
frr_cfg.commit_configuration(zebra_daemon)
# Generate empty helper string which can be ammended to FRR commands, it
@@ -228,7 +228,7 @@ def apply(ospf):
for interface in ospf[key]:
frr_cfg.modify_section(f'^interface {interface}{vrf}$', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ospf['frr_ospfd_config'])
+ frr_cfg.add_before(frr.default_add_before, ospf['frr_ospfd_config'])
frr_cfg.commit_configuration(ospf_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py
index 536ffa690..bb05e65ac 100755
--- a/src/conf_mode/protocols_ospfv3.py
+++ b/src/conf_mode/protocols_ospfv3.py
@@ -83,7 +83,7 @@ def apply(ospfv3):
frr_cfg.load_configuration(frr_daemon)
frr_cfg.modify_section(r'^interface \S+', '')
frr_cfg.modify_section('^router ospf6$', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ospfv3['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, ospfv3['new_frr_config'])
frr_cfg.commit_configuration(frr_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py
index 6b78f6f2d..b7eaad745 100755
--- a/src/conf_mode/protocols_rip.py
+++ b/src/conf_mode/protocols_rip.py
@@ -114,7 +114,7 @@ def apply(rip):
frr_cfg.modify_section(r'interface \S+', '')
frr_cfg.modify_section('^router rip$', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', rip['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, rip['new_frr_config'])
frr_cfg.commit_configuration(rip_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_ripng.py b/src/conf_mode/protocols_ripng.py
index bc4954f63..eada236b5 100755
--- a/src/conf_mode/protocols_ripng.py
+++ b/src/conf_mode/protocols_ripng.py
@@ -105,7 +105,7 @@ def apply(ripng):
frr_cfg.modify_section(r'key chain \S+', '')
frr_cfg.modify_section(r'interface \S+', '')
frr_cfg.modify_section('router ripng', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ripng['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, ripng['new_frr_config'])
frr_cfg.commit_configuration(frr_daemon)
# Save configuration to /run/frr/config/frr.conf
diff --git a/src/conf_mode/protocols_rpki.py b/src/conf_mode/protocols_rpki.py
index 947c8ab7a..0688e542f 100755
--- a/src/conf_mode/protocols_rpki.py
+++ b/src/conf_mode/protocols_rpki.py
@@ -87,7 +87,7 @@ def apply(rpki):
frr_cfg = frr.FRRConfig()
frr_cfg.load_configuration(frr_daemon)
frr_cfg.modify_section('rpki', '')
- frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', rpki['new_frr_config'])
+ frr_cfg.add_before(frr.default_add_before, rpki['new_frr_config'])
frr_cfg.commit_configuration(frr_daemon)
return None
diff --git a/src/conf_mode/vrf_vni.py b/src/conf_mode/vrf_vni.py
index 50d60f0dc..ca7eb7849 100755
--- a/src/conf_mode/vrf_vni.py
+++ b/src/conf_mode/vrf_vni.py
@@ -48,7 +48,7 @@ def apply(vrf):
frr_cfg = frr.FRRConfig()
frr_cfg.load_configuration(frr_daemon)
frr_cfg.modify_section(f'^vrf .+$', '')
- frr_cfg.add_before(r'(interface .*|line vty)', vrf['new_frr_config'])
+ frr_cfg.add_before(r'(interface .*|line vty|end)', vrf['new_frr_config'])
frr_cfg.commit_configuration(frr_daemon)
# Save configuration to /run/frr/config/frr.conf