To understand of how LMC Add-ins work, we need to consider which elements are applied to the configuration of a device.
The following is the process in which the configuration can be modified:
- The existing (or default) configuration - visible in the detail configuration of a device - may be modified by One-time Add-ins or manual user changes.
- The Software Defined (SD-WAN,SD-LAN,SD-WLAN) configuration - also called Smart configuration - may be modified by global or network Add-ins using OIDs.
Those changes are visible via show preview in the detail configuration. - The ScriptLines are executed on the device after the configuration roll out and may not be visible in the LMC.
The result of steps 1 and 2 is sent as configuration data to the device. The scripts from step 3 are sent as extra actions with a configuration roll out and will be executed on the device after the combined configuration data from step 1and 2 has been applied to the device.
As shown above, we have two ways of manipulating the configuration of a device with Add-ins.
- via Object Id (Oid): this modifies the configuration data provided by the previous config concepts.
- via ScriptLines: this is sent to and executed on the device itself.
- via API Method: send requests to the UF-API for configuration changes for Unified Firewalls.
Operating System | config.[...]ByOid(...) | config.addScriptLine(...) | ufAPI.Method |
---|---|---|---|
LCOS | ✅ | ✅* | ❌ |
LCOS-SX | ✅ | ✅* | ❌ |
LCOS-LX | ✅ | ❌ | ❌ |
LCOS-FX | ❌ | ❌ | ✅ |
* device specific terminal syntax
Object Id (Oid)
Each configuration value or table is specified by a machine readable Object Id, short o id.
The oid is a sequence of numbers separated by dots (the following example denotes the LCOS cron-table):
1.2.11.20
To modify the configuration data you can either get/set single values (scalars) or tables/rows.
Scalars
Scalars are single values in the configuration.
exports.main = function (config, context) { var value = config.getScalarByOid("1.2.3.4.5.1"); config.setScalarByOid("1.2.3.4.5.2", "test"); };
Tables
Tables can have a fixed or a dynamic number of rows.
exports.main = function (config, context) { var table = config.getTableByOid("1.2.3.4.5.3"); var rows = table.getRows(); // array of rows var row = table.createNewRow(); //create a new empty row table.addOrMerge(row); // add/merge this row into table };
Script-Line
To execute a script on the device after applying the configuration you need to use the addScriptLine
syntax:
exports.main = function (config, context) { config.addScriptLine("cd /2/3/4/5/2"); config.addScriptLine("set 1 test"); };
The scriptline example sets the same value as the scalar example above. The first number is ommitted as well as the .
(full stop) which is translated to /
(slash). In this case we will not see the values in the Detail configuration in the LMC when previewing the configuration, but in the preview of the script that will be executed on the device.
In contrast to setting of values via oid, we can also use the human readable notation, e.g. config.addScriptLine("cd /Setup/WAN/DSL-Broadband-Peers")
.