devops_utils.plugin module

Implements plugin mechanism for the devops-utils image.

The location of the root plugin directory is defined in main package: devops_utils.PLUGIN_DIR.

The function load_plugins() is used to load all plugins of a given type, whereas get_plugins() can be used to just get a list of paths to the plugin files.

devops_utils.plugin.get_plugins(type_, basedir='/etc/devops-utils', pattern='*')[source]

Return a tuple of filenames of plugins of a given type.

  • type (str) – type of plugins, i.e. init or runner
  • basedir (str) – base directory to look up plugins in
  • pattern (str) – glob pattern to match against plugin names
devops_utils.plugin.load_plugins(type_, globals, basedir='/etc/devops-utils', pattern='*')[source]

Load plugins of given type.

The plugin files are looked up in ${type}_plugins directory under PLUGIN_DIR. They are execfile()d in the global namespace of the module.

The reason the plugins are exec’ed and not imported is so that it is easier for derived images to add plugins, as they can just drop files into a known directory.

  • type (str) – type of plugins, i.e. init or runner
  • globals (dict) – as for execfile()