diff options
author | John Estabrook <jestabro@vyos.io> | 2024-07-14 16:31:58 -0500 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-17 13:21:10 +0000 |
commit | 08f524a62f4a805a63503af64ed1b26fa48c6337 (patch) | |
tree | 1d0ceb4c98c33570babe3698a904a1bc71c238b3 /python/vyos | |
parent | 655ad2e9a5890b31cb906a17a3f9ea9937a6883f (diff) | |
download | vyos-1x-08f524a62f4a805a63503af64ed1b26fa48c6337.tar.gz vyos-1x-08f524a62f4a805a63503af64ed1b26fa48c6337.zip |
configdep: T6559: use single dependency list with reset under configd
(cherry picked from commit 52d08b1ec5b2943744daac7123e35fd415f85db2)
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/config.py | 1 | ||||
-rw-r--r-- | python/vyos/configdep.py | 18 |
2 files changed, 9 insertions, 10 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py index cca65f0eb..b7ee606a9 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -140,6 +140,7 @@ class Config(object): self._level = [] self._dict_cache = {} + self.dependency_list = [] (self._running_config, self._session_config) = self._config_source.get_configtree_tuple() diff --git a/python/vyos/configdep.py b/python/vyos/configdep.py index 141c7baf7..e0fe1ddac 100644 --- a/python/vyos/configdep.py +++ b/python/vyos/configdep.py @@ -33,7 +33,7 @@ if typing.TYPE_CHECKING: dependency_dir = os.path.join(directories['data'], 'config-mode-dependencies') -dependent_func: dict[str, list[typing.Callable]] = {} +dependency_list: list[typing.Callable] = [] DEBUG = False @@ -122,26 +122,24 @@ def def_closure(target: str, config: 'Config', def set_dependents(case: str, config: 'Config', tagnode: typing.Optional[str] = None): - global dependent_func + global dependency_list + + dependency_list = config.dependency_list d = get_dependency_dict(config) k = caller_name() - - if hasattr(config, 'dependent_func'): - dependent_func = getattr(config, 'dependent_func') - - l = dependent_func.setdefault(k, []) + l = dependency_list for target in d[k][case]: func = def_closure(target, config, tagnode) append_uniq(l, func) - debug_print(f'set_dependents: caller {k}, dependents {names_of(l)}') + debug_print(f'set_dependents: caller {k}, current dependents {names_of(l)}') def call_dependents(): k = caller_name() - l = dependent_func.get(k, []) - debug_print(f'call_dependents: caller {k}, dependents {names_of(l)}') + l = dependency_list + debug_print(f'call_dependents: caller {k}, remaining dependents {names_of(l)}') while l: f = l.pop(0) debug_print(f'calling: {f.__name__}') |