Commit 200fe2eb authored by Ferreira da Silva, Rafael's avatar Ferreira da Silva, Rafael
Browse files

making module import dynamic based on enabled plugins

parent 47ff26f9
Pipeline #269322 canceled with stage
......@@ -114,24 +114,23 @@ class Plugins:
This will just configure the "shell" plugin
"""
for module_name in self.__module_names:
module = import_module(
f"zambeze.orchestration.plugin_modules.{module_name}"
)
for attribute_name in dir(module):
potential_plugin = getattr(module, attribute_name)
if isclass(potential_plugin):
if (
issubclass(potential_plugin, Plugin)
and attribute_name != "Plugin"
):
self._plugins[attribute_name.lower()] = potential_plugin(
logger=self.__logger
)
for key in self._plugins:
if key in config.keys():
obj = self._plugins.get(key)
obj.configure(config[key])
if module_name in config.keys() and module_name in self.__module_names:
module = import_module(
f"zambeze.orchestration.plugin_modules.{module_name}"
)
for attribute_name in dir(module):
potential_plugin = getattr(module, attribute_name)
if isclass(potential_plugin):
if (
issubclass(potential_plugin, Plugin)
and attribute_name != "Plugin"
):
self._plugins[attribute_name.lower()] = potential_plugin(
logger=self.__logger
)
obj = self._plugins.get(module_name)
obj.configure(config[module_name])
@property
def configured(self) -> list[str]:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment