# HG changeset patch # User Matthew Wild # Date 1529487662 -3600 # Node ID e727747279a00f7b5c2ce9b6a3e5be9f152c5b7d # Parent 2502be210a8537fabdd5e3db90833be16606cb32 modulemanager: Expose function to get the list of modules that should be loaded on a host diff -r 2502be210a85 -r e727747279a0 core/modulemanager.lua --- a/core/modulemanager.lua Mon Jun 18 04:25:01 2018 +0200 +++ b/core/modulemanager.lua Wed Jun 20 10:41:02 2018 +0100 @@ -46,8 +46,8 @@ -- [host] = { [module] = module_env } local modulemap = { ["*"] = {} }; --- Load modules when a host is activated -function load_modules_for_host(host) +-- Get the list of modules to be loaded on a host +local function get_modules_for_host(host) local component = config.get(host, "component_module"); local global_modules_enabled = config.get("*", "modules_enabled"); @@ -71,8 +71,16 @@ modules:add("admin_telnet"); end - if component then - load(host, component); + return modules, component; +end + +-- Load modules when a host is activated +function load_modules_for_host(host) + local modules, component_module = get_modules_for_host(host); + + -- Ensure component module is loaded first + if component_module then + load(host, component_module); end for module in modules do load(host, module); @@ -324,6 +332,7 @@ end return { + get_modules_for_host = get_modules_for_host; load_modules_for_host = load_modules_for_host; load = load; unload = unload;