# HG changeset patch # User Marco Cirillo # Date 1364855684 0 # Node ID bea93cfd6c5456970488ff578a71f37741a5253b # Parent 8e98a58ab6a3e769ff262a7005ffaec367b5ec19 modulemanager: add function to retrieve module items from a specific host entity. diff -r 8e98a58ab6a3 -r bea93cfd6c54 core/modulemanager.lua --- a/core/modulemanager.lua Mon Apr 01 14:51:42 2013 +0100 +++ b/core/modulemanager.lua Mon Apr 01 22:34:44 2013 +0000 @@ -19,7 +19,7 @@ local pcall, xpcall = pcall, xpcall; local setmetatable, rawget = setmetatable, rawget; -local pairs, type, tostring = pairs, type, tostring; +local pairs, type, tostring, t_insert = pairs, type, tostring, table.insert; local debug_traceback = debug.traceback; local unpack, select = unpack, select; @@ -278,6 +278,23 @@ return modulemap[host] and modulemap[host][name]; end +function get_items(key, host) + local result = {}; + local modules = modulemap[host]; + if not key or not host or not modules then return nil; end + + for _, module in pairs(modules) do + local mod = module.module; + if mod.items and mod.items[key] then + for _, value in ipairs(mod.items[key]) do + t_insert(result, value); + end + end + end + + return result; +end + function get_modules(host) return modulemap[host]; end