diff options
author | Christian Breunig <christian@breunig.cc> | 2024-12-11 20:14:45 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-12-16 22:24:50 +0100 |
commit | 55683a8406e17408021437cb35b57c48bd8b2ab1 (patch) | |
tree | bc149befb6ceadc94bf57503c65dd9267339edf0 /python | |
parent | 779f311e7fe81e3c85de28f13e4e12e33b255483 (diff) | |
download | vyos-1x-55683a8406e17408021437cb35b57c48bd8b2ab1.tar.gz vyos-1x-55683a8406e17408021437cb35b57c48bd8b2ab1.zip |
configd: T6746: handle FRR config reload as last step in commit
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configdict.py | 22 | ||||
-rw-r--r-- | python/vyos/configverify.py | 5 | ||||
-rw-r--r-- | python/vyos/frrender.py | 5 |
3 files changed, 22 insertions, 10 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index baffd94dd..f5e84267e 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -666,7 +666,7 @@ def get_accel_dict(config, base, chap_secrets, with_pki=False): return dict -def get_frrender_dict(conf) -> dict: +def get_frrender_dict(conf, argv=None) -> dict: from copy import deepcopy from vyos.config import config_dict_merge from vyos.frrender import frr_protocols @@ -675,6 +675,9 @@ def get_frrender_dict(conf) -> dict: # returned to the caller dict = {} + if argv and len(argv) > 1: + dict['vrf_context'] = argv[1] + def dict_helper_ospf_defaults(ospf, path): # We have gathered the dict representation of the CLI, but there are default # options which we need to update into the dictionary retrived. @@ -1024,7 +1027,11 @@ def get_frrender_dict(conf) -> dict: if 'bgp' in dict: dict['bgp']['dependent_vrfs'].update({vrf_name : {'protocols': tmp} }) - vrf['name'][vrf_name]['protocols'].update({'bgp' : tmp}) + + if 'protocols' not in vrf['name'][vrf_name]: + vrf['name'][vrf_name].update({'protocols': {'bgp' : tmp}}) + else: + vrf['name'][vrf_name]['protocols'].update({'bgp' : tmp}) # We need to check the CLI if the EIGRP node is present and thus load in all the default # values present on the CLI - that's why we have if conf.exists() @@ -1125,15 +1132,16 @@ def get_frrender_dict(conf) -> dict: dict.update({'vrf' : vrf}) + if os.path.exists(frr_debug_enable): + print('======== < BEGIN > ==========') + import pprint + pprint.pprint(dict) + print('========= < END > ===========') + # Use singleton instance of the FRR render class if hasattr(conf, 'frrender_cls'): frrender = getattr(conf, 'frrender_cls') dict.update({'frrender_cls' : frrender}) frrender.generate(dict) - if os.path.exists(frr_debug_enable): - print('======== < BEGIN > ==========') - import pprint - pprint.pprint(dict) - print('========= < END > ===========') return dict diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 4450dc16b..4084425b1 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -538,7 +538,10 @@ def verify_eapol(config: dict): for ca_cert in config['eapol']['ca_certificate']: verify_pki_ca_certificate(config, ca_cert) -def has_frr_protocol_in_dict(config_dict: dict, protocol: str, vrf: str=None) -> bool: +def has_frr_protocol_in_dict(config_dict: dict, protocol: str) -> bool: + vrf = None + if config_dict and 'vrf_context' in config_dict: + vrf = config_dict['vrf_context'] if vrf and protocol in (dict_search(f'vrf.name.{vrf}.protocols', config_dict) or []): return True if config_dict and protocol in config_dict: diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py index e02094bbb..f1bb39094 100644 --- a/python/vyos/frrender.py +++ b/python/vyos/frrender.py @@ -44,7 +44,8 @@ class FRRender: def generate(self, config): if not isinstance(config, dict): - raise ValueError('config must be of type dict') + tmp = type(config) + raise ValueError(f'Config must be of type "dict" and not "{tmp}"!') def inline_helper(config_dict) -> str: output = '!\n' @@ -136,7 +137,7 @@ class FRRender: emsg = '' while count < count_max: count += 1 - print('FRR: Reloading configuration - tries:', count, 'Python class ID:', id(self)) + debug(f'FRR: Reloading configuration - tries: {count} | Python class ID: {id(self)}') cmdline = '/usr/lib/frr/frr-reload.py --reload' if DEBUG_ON: |