diff options
Diffstat (limited to 'cloudinit/config/modules.py')
-rw-r--r-- | cloudinit/config/modules.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/cloudinit/config/modules.py b/cloudinit/config/modules.py index 6716fc32..def6b795 100644 --- a/cloudinit/config/modules.py +++ b/cloudinit/config/modules.py @@ -7,6 +7,7 @@ # This file is part of cloud-init. See LICENSE file for license information. import copy +from inspect import signature from types import ModuleType from typing import Dict, List, NamedTuple, Optional @@ -221,17 +222,12 @@ class Modules: # and which ones failed + the exception of why it failed failures = [] which_ran = [] - for (mod, name, freq, args) in mostly_mods: + for mod, name, freq, args in mostly_mods: try: LOG.debug( "Running module %s (%s) with frequency %s", name, mod, freq ) - # Use the configs logger and not our own - # TODO(harlowja): possibly check the module - # for having a LOG attr and just give it back - # its own logger? - func_args = [name, self.cfg, cc, LOG, args] # Mark it as having started running which_ran.append(name) # This name will affect the semaphore name created @@ -241,8 +237,22 @@ class Modules: myrep = ReportEventStack( name=run_name, description=desc, parent=self.reporter ) + func_args = { + "name": name, + "cfg": self.cfg, + "cloud": cc, + "args": args, + } with myrep: + func_signature = signature(mod.handle) + func_params = func_signature.parameters + if len(func_params) == 5: + util.deprecate( + deprecated="Config modules with a `log` parameter", + deprecated_version="23.2", + ) + func_args.update({"log": LOG}) ran, _r = cc.run( run_name, mod.handle, func_args, freq=freq ) |