diff options
author | John Estabrook <jestabro@vyos.io> | 2024-02-27 14:54:50 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-02-28 14:02:49 -0600 |
commit | 70e1df1b5fcb3b1791cca320ed45b71e01e1ffda (patch) | |
tree | 66e586d26f2ab77144adcd341da14c854bdd0795 /python/vyos/configdep.py | |
parent | 5c173c5935eab3a8bd0f169759617c4296a92df7 (diff) | |
download | vyos-1x-70e1df1b5fcb3b1791cca320ed45b71e01e1ffda.tar.gz vyos-1x-70e1df1b5fcb3b1791cca320ed45b71e01e1ffda.zip |
configdep: T5660: remove global redundancies under vyos-configd
Diffstat (limited to 'python/vyos/configdep.py')
-rw-r--r-- | python/vyos/configdep.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/python/vyos/configdep.py b/python/vyos/configdep.py index 41252d8f5..73bd9ea96 100644 --- a/python/vyos/configdep.py +++ b/python/vyos/configdep.py @@ -33,9 +33,10 @@ if typing.TYPE_CHECKING: dependency_dir = os.path.join(directories['data'], 'config-mode-dependencies') -dependent_func: dict[str, list[typing.Callable]] = {} +local_dependent_func: dict[str, list[typing.Callable]] = {} DEBUG = False +FORCE_LOCAL = False def debug_print(s: str): if DEBUG: @@ -122,16 +123,25 @@ def set_dependents(case: str, config: 'Config', d = get_dependency_dict(config) k = canon_name_of_path(caller_name()) tag_ext = f'_{tagnode}' if tagnode is not None else '' - l = dependent_func.setdefault(k, []) + if hasattr(config, 'dependent_func') and not FORCE_LOCAL: + dependent_func = getattr(config, 'dependent_func') + l = dependent_func.setdefault('vyos_configd', []) + else: + dependent_func = local_dependent_func + l = dependent_func.setdefault(k, []) for target in d[k][case]: func = def_closure(target, config, tagnode) func.__name__ = f'{target}{tag_ext}' append_uniq(l, func) debug_print(f'set_dependents: caller {k}, dependents {names_of(l)}') -def call_dependents(): +def call_dependents(dependent_func: dict = None): k = canon_name_of_path(caller_name()) - l = dependent_func.get(k, []) + if dependent_func is None or FORCE_LOCAL: + dependent_func = local_dependent_func + l = dependent_func.get(k, []) + else: + l = dependent_func.get('vyos_configd', []) debug_print(f'call_dependents: caller {k}, dependents {names_of(l)}') while l: f = l.pop(0) |