made callbacks backwards compatible (#30625)
* made callbacks backwards compatible This fixes #30597 for those that were not inheriting from base. Added deprecation notice so those callbacks get updated. Callback must either inherit from base (directly or indirectly), which already implements this or implement set_options themselves. * added note about porting guide
This commit is contained in:
parent
875153d503
commit
131d417c7a
1 changed files with 12 additions and 2 deletions
|
@ -176,7 +176,12 @@ class TaskQueueManager:
|
||||||
raise AnsibleError("Invalid callback for stdout specified: %s" % self._stdout_callback)
|
raise AnsibleError("Invalid callback for stdout specified: %s" % self._stdout_callback)
|
||||||
else:
|
else:
|
||||||
self._stdout_callback = callback_loader.get(self._stdout_callback)
|
self._stdout_callback = callback_loader.get(self._stdout_callback)
|
||||||
self._stdout_callback.set_options(C.config.get_plugin_options('callback', self._stdout_callback._load_name))
|
try:
|
||||||
|
self._stdout_callback.set_options(C.config.get_plugin_options('callback', self._stdout_callback._load_name))
|
||||||
|
except AttributeError:
|
||||||
|
display.deprecated("%s stdout callback, does not support setting 'options', it will work for now, "
|
||||||
|
" but this will be required in the future and should be updated,"
|
||||||
|
" see the 2.4 porting guide for details." % self._stdout_callback._load_name, version="2.9")
|
||||||
stdout_callback_loaded = True
|
stdout_callback_loaded = True
|
||||||
else:
|
else:
|
||||||
raise AnsibleError("callback must be an instance of CallbackBase or the name of a callback plugin")
|
raise AnsibleError("callback must be an instance of CallbackBase or the name of a callback plugin")
|
||||||
|
@ -200,7 +205,12 @@ class TaskQueueManager:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
callback_obj = callback_plugin()
|
callback_obj = callback_plugin()
|
||||||
callback_obj .set_options(C.config.get_plugin_options('callback', callback_plugin._load_name))
|
try:
|
||||||
|
callback_obj .set_options(C.config.get_plugin_options('callback', callback_plugin._load_name))
|
||||||
|
except AttributeError:
|
||||||
|
display.deprecated("%s callback, does not support setting 'options', it will work for now, "
|
||||||
|
" but this will be required in the future and should be updated, "
|
||||||
|
" see the 2.4 porting guide for details." % self._stdout_callback._load_name, version="2.9")
|
||||||
self._callback_plugins.append(callback_obj)
|
self._callback_plugins.append(callback_obj)
|
||||||
|
|
||||||
self._callbacks_loaded = True
|
self._callbacks_loaded = True
|
||||||
|
|
Loading…
Reference in a new issue