diff --git a/Dockerfile b/Dockerfile index f9f7c80..03e3b1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ LABEL org.opencontainers.image.source="https://github.com/SovereignCloudStack/ro ARG ROOKIFY_VERSION=0.0.0.dev1 ENV ROOKIFY_VERSION=$ROOKIFY_VERSION +ENV PYTHONPATH="${PYTHONPATH}:/app/rookify/src" WORKDIR /app/rookify diff --git a/src/rookify/modules/__init__.py b/src/rookify/modules/__init__.py index a5c4947..51af7e6 100644 --- a/src/rookify/modules/__init__.py +++ b/src/rookify/modules/__init__.py @@ -30,7 +30,16 @@ def _load_module(machine: Machine, config: Dict[str, Any], module_name: str) -> :return: returns tuple of preflight_modules, modules """ - module = importlib.import_module("rookify.modules.{0}".format(module_name)) + if "." in module_name: + absolute_module_name = module_name + else: + absolute_module_name = "rookify.modules.{0}".format(module_name) + + try: + module = importlib.import_module(absolute_module_name) + except ModuleNotFoundError as e: + raise ModuleLoadException(module_name, str(e)) + additional_modules = [] if not hasattr(module, "ModuleHandler") or not callable( @@ -63,6 +72,11 @@ def load_modules(machine: Machine, config: Dict[str, Any]) -> None: migration_modules.remove(entry.name) _load_module(machine, config, entry.name) + for migration_module in migration_modules.copy(): + if "." in migration_module: + migration_modules.remove(migration_module) + _load_module(machine, config, migration_module) + if len(migration_modules) > 0 or len(config["migration_modules"]) < 1: logger = get_logger()