<Prereq> element
The <Prereq> element assigns a prerequisite to <Get>, <Set>, and <Discover> operations.
Syntax
Parent element: <Get>, <Set>, and <Discover>
Attribute | Required | Type | Description |
---|---|---|---|
id | no | string | Specifies an unique identifier |
Child element | Required | Description |
---|---|---|
<Command> | no | Command |
<Argument> | no | Command-line arguments |
<Stdin> | no | Arguments supported by the <Stdin> element |
<ErrMessage> | no | Message to print if prerequisites fail |
Usage
Prereqs are commands that condition the processing of a <Get>, <Set>, and <Discover> operation for parameters that use this <Get>, <Set>, and <Discover> operations. Parameters for which a prereq command fails (nonzero return code) are ignored, and the error message defined in the prerequisite is displayed.
The <Prereq> element assigns a prerequisite to the parent <Get>, <Set>, or <Discover> operation. The prerequisite is either defined locally under the <Prereq> element, or inherited from a higer-level <Prereq> or <PrereqDef> element that has a matching id attribute.
A parameter has all the prerequisites defined locally under the <ParameterDef> element. Also, the prerequisite has the properties defined in the configuration method of the parameter, if a configuration method is used. The consequence is that if a prerequisite is defined in a <CfgMethod> element, all the <ParameterDef> elements that use the configuration method will automatically have that prerequisite (although some of those elements might redefine the prerequisite locally).
- Under the <Prereq> subelement of the relevant operation of the <ParameterDef> element.
- If the <ParameterDef> element has a cfgmethod attribute, under the <Prereq> subelement that has a matching id of the relevant operation of the configuration method.
- Under the <PrereqDef> element of the catalog that has a matching id.
Example
The following example defines a prerequisite that checks that the netaddr and netaddr6 parameters are applied on the same system on which they were captured:
<ParameterDef name="netaddr" type="string" targetClass="device" cfgmethod="attr">
<Set type="permanent">
<Prereq>
<Command>[[ `/usr/bin/uname -f` = %p[nodeId] ]]</Command>
<ErrMessage>Parameter cannot be applied to a different node</ErrMessage>
</Prereq>
</Set>
</ParameterDef>
<ParameterDef name="netaddr6" type="string" targetClass="device" cfgmethod="attr">
<Set type="permanent">
<Prereq>
<Command>[[ `/usr/bin/uname -f` = %p[nodeId] ]]</Command>
<ErrMessage>Parameter cannot be applied to a different node</ErrMessage>
</Prereq>
</Set>
</ParameterDef>
In this example, the test is run twice: once for the netaddr parameter, and once for the netaddr6 parameter. This dual processing is because each parameter has its own prerequisite with its own <Command> element. See , artex_catalog_elem_PrereqDef.html for an example that requires only one run of the test.