Child pages
  • Simple Code Examples

This is the documentation of the release 2.1 of automaIT. The documentation of the latest stable release can be found at AUTOMAIT.

Skip to end of metadata
Go to start of metadata

Plans or components can be used to write code for automaIT. Both of them are XML files of the model namespace. The root element of a plan is named plan and the root element of a component is component.

To create the content of a plan, install, uninstall, or control method of a component, it is necessary to be familiar with so called block statements. Block statements are a sequence of steps and the content of the following elements:

  • Body of a Plan
  • Install method of a component (installSteps)
  • Uninstall method of a component (uninstallSteps)
  • Controls of a component (control)
  • Body of if blocks
  • Body of switch resp. case blocks
  • Body of try blocks

The complete model schema reference is documented in the Model Schema Reference .

Block statements can contain single elements such as an execNative, an echo, an if, try, etc.

Simple Example
<plan name="SimpleExample" description="Says 'Hello World!'"
    xmlns="http://www.novatec-gmbh.de/np/schemas/server/model/2.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.novatec-gmbh.de/np/schemas/server/model/2.1 plan.xsd ">
    
    <echo message="Hello World!" />

</plan>

The elements if, switch and try are nestable, too. In the following example the block and catch elements are examples for elements that can contain all block statements again.

Example with try/catch statement
<plan name="SimpleExample" description="Lists the content of the /etc directory."
    xmlns="http://www.novatec-gmbh.de/np/schemas/server/model/2.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.novatec-gmbh.de/np/schemas/server/model/2.1 plan.xsd ">

    <try>
        <block>
            <execNative>
                <exec cmd="ls">
                    <arg value="/etc" />
                </exec>
            </execNative>
        </block>
        <catch>
            <echo message="This directory does not exist, but I don't care." />
        </catch>
    </try>
</plan>
Example with if statement
<plan name="SimpleExample" description="says 'Hello'"
    xmlns="http://www.novatec-gmbh.de/np/schemas/server/model/2.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.novatec-gmbh.de/np/schemas/server/model/2.1 plan.xsd ">

    <if>
        <condition>
            <not>
                <isInstalled>
                    <installedComponent name="MyComponent" />
                </isInstalled>
            </not>
        </condition>
        <then>
            <echo message="Component is not installed." />
        </then>
        <else>
            <uninstall blockName="default">
                <installedComponent name="MyComponent" />
            </uninstall>
        </else>
    </if>
</plan>
Example with swith-case statement
...
<switch value="java_:[java_version]_vendor_:[vendor]_:[architecture]_bit" caseSensitive="false" executeMultiple="true">
    <case matches="^java_6_vendor_oracle_32_bit$">
        <echo message="Installing Java Version 6 on 32 bit system. Vendor Oracle." />
    </case>
    <case matches="^java_7_vendor_ibm_(32|64)_bit$">
        <echo message="Configure installation. Java Version 7 on :[architecture] bit system. Vendor IBM." />
    </case>
    <case matches="^java_7_vendor_ibm_32_bit$">
        <echo message="Installing Java Version 7 on 32 bit system. Vendor IBM." />
    </case>
    <case matches="^java_7_vendor_ibm_64_bit$">
        <echo message="Installing Java Version 7 on 64 bit system. Vendor IBM." />
     </case>
    <default>
        <raise message="Unknown java/vendor/architecture combination : Java version: :[java_version], Vendor :[vendor], Architecture: :[architecture] bit" />
    </default>
</switch>
...

Writing code gets much easier by using code completion of Eclipse (documentation).

  • No labels