<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM* and/or HCL**
- UrbanCode Deploy
- UrbanCode Build
- UrbanCode Release
- AnthillPro
- (c) Copyright IBM Corporation 2011, 2017. All Rights Reserved.
- (c) Copyright HCL Technologies Ltd. 2018. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-
- * Trademark of International Business Machines
- ** Trademark of HCL Technologies Limited
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.air.plugin.SystemInformation" name="System Information" version="8"/>
    <description>
      The System Information plugin includes a variety of checks to perform against the operating system. These steps can be used to verify that a deployment can succeed or has succeeded.
    </description>
    <tag>System Utility/System Information</tag>
  </header>
  <step-type name="Check Connectivity">
    <description>Ensure that a TCP connection can be made to a given host and port from this machine.</description>
    <properties>
      <property name="hostname" required="true">
        <property-ui type="textBox"
                     label="Hostname"
                     description="The hostname or IP of the machine to try to connect to." default-value="localhost"/>
      </property>
      <property name="port" required="true">
        <property-ui type="textBox"
                     label="Port"
                     description="The port to try to connect to." default-value="80"/>
      </property>
      <property name="retries" required="true">
        <property-ui type="textBox"
                    label="Retries"
                    description="The number of time to retry the connection." default-value="0"/>
      </property>
      <property name="interval" required="true">
        <property-ui type="textBox"
                    label="Interval(seconds)"
                    description="The inteval in seconds between retries." default-value="1"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar"/>
      <arg file="conCheck.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Check Environment Variable">
    <description>Ensure that an environment variable is set to an expected value.</description>
    <properties>
      <property name="variable" required="true">
        <property-ui type="textBox"
                     label="Variable Name"
                     description="The name of the variable to check for."/>
      </property>
      <property name="value">
        <property-ui type="textBox"
                     label="Value"
                     description="The expected value of the variable. Leave blank if you just want to check the var is set without checking value."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar"/>
      <arg file="envCheck.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Check Available Disk Space">
    <description>Ensure that there is enough available disk space.</description>
    <properties>
      <property name="path" required="true">
        <property-ui type="textBox"
                     label="Path"
                     description="The path to check disk space for. (i.e. For Windows C:\, For *nix /mntpoint"/>
      </property>
      <property name="size" required="true">
        <property-ui type="textBox"
                     label="Available Space(kB)"
                     description="The minimum space in kilo-bytes for this step to pass." default-value="30720"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/commons-io.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar"/>
      <arg file="spaceCheck.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Check Regex">
    <description>Check if a value matches a Regex. If it does the matched groups will be set as output properties with the names group0, group1, etc.</description>
    <properties>
      <property name="regex" required="true">
        <property-ui type="textBox"
                     label="Regex"
                     description="The regex to try to match."/>
      </property>
      <property name="valueString" required="true">
        <property-ui type="textBox"
                     label="Value"
                     description="The value you want to check the regex against."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar"/>
      <arg file="regexCheck.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
