You may not know that you can share table definitions between modules. You can see examples of this in TKU (see the SupportingFiles.Tables module).
For example, define a module with a table definition:
tpl 1.0 module TEST1;
// Define a table to be shared in other modules
table LookupPath 1.0
'sudo' -> ['/sbin/sudo', '/usr/local/bin/suexec'];
end table;
This allows a value to be returned by the table based on a key (in this case a list of strings). In one or more other modules, “import” the table in module scope with the command:
from TEST1 import LookupPath 1.0;
and then the table can be used in a pattern this second module as normal:
tpl 1.0 module TEST2;
from TEST1 import LookupPath 1.0;
pattern TEST2 1.0
'''
Test pattern to use imported table
'''
overview
tags TEST;
end overview;
triggers
on device := DeviceInfo;
end triggers;
body
host := model.host(device);
if not host then
log.error('No host node for: % device.name%');
stop;
end if;
for val in LookupPath['sudo'] do
log.info('>>> Possible path: % val%');
end for;
end body;
end pattern;
