diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-12-08 09:51:27 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-12-08 09:52:12 +0100 |
commit | a17c70449a766dbc00a7ab8438c13a2a12745614 (patch) | |
tree | 8f09baa442916af6da9d7e1c10b22ca974b10de8 /src/conf_mode/protocols_mpls.py | |
parent | c3190d923b0e7293b1c7caae21a59c5fd5b2d7de (diff) | |
download | vyos-1x-a17c70449a766dbc00a7ab8438c13a2a12745614.tar.gz vyos-1x-a17c70449a766dbc00a7ab8438c13a2a12745614.zip |
mpls: T4024: use FRRConfig() class for config reloading
Diffstat (limited to 'src/conf_mode/protocols_mpls.py')
-rwxr-xr-x | src/conf_mode/protocols_mpls.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/conf_mode/protocols_mpls.py b/src/conf_mode/protocols_mpls.py index 3b27608da..d424338d8 100755 --- a/src/conf_mode/protocols_mpls.py +++ b/src/conf_mode/protocols_mpls.py @@ -74,28 +74,15 @@ def generate(mpls): return None def apply(mpls): - # Define dictionary that will load FRR config - frr_cfg = {} + ldpd_damon = 'ldpd' # Save original configuration prior to starting any commit actions - frr_cfg['original_config'] = frr.get_configuration(daemon='ldpd') - frr_cfg['modified_config'] = frr.replace_section(frr_cfg['original_config'], mpls['new_frr_config'], from_re='mpls.*') - - # If FRR config is blank, rerun the blank commit three times due to frr-reload - # behavior/bug not properly clearing out on one commit. - if mpls['new_frr_config'] == '': - for x in range(3): - frr.reload_configuration(frr_cfg['modified_config'], daemon='ldpd') - elif not 'ldp' in mpls: - for x in range(3): - frr.reload_configuration(frr_cfg['modified_config'], daemon='ldpd') - else: - # FRR mark configuration will test for syntax errors and throws an - # exception if any syntax errors is detected - frr.mark_configuration(frr_cfg['modified_config']) + frr_cfg = frr.FRRConfig() - # Commit resulting configuration to FRR, this will throw CommitError - # on failure - frr.reload_configuration(frr_cfg['modified_config'], daemon='ldpd') + frr_cfg.load_configuration(ldpd_damon) + frr_cfg.modify_section(f'^mpls ldp') + frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty|end)', mpls['new_frr_config']) + for x in range(3): + frr_cfg.commit_configuration(ldpd_damon) # Set number of entries in the platform label tables labels = '0' |