<PrereqDef> element
The <PrereqDef> element that can later be used in a <Prereq> element.
Syntax
Parent element: <Catalog>
Attribute | Required | Type | Description |
---|---|---|---|
name | yes | string | Specifies the name of the property. |
Child element | Required | Description |
---|---|---|
<Command> | no | Command |
<Argument> | no | Command-line arguments |
<Stdin> | no | Arguments that are supported by the <Stdin> element |
<ErrMessage> | no | Message to print if prerequisite fails |
Usage
Prereq are commands that condition the run of the <Get>, <Set>, and <Discover> operations for parameters that use the <Get>, <Set>, or <Discover> operation. Parameters for which a prereq command fails (nonzero return code) are ignored, and the error message defined in the prerequisite is displayed.
The <PrereqDef> element defines a prerequisite. This prerequisites can later be associated with an operation of a parameter or a configuration method by using a <Prereq> element that has the same id attribute.
Example
The following example defines the nodeId prerequisite and assigns it to the netaddr and netaddr6 parameters:
<PrereqDef id="nodeId">
<Command>[[ `/usr/bin/uname -f` = %p[nodeId] ]]</Command>
<ErrMessage>Parameter cannot be applied to a different node</ErrMessage>
</PrereqDef>
<ParameterDef name="netaddr" type="string" targetClass="device" cfgmethod="attr">
<Set type="permanent">
<Prereq id="nodeId"/>
</Set>
<Property name="nodeId"/>
</ParameterDef>
<ParameterDef name="netaddr6" type="string" targetClass="device" cfgmethod="attr">
<Set type="permanent">
<Prereq id="nodeId"/>
</Set>
<Property name="nodeId"/>
</ParameterDef>
In this example, the test is executed only once, because the two parameters use the same <Command> element for their prerequisites, and the generated command line is the same for the two parameters.