From f1973bcf16fcc5e38c5fa3d3749846470e8e4afa Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 27 Nov 2021 20:10:55 +0100 Subject: frr: T3753: autosave config when calling commit_configuration() --- python/vyos/frr.py | 11 ++++++++--- src/conf_mode/policy.py | 3 --- src/conf_mode/protocols_bgp.py | 3 --- src/conf_mode/protocols_isis.py | 2 -- src/conf_mode/protocols_ospf.py | 3 --- src/conf_mode/protocols_ospfv3.py | 2 -- src/conf_mode/protocols_rip.py | 3 --- src/conf_mode/protocols_ripng.py | 3 --- src/conf_mode/protocols_rpki.py | 3 --- src/conf_mode/protocols_static.py | 3 --- src/conf_mode/vrf_vni.py | 3 --- 11 files changed, 8 insertions(+), 31 deletions(-) diff --git a/python/vyos/frr.py b/python/vyos/frr.py index e5253350a..a8f115d9a 100644 --- a/python/vyos/frr.py +++ b/python/vyos/frr.py @@ -445,9 +445,11 @@ class FRRConfig: mark_configuration('\n'.join(self.config)) def commit_configuration(self, daemon=None): - '''Commit the current configuration to FRR - daemon: str with name of the FRR daemon to commit to or - None to use the consolidated config + ''' + Commit the current configuration to FRR daemon: str with name of the + FRR daemon to commit to or None to use the consolidated config. + + Configuration is automatically saved after apply ''' LOG.debug('commit_configuration: Commiting configuration') for i, e in enumerate(self.config): @@ -469,6 +471,9 @@ class FRRConfig: if count >= count_max: raise ConfigurationNotValid(f'Config commit retry counter ({count_max}) exceeded') + # Save configuration to /run/frr/config/frr.conf + save_configuration() + def modify_section(self, start_pattern, replacement='!', stop_pattern=r'\S+', remove_stop_mark=False, count=0): if isinstance(replacement, str): diff --git a/src/conf_mode/policy.py b/src/conf_mode/policy.py index 5f9fcab9f..e251396c7 100755 --- a/src/conf_mode/policy.py +++ b/src/conf_mode/policy.py @@ -204,9 +204,6 @@ def apply(policy): frr_cfg.add_before(frr.default_add_before, policy['new_frr_config']) frr_cfg.commit_configuration(zebra_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index 359bfff76..b88f0c4ef 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -302,9 +302,6 @@ def apply(bgp): 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 - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_isis.py b/src/conf_mode/protocols_isis.py index 0011e6fbf..9b4b215de 100755 --- a/src/conf_mode/protocols_isis.py +++ b/src/conf_mode/protocols_isis.py @@ -236,8 +236,6 @@ def apply(isis): 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 - frr.save_configuration() return None diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index 255560e19..9d1fb48e4 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -231,9 +231,6 @@ def apply(ospf): 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 - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py index 5d6ca7169..f1e490f48 100755 --- a/src/conf_mode/protocols_ospfv3.py +++ b/src/conf_mode/protocols_ospfv3.py @@ -102,8 +102,6 @@ def apply(ospfv3): frr_cfg.add_before(frr.default_add_before, ospfv3['new_frr_config']) frr_cfg.commit_configuration(ospf6_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() return None diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py index 96df41bdb..300f56489 100755 --- a/src/conf_mode/protocols_rip.py +++ b/src/conf_mode/protocols_rip.py @@ -131,9 +131,6 @@ def apply(rip): 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 - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_ripng.py b/src/conf_mode/protocols_ripng.py index d46a2216c..d9b8c0b30 100755 --- a/src/conf_mode/protocols_ripng.py +++ b/src/conf_mode/protocols_ripng.py @@ -116,9 +116,6 @@ def apply(ripng): frr_cfg.add_before(frr.default_add_before, ripng['new_frr_config']) frr_cfg.commit_configuration(ripng_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_rpki.py b/src/conf_mode/protocols_rpki.py index dadd8d6f4..4bd4e8650 100755 --- a/src/conf_mode/protocols_rpki.py +++ b/src/conf_mode/protocols_rpki.py @@ -95,9 +95,6 @@ def apply(rpki): frr_cfg.add_before(frr.default_add_before, rpki['new_frr_config']) frr_cfg.commit_configuration(bgp_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/protocols_static.py b/src/conf_mode/protocols_static.py index 5cfe37655..c1e427b16 100755 --- a/src/conf_mode/protocols_static.py +++ b/src/conf_mode/protocols_static.py @@ -114,9 +114,6 @@ def apply(static): frr_cfg.add_before(frr.default_add_before, static['new_frr_config']) frr_cfg.commit_configuration(static_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() - return None if __name__ == '__main__': diff --git a/src/conf_mode/vrf_vni.py b/src/conf_mode/vrf_vni.py index a357f30dd..680d79826 100755 --- a/src/conf_mode/vrf_vni.py +++ b/src/conf_mode/vrf_vni.py @@ -52,9 +52,6 @@ def apply(vrf): frr_cfg.add_before(frr.default_add_before, vrf['new_frr_config']) frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/config/frr.conf - frr.save_configuration() - return None if __name__ == '__main__': -- cgit v1.2.3