Werk #11118: Plugin development: make all includes imports
Komponente | Checks & agents |
Titel | Plugin development: make all includes imports |
Datum | 19.10.2020 |
Checkmk Edition | Checkmk Raw (CRE) |
Checkmk-Version | 2.0.0i1 |
Level | Kleine Änderung |
Klasse | Neues Feature |
Kompatibilität | Inkompatibel - Manuelle Interaktion könnte erforderlich sein |
This Werk only affects users who have developed their own check or inventory plugins and are using some of the shipped includes in them.
The *.include files have been moved to a dedicated module and are replaced with imports.
Note that the "include" mechanism is still available. If you are using your own include file you can continue to to so. However, if you are using (or shadowing) one of the shipped include files, you will need to change your plugins.
Users who are using code from a shipped include file should adapt their plugin in the following way:
- drop the "includes" keyword from the check_info
- import the required names from the module coresponding to the former include file
For example: If you used the line
"includes": ["temperature.include"],
to access the check_temperature function, you should now add the line
from cmk.base.check_legacy_includes.temperature import check_temperature
at the top of your plugin.
You can grep for "temperature import" in the checks directory for some examples. The checks/ directory can be found either at the top level of the git repository, or in in the share/check_mk/ folder of your site. Note that a wildcard import is used currently, but this is considered bad practice. You should explicitly import the required names.
If you have made local changes to an include file but not to the plugin that should be affected, you need to do the reverse: Locally change said plugin to re-introduce the "includes" key to the check_info and remove the corresponding import statement.