Possible declarations are:
Scripts may be documented by adding one or more lines starting with ! first in the decl
block.
A parameter declaration includes the name and the type of a script parameter and an optional default value. It can also be followed by one or more lines of documentation, each starting with !.
param name : type [ = default-value] ! documentation line
Example:
param ram_size : int = 8 ! Size of RAM in MiB
This means that the variable $ram_size will be set when the script is executed, that it must be an integer, and that it will be 8 if not specified in any other way. If there is no default value, then the parameter must be specified when the script is started; otherwise it is optional.
A script with a declaration block will only see the variables that have been declared as parameters. Other variables are hidden during the script's execution and will re-appear when the script terminates.
Several parameter declarations may be collected together by declaring a group. All parameters after a group declaration will belong to it, until a new group is declared. Example:
group "Disks"
Script parameters may be imported from another script, typically one included in the command section using run-command-file
. Example:
params from "qsp-system.include" except mac_address, system default num_cpus = 8
The except statement is used to skip the import of some named parameters, while default provides a way to assign a default value to a parameter in the imported script.
A script can return variables that it has set by declaring results in the following way:
result param : type
Example:
result mac_address : string
It means that the script must set $mac_address before terminating, that it must be a string value, and that this variable is available to the caller. All other variables assigned to by the script are lost. The same name can be used for both a parameter and a result.
The automatically generated script trampolines in project directories use a single substitute line in the decl
block to inherit all parameters and return values from another script. This keyword is not supposed to be used in user written scripts.
Whitespace (spaces, tabs, line breaks) are in general not significant in script declaration blocks unless specifically noted. Comments are allowed, starting with # and running to the end of the line.