N1 Grid Service Provisioning System 5.0 XML Schema Reference Guide

Shared Steps

This section lists steps that can be used in either a component or a simple plan.

<call> Step

Use the <call> step to execute a control block associated with a component installed on the target host.

The <call> step has the following child elements:

Attributes for the <call> Step

The <call> element has one required attribute of type entityName, blockName, which is the name of the control block to execute on the installed component.

<argList> Element

The <argList> element is a child of the <call>, <install>, <uninstall>, <execSubplan>, and <addSnapshot> steps. This element specifies a list of variables to be passed as arguments to the called service.

The called service declares the variables that it expects by using a <paramList> element. The variables within the <argList> and the called <paramList> need not be the same. However, for each variable in the called <paramList> that does not have a default value, a variable with the same name must be present in the <argList>, or a preflight error is raised at plan runtime. For each variable in the called <paramList> for which there is a corresponding variable in the <argList>, the value of the variable in <paramList> will obtain the value of the corresponding variable in <argList> for the duration of the execution of the called service.

Variables in <argList> that do not correspond to a variable in the called <paramList> are silently ignored. Thus, services can be redefined with additional parameters, while still ensuring backward compatibility. So, one plan could call both old and new versions of the service.

The arguments of the <argList> element are expressed as attributes. The order in which the attributes appear is not significant. The following <argList> declares two arguments, password and path:


<argList password=":[password]" path="/tmp"/>

Attributes for the <argList> Element

The <argList> element must have at least one attribute. Each attribute is treated as a named variable to be passed to the called service. The name of each attribute must be an identifier without substitution variable references. The attribute name should correspond to the name of a parameter in the called service. The value of each attribute is an arbitrary string that can include references to variables in the enclosing scope, but not other arguments within the <argList>.

<checkDependency> Step

Use the <checkDependency> step to verify that a particular component has been installed on the target host. If an appropriate component has not been installed, the step fails and execution stops.

The dependency is checked by using the contained component targeter. If the targeter successfully resolves a component, the dependency is satisfied. Otherwise, the dependency is failed.

The <checkDependency> step has one required child element, an installed component targeter, which identifies the component to check for dependency. See Installed Component Targeters.

<execJava> Step

This step executes a JavaTM Executor instance on the target host. If the executor instance raises an exception, the step fails and execution stops.

The <execJava> step has one optional child element, <argList>, which is a list of arguments to pass to the Executor instance. If you specify this element, it can only appear one time.

Attributes for the <execJava> Step

The <execJava> element has the following attributes:

When an <execJava> step is contained within a component, the step typically calls classes that are contained within one or more resources that are deployed by that component. When the step is contained within a plan, the classes called are already resident on the agent, either as a system class of the agent itself or as a resource that was deployed with an existing component.

<execNative> Step

The <execNative> step executes a command native to the operating system on the target host. If the command produces an unexpected result, the step fails and execution stops.

The <execNative< step has the following child elements:

Attributes for the <execNative> Step

The <execNative> step has the following attributes:

<env> Element

The <execNative> element can optionally have <env> elements to specify environment variables for the command. You can use <env> to supply new variables for the command's environment or to override existing variables.

The set of the command's environment variables is a union of the set of the remote agent's environment variables and the variables supplied by using the <env> elements.

Attributes for the <env> Element

The <env> element has the following attributes. They can reference simple substitution variables.

<background> Element

The <background> element is a child of the <execNative> element. When present, this element specifies that the command should be executed as a background process. This element has no attributes or child elements.

An <execNative> with a <background> element has the following constraints:

<outputFile> Element

The <outputFile> element is a child of the <execNative> element. The <outputFile> element specifies the path to a local file on the agent in which to store the standard output of the command that is being executed. Specify the path to the local file by using the <outputFile> name attribute. Relative paths are interpreted as being relative to the command's working directory.

You must specify the <outputFile> element if you specify the <background> element.

If <outputFile> is not specified and the <successCriteria> element does not specify outputMatches, the command output is not stored and will be lost. If outputMatches is specified, the standard output is stored in a temporary file that is deleted after the command finishes executing.

Attributes for the <outputFile> Element

The <outputFile> element has one required attribute, name, which is the name of the file to which the standard output of the command is written. This value should be a nonempty string. This attribute can reference simple substitution variables.

<errorFile> Element

The <errorFile> element specifies the path to a local file on the agent in which to store the error output of the command that is being executed. The path to the local file is specified by using the <errorFile> name attribute. Relative paths are interpreted as being relative to the command's working directory.

You must specify the <errorFile> element if you specify the <background> element.

If <errorFile> is not specified and the <successCriteria> element does not specify errorMatches, the command output is not stored and will be lost. If errorMatches is specified, the error output is stored in a temporary file that is deleted after the command finishes executing.

Attributes for the <errorFile> Element

The <errorFile> element has one required attribute, name, which is the name of the file to which the standard error output of the command is written. This value should be a nonempty string. This attribute can reference simple substitution variables.

<inputText> Element

The <inputText> element is a child element of the <execNative> element. This child element specifies the arbitrary text that should be used as standard input to the command. The text is specified as the contents of this element.


<execNative>
    <inputText>
        ls -l | fgrep `*test*' | sort -u > file.out
    </inputText>
    <command exec=”sh”/>
</execNative>

The body of the <inputText> element can be enclosed in a CDATA section to preserve the formatting of the input and to avoid parsing errors that might be caused by input that contains the & and < characters.

If the <inputText> is specified, it is always enclosed within a CDATA section when generating XML for the <execNative> step. All of the characters within <inputText> are passed as standard input to the command that is being executed. If <inputText> contains only white spaces, those white spaces are passed, exactly as specified, to the command that is being executed.

The contents of <inputText> are config-generated.

The <inputText> element has no attributes.

<inputFile> Element

The <inputFile> element is a child element of <execNative>. This child element specifies the path to a local file on the remote agent whose contents are used as standard input to the command being executed. The path to the local file is specified by using the <inputFile> name attribute.


Note –

The <inputFile> element cannot be used with the <inputText> element in an <execNative> command.


Attributes for the <inputFile> Element

The <inputFile> element as one required attribute, name, which is the file to act as standard input to the command. This value should be a nonempty string. If a relative path is specified, it is relative to the command's working directory. This attribute can reference simple substitution variables.

<exec> Element

An <execNative> step can contain only one <exec> element. The <exec> element specifies the details of the native command to be executed.

The <exec> element contains the following attributes:

<execNative> executes the command specified by cmd with the arguments in the order in which they are specified.

For example, the following <execNative> step executes the ps -fu sps command:


<execNative>
    <exec cmd=”ps”>
        <arg value=”-fu”/>
        <arg value=”sps”/>
    </exec>
</execNative>

The <exec> element has an optional child element, <arg>. Specify one <arg> element for each argument to the command that you want to execute.

The <arg> element has one required attribute, value, which is the argument value. This argument is supplied as the nth argument to the command, where <arg> is the nth child of the command element. This attribute can reference simple substitution variables.

Attributes for the <exec> Element

The <exec> element has one required attribute, cmd, which is the path of the command to execute. If the specified path is not absolute, the command is found by using the platform-specified PATH environment variable set for the remote agent. This value should be a nonempty string. This attribute can reference simple substitution variables.

<shell> Element

The <shell> element is a child element of <execNative>. The contents of the <shell> element specifies the command to be executed. The command to be executed is interpreted using an interpreter, which is specified by the cmd attribute. The command is executed by using sh -c “command” syntax for the platform. In this form, the cmd attribute must be specified to indicate the shell command to use to execute the command.

For example:


<execNative>
    <shell cmd=”/usr/bin/bash -c”>
        ls -l | fgrep `*test*' | sort -u > file.out
    </shell>
</execNative>

The previous <execNative> example executes the following command:


/usr/bin/bash -c `ls -l | fgrep `*test*' | sort -u > file.out'

To preserve formatting and to avoid XML parsing problems, the text contents of the command is always enclosed within a CDATA element when the XML representation is generated from the <execNative> step.

A command string cannot be empty or contain only white space characters. The command string is supplied exactly as it is specified, including surrounding white space, to the shell.

The contents of the <shell> element are config-generated.

Attributes for the <shell> Element

The <shell> element has one required attribute, cmd, which is the shell command in the sh -c syntax. The string should not contain any embedded quote characters. The string is parsed to retrieve the shell name and the arguments by using white space as delimiters. For example, /usr/bin/bash -c should be a nonempty string. This attribute can reference simple substitution variables.

<successCriteria> Element

The <successCriteria> element is a child element of <execNative>. This child element specifies the criteria to be used to evaluate whether an <execNative> step executed successfully. If this element is not specified, the default value is <successCriteria status=”0”/>.

If the specified <successCriteria> is empty, it is ignored.

If you specify <successCriteria/>, the step always succeeds no matter what output or exit code the command generated.

Attributes for the <successCriteria> Element

The <successCriteria> element has the following optional attributes. If more than one of the status, outputMatches, and errorMatches attributes are specified, they are ANDed together.

<if> Step

This step is used to conditionally execute a block of steps. This step has no attributes. Its child elements are <condition>, <then>, and <else>. The <condition> and <then> elements must appear one time. If you specify the <else> element, it can only appear one time.

If the contents of the <condition> element evaluates to true, the steps of the <then> block are executed. Otherwise, the steps of the <else> block are executed, if present.


Example 2–1 Using the <if> Step

The following example shows an <if> step that is used to conditionally restart.


<if>
    <condition><istrue value=":[restart]"/></condition>
    <then>
        <call blockName="restart"/>
    </then>
</if>

<condition> Element

The <condition> element is a child of the <if> step and specifies a Boolean expression. This element has no attributes and must contain exactly one Boolean operator child element. See Boolean Operators.

<then> Element

The <then> element is a child element of the <if> step. This element specifies the steps to execute if the associated condition is true. The <then> element can contain any number of steps that are permitted within the scope of the block that contains the <if> step.

<else> Element

The <else> element is a child element of the <if> step. This element specifies the steps to execute if the associated condition is not true. The <else> element can contain any number of steps that are permitted within the scope of the block that contains the <if> step.

<pause> Step

The <pause> step pauses the execution of a plan for a specified amount of time. You can use <pause> to make a plan wait for required services to come online after being started.

Attributes for the <pause> Step

The <pause> element has one required attribute of type positiveInteger, delaySecs, which is the number of seconds to wait.

<processTest> Step

The <processTest> step is used to verify that a particular process is running on the target host. If the specified process does not exist, the step fails and execution stops.


Note –

This step only applies to UNIX® systems.


Attributes for the <processTest> Step

The <processTest> step has the following attributes:

<raise> Step

The <raise> step is a step that always fails, though it can be caught and handled by a <try> step. This step has a single attribute, message, and has no child elements.

The <raise> step is used to indicate a failure condition without having to construct an artificial step to do so. This step most often appears within a <catch> block to propagate an error condition after cleaning up.

Attributes for the <raise> Step

The <raise> element has one optional attribute, message, which is a message that describes the error condition. By default, the message is a generic system-specified message. This attribute can reference simple substitution variables.


Example 2–2 Using the <raise> Step

The following example shows how the <raise> step is used to repropagate an error condition from within a <catch> block, after noting the error in a log.


<control blockName="default">
    <try>
        <block>
            <!-- some arbitrary processing here -->
        </block>
        <catch>
            <!-- note error in log -->
            <execNative>
                <exec cmd="appendLog">
                    <arg value="an error occurred"/>
                </exec>
            </execNative>
            <!-- rethrow error -->
            <raise/>
        </catch>
    </try>
</control>

MS Windows: <reboot> Step

This step causes the agent to reboot before running the rest of the plan. You can only use this step on Microsoft Windows (MS Windows) based systems. If encountered on a system other than MS Windows, an error is issued. If you reboot an agent that resides on the same host as the master server, an error is issued. These errors are preflight errors.

MS Windows: Attributes for the <reboot> Step

The <reboot> step has one optional attribute of type positiveInteger, timeout, which is the maximum number of seconds to wait for the server to reboot. If this attribute is omitted, the plan's <execNative> timeout period applies.

<retarget> Step

This step changes the execution target for a set of steps. Retarget steps can be nested.

The <retarget> step has the following child elements:

Attributes for the <retarget> Step

The <retarget> step has a required attribute, host, which is the host on which the contained steps should be executed. This attribute can reference simple substitution variables.

This attribute is used by the <retarget> step, as well as by various component targeter elements. Its value is the name of a host, which can include substitution variable references. The value can also include the symbolic name / to reference the root physical host of the current execution target, or ..(/..)* to reference a parent host of the current execution target.


Note –

When a host attribute is specified within a component targeter, it is semantically equivalent to enclosing the containing step in a <retarget> step.


<retarget> Step Execution Semantics

When a <retarget> step is encountered, the host attribute is first evaluated in the context of the current host of the caller.

If the value of the host attribute is different from the name of the current host, the provisioning software takes the following steps:

  1. Resolves the host name to an actual host. If no such host exists, an error is issued.

  2. Verifies that the current user has “execute” permission on the given host for the plan's folder or for the component that contains this step. If not, an error is issued.

  3. Verifies that the following conditions are met for the root physical host of the host:

    • It contains a remote agent.

    • You can connect to it.

    • It is updated and prepared.

    If these conditions are not met, an error is issued.

  4. Obtains a lock on the host, while retaining locks on all previously visited hosts. If the current execution thread already locks the host, this operation is effectively a no-op. If the host is already locked by another execution thread, this operation blocks until the host is unlocked. If the request for a lock would result in a deadlock, an error is issued.

  5. Resets the host to become the new “current” host. The “physical” host is reset based on the new “current” host. The “initial” host does not change.

After the previous steps complete, variables of the <varList> element are evaluated in the context of the new current host. Local variables can hide variables of enclosing scopes. Then, each of the steps is executed in the context of the new current host.

Finally, if the retarget operation changed the current host, it is unlocked, as appropriate, and the current host is reset to the current host of the caller. If the host was locked previously in the current execution thread, it remains locked until the block that first acquired the lock completes.

You can use an empty <retarget> block to prevalidate that the current user has the appropriate permissions and that the host is properly prepared.


Example 2–3 Using the <retarget> Step

This example shows a “restart” control service that you might find on a WebLogic managed server. This control service is implemented by calling a control on the administrative server to stop the managed server. Then it makes a call on the local server to start the server.

The adminHostName variable is evaluated on the current host of the caller, which is assumed to be the virtual host that contains the managed server. The domainName variable is evaluated on the retargeted host, which is assumed to be the virtual host that contains the administrative server. The ADMIN_SERVER component is also resolved on the retargeted host.


<control name="restart">
    <varList>
        <var name="adminHostName" default=":[target:adminHostName]"/>
    </varList>
    <retarget host=":[adminHostName]">
        <varList>
            <var name="domainName" default=":[target:domainName]"/>
        </varList>
        <call blockName="stopServer">
            <argList serverName=":[serverName]"
	      domainName=":[domainName]"/>
            <installedComponent name="ADMIN_SERVER"/>
        </call>
    </retarget>
    <call blockName="start"/>
</control>

<sendCustomEvent> Step

The <sendCustomEvent> step is used to generate a custom event with a particular message. This step can be used in conjunction with the notification rules module to send an email any time this step is encountered on a particular host.

Attributes for the <sendCustomEvent> Step

The <sendCustomEvent> step has one required attribute, message, which is the message to include as the event text. This attribute can reference simple substitution variables.

<transform> Step

The <transform> step is used to perform a text-based transformation on a file on the target host. Currently, Perl-type and XSLT-based transformations are supported.

The <transform> child elements specify the transformation to be applied to the input file. The child elements can be any one of the following elements:

Attributes for the <transform> Step

The <transform> step has the following attributes:

The input and output attributes can reference the same or distinct files. The value of these attributes is a generalized path that can include zip archives or zip derivatives, such as JAR, as directory elements. For example, a path might be webapp/myapp.jar/config.xml.

<stylesheet> Element

The <stylesheet> element is a child of the <transform> step and specifies an XSLT transformation to apply to the input source. At most one <stylesheet> element can appear as a child of a particular <transform> element. You cannot use the <stylesheet> element in conjunction with other child elements.

The <stylesheet> element is an XSLT Version 1.0 element as defined by the http://www.w3.org/1999/XSL/Transform name space. For more information, see Version 1.0 of the XSL Transformations (XSLT) specification at http://www.w3.org/TR/xslt.html. Only the XSLT <stylesheet> element is accepted as a child of the <transform> element. In particular, neither the XSLT synonym <transform> nor the simplified XSLT transform syntax described in Section 2.3 of the XSLT specification is supported as a child of the <transform> element.

The <stylesheet> element body can include substitution variable references if the body is still a valid XSLT without first undergoing variable substitution.

When a <stylesheet> element is used as a transformation, the input file must be written in XML. For more information, see Version 1.0 of the XSL Transformations (XSLT) specification.


Example 2–4 Using the <stylesheet> Element


<transform output="/etc/hosts">
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <xsl:for-each select="a">
                <xsl:value-of select="b"/>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
</transform>

<subst> Element

The <subst> element is a child of the <transform> step. This element specifies a Perl-like substitution pattern to apply as a transformation. One or more <subst> elements can appear as children of the <transform> element, but they cannot be used in conjunction with other child elements. When more than one <subst> element appears, they are applied sequentially.

All occurrences of the pattern in the input file are replaced, including multiple occurrences within a line.

For information about the supported syntax, see Java documentation (class java.util.regex.Pattern).

Attributes for the <subst> Element

The <subst> element has the following attributes:


Example 2–5 Using the <subst> Element

The following transformation converts all occurrences of the string 127.0.0.xxx to 10.10.0.xxx in the /etc/hosts file:


<transform output=”/etc/hosts”>
    <subst match="127\.0\.0\.(\d+)"
    replace="10.10.0.$1"/>
</transform>

<source> Element

The <source> element is a child of the <transform> step. This element specifies an external file on the target host that contains the transformation to be applied to the input file. At most one <source> element can appear as a child of a particular <transform> element. You cannot use the <source> element in conjunction with other child elements.

Configuration generation is not performed on the specified source file as part of the <transform> step. However, the specified source file can be a config-type resource file that is deployed as part of a component installation. In such as case, substitution variables that are contained in the source file would have been substituted when the file was deployed.

Attributes for the <source> Element

The <source> element has the following attributes:

<try> Step

The <try> step is used to specify typical error handling and cleanup logic for a block of steps. This step has no attributes. This step has these child elements: <block>, <catch>, and <finally>.

The <try> step is executed as follows:

The <catch> element is used to suppress and recover from errors that are encountered in the <block> element. The <finally> element is used to unconditionally perform some cleanup, regardless of whether typical errors were encountered.

The <try> step either succeeds or fails as follows:

Failures in the <block> element are suppressed by the presence of a <catch> element.

The <try> step has the following child elements:

<block> Element

The <block> element is a child element of the <try> step. This element specifies the primary steps that are executed by the <try> step. The <block> element contains one or more steps that are permitted within the scope of the block that contains the <try> step.

<catch> Element

The <catch> element is a child element of the <try> step. This element specifies the steps to execute if a typical error occurs while executing the steps of the <block> element. The <catch> element can contain any number of steps that are permitted within the scope of the block that contains the <try> step.

The <catch> element serves both to suppress typical errors of the <block> element and to define typical error recovery actions. This element can be empty, in which case <catch> only suppresses typical errors.

<finally> Element

A child element of the <try> step. <finally> specifies the steps to execute regardless of whether a typical error occurred earlier within the <try> or <catch> steps. An atypical error can be a plan abort or a plan timeout, in which case the steps of the <finally> element are skipped. <finally> can contain any number of steps that are permitted within the scope of the block that contains the <try> step.

The <finally> element is used primarily to specify cleanup steps that should always be run regardless of an error. To run cleanup steps in response to an error, put them in the <catch> element instead.


Example 2–6 Using the <try> Step

In this example, the component installation consists of resource deployment followed by a restart. In this case, the component is considered to be installed after its resources are deployed, and a failure during restart should not affect its installed state. Typical errors can be suppressed during the restart as follows:


<installSteps blockName="default">
    <deployResource/>
    <try>
        <block>
            <call blockName="restart"><thisComponent/></call>
        </block>
        <catch/><!-- suppress all typical errors -->  
    </try>
</installSteps>

You can use <try> blocks to model intelligent auto-upgrades. Version 1.1 of a component has two different installation routines. One performs a fresh installation of the component. The other performs an upgrade installation if Version 1.0 of that component was previously installed. You can model this situation in a single installation block, as follows:


<installSteps blockName="default">
    <try>
        <block>
          <checkDependency>
              <installedComponent name="foo" version="1.0"/>
          </checkDependency>
          <!-- 1.0 installation exists, do upgrade -->
        </block>
        <catch>
          <!-- 1.0 installation doesn't exist, do fresh installation -->
        </catch>
    </try>
</installSteps>

The <finally> block is most often used to clean up temporary resources. The following example creates a temporary file, processes it, and then removes it.


<control blockName="default">
    <varList>
        <var name="file" default="/tmp/file.txt"/>
    </varList>
    <execNative outputFile=":[file]">
        <exec cmd="ls"><arg value="-l"/></exec>
    </execNative>
    <try>
        <block>
            <!-- process file in some way -->
        </block>
        <finally>
            <execNative>
                <exec cmd="rm"><arg value=":[file]"/></exec>
            </execNative>
        </finally>
    </try>
</control>

<urlTest> Step

This step is used to verify that the contents of a particular URL match an expected pattern. If the desired pattern is not matched, the step fails and execution stops.

Attributes for the <urlTest> Step

The <urlTest> step has the following attributes: