Investigate calling config dependency scripts in stages, for each canonical function: 'verify', 'generate', 'apply', instead of only calling the whole script at apply stage: example outlined by @zsdc in discussion:
def run_config_mode_script(script: str, config: 'Config', stages=[]): """Run configuration script Args: script (str): name of a script config (Config): current config stages (list, optional): list of functions from the script to execute. Defaults to []. """ path = os.path.join(directories['conf_mode'], script) name = canon_name(script) mod = load_as_module(name, path) config.set_level([]) try: c = mod.get_config(config) if stages: for stage in stages: getattr(mod, stage)(c) else: mod.verify(c) mod.generate(c) mod.apply(c) except (VyOSError, ConfigError) as e: raise ConfigError(repr(e))
def verify(config): ... call_dependents(['verify']) def apply(config): ... call_dependents(['apply'])
Implementation is clear, but we would need to consider ramifications. Restrictions on the dependency graph remain the same. Distinctions made here should likely be subsumed by pruning in the case of T5666 in service of T5660; doing otherwise would need a reconsideration of the general approach.
Note also: a general orchestration of config dependencies could be managed by vyos-configd, and eventually will be managed by vyconf, but we want to preserve for now the ability to run with/without the config daemon support.