<< Click to Display Table of Contents >> Raynet One > 1.1 > User Guide > Technical overview > Custom inventory scripting CSM inventory scripting |
The CSM inventory script language uses XML nodes to describe basic structured device inventory processes. It is designed to provide solutions for the following ideas:
•execute a device command and turn its results into an inventory object,
•execute a device command, split the command output into lines, execute another command based on the line content and turn the command results into a combined inventory object, and
•distributed device command execution.
The language uses a simple execution model. Each inventory file is a set of scripts. A script can contain a preliminary command list. After the commands, the script can contain line-splitting nodes to execute another list of commands per line of command output.
If no line-splitting is involved, the script is considered to be of type A, otherwise of type B. Scripts of type A allow the creation of exactly one inventory object based on the preliminary command output. Scripts of type B allow the creation of inventory objects in each line-splitting node for each line encountered, but not just based on the preliminary command output.
CSM defines a fixed set of computation nodes.
A script has a set of global variables. Initially, the set of global variables is empty. During the computation of a node with the Name attribute, the variable named after the attribute's value is created or set according to the node's specification.
Shell commands do not share an execution context. CSM variables are not visible in the executing shell commands. Text template substitution is used to put CSM variable contents into the requested shell command text.
Specific fields of CSM XML nodes perform recursive variable substitution based on the set of defined run-time variables. The first variable definition starts the recursion. The variable definitions are ordered according to the defining node execution order. The execution order is hinted at in the general description of the simple execution model above.
To perform variable substitution, a string of any characters is processed. The occurrence of the $(NAME)character sequence is substituted by the content of the NAME variable. The occurrence of the $(NAME):N character sequence is substituted by the Nth line of the NAME variable (index operation). The occurrence of the $(NAME):N[M] character sequence is substituted by the Mth word of the Nth line in the NAME variable (index operation). Index operations only work on certain variable value types. The indices start at 0.
Disambiguation: Even though the CSM variable substitution notation looks similar to the Linux shell notation of substitution by command result, it is not. CSM variable substitution is always performed on the runner side of execution, but the shell commands are executed on the inventory device.
Security consideration: Shell command substitution by CSM could lead to unpredictable, potentially insecure execution. After all, the shell command is interpreted after replacement, allowing the insertion of new shell command operators through CSM variable substitution, possibly changing the entire meaning of the shell command. Assess the contents of CSM scripts and evaluate the impact of template command execution.
If the runner instrument log level is set to Debug or Verbose, exhaustive information about CSM script execution is put into the instrument log. Command nodes allow the behavioural specification on error, enabling further log entries.