diff options
author | John Estabrook <jestabro@vyos.io> | 2024-02-27 14:54:50 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-04-28 09:21:08 -0500 |
commit | d2ba96d8af035e6f20b928e7f95fb7c5bfa5fc95 (patch) | |
tree | 97142bab80ab777c6d6dccb4bbb24709a46b76e2 /python/vyos/configdep.py | |
parent | 0239ee33ec0651c969953782b9fea8eb0cdf78e6 (diff) | |
download | vyos-1x-d2ba96d8af035e6f20b928e7f95fb7c5bfa5fc95.tar.gz vyos-1x-d2ba96d8af035e6f20b928e7f95fb7c5bfa5fc95.zip |
configdep: T5660: remove global redundancies under vyos-configd
(cherry picked from commit 70e1df1b5fcb3b1791cca320ed45b71e01e1ffda)
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) |