<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Build
- IBM UrbanCode Deploy
- IBM UrbanCode Release
- IBM AnthillPro
- (c) Copyright IBM Corporation 2002, 2013. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->
<plugin xmlns='http://www.urbancode.com/PluginXMLSchema_v1' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  <header>
    <identifier id='com.urbancode.air.plugin.AmazonEC2' version='6' name='AmazonEC2' />
    <description>This plugin provides steps for launching instances, terminating instances, associating ip addresses, waiting for instances, creating a security group, and getting the public DNS for the Amazon EC2 tool.</description>
    <tag>Cloud/AmazonEC2</tag>
  </header>
  <step-type name='Launch Instances'>
    <description>Launch instances of the given AMI.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name='number' required='true'>
        <property-ui type='textBox' label='# of instances' description='The number of EC2 instances to startup.' />
      </property>
      <property name='instanceType' required='true'>
        <property-ui type='textBox' label='Instance Type' description='The type of instances to run. Allowed values are m1.small, m1.large, m1.xlarge, m2.xlarge, m2.4xlarge, c1.medium, c1.xlarge.'/>
      </property>
      <property name="group">
        <property-ui type='textBox' label="Security Group" description='A comma-separated list of security group names to use.'/>
      </property>
      <property name="zone">
        <property-ui type='textBox' label="Availability Zone" description='The zone to start these instances in.'/>
      </property>
      <property name="keypair">
        <property-ui type='textBox' label="Keypair" description='The keypair to start these instances with.'/>
      </property>
      <property name='ami' required='true'>
        <property-ui type='textBox' label='AMI ID' description='The AMI ID of the instances to be started.' />
      </property>
      <property name='options'>
        <property-ui type='textAreaBox' label='User data' description='The user data to be passed to the instance.' />
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='start_instances.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>
  <step-type name='Terminate Instances'>
    <description>Terminate instances with the given instance IDs.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name='instanceIds' required='true'>
        <property-ui type='textBox' label='Instance IDs' description='A comma-separted list of instance IDs for instances to be terminated.' />
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='stop_instances.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>
  <step-type name='Associate IPs'>
    <description>Associate Elastic IPs with instances.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name="ips" required='true'>
        <property-ui type='textAreaBox' label="IPs" description='A new-line separated list of elastic IPs to associate with instances'/>
      </property>
      <property name="instances" required='true'>
        <property-ui type='textAreaBox' label="Instance IDs" description='A comma separated list of instance IDs that correspond to the IPs to associate.'/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='associate_ips.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>
  <step-type name='Wait for instances'>
    <description>Wait for instances to be in a certain state.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name="instances" required='true'>
        <property-ui type='textAreaBox' label="Instance IDs" description='A comma separated list of instance IDs that correspond to the IPs to associate.'/>
      </property>
      <property name='status' required='true'>
        <property-ui type='textBox' label='State' description='The state for instances to be in.' />
      </property>
      <property name="ec2Timeout" required='true'>
        <property-ui type="textBox" label="Timeout" description="The timeout for this step."/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='wait_for_instances.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>
  <step-type name='Create Security Group'>
    <description>Create a security group from a file.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name='name'>
        <property-ui type='textBox' label='Name' description='The name of the security group to create, if not using a file to add permissions.' />
      </property>
      <property name='description'>
        <property-ui type='textBox' label='Description' description='The description of the security group to create, if not using a file to add permissions.' />
      </property>
      <property name='vpcId'>
        <property-ui type='textBox' label='VPC ID' description='The ID of the vpc to use, if not using a file to add permissions.' />
      </property>
      <property name="secGroupFile">
        <property-ui type='textBox' label="Definition File" description='The file describing the security group allowed IPs/ports. If left blank, an empty security group will be created. Else, the file has the format &lt;SecurityGroup name="name" description="description" vpcId="ID optional"&gt;&lt;ipPermission protocol="tcp" fromPort="22" toPort="22"&gt;&lt;ipRange value="0.0.0.0/0"/&gt;&lt;/ipPermission&gt;&lt;/SecuirtyGroup&gt;'/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='createSecurityGroup.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>

  <step-type name='Get Public DNS'>
    <description>Get the public dns for given instance IDs. Returned in a comma-separated list in property dns.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name="instanceIds" required='true'>
        <property-ui type='textAreaBox' label="Instance IDs" description='A comma-separated list of instance-IDs to be retrieved. The dns returned will be in the same order as the IDs given.'/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='getPublicDns.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>

  <step-type name='Register Instances with LoadBalancer'>
    <description>This step will register instances with an Amazon Load Balancer.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name="loadBalancerName" required="true">
        <property-ui type="textBox" label="Load Balancer Name" description="The name of the load balancer in this EC2 account to register the instances with"/>
      </property>
      <property name="instanceIds" required='true'>
        <property-ui type='textAreaBox' label="Instance IDs" description='A comma-separated list of IDs of the instances to be assiociated with the load balancer.'/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='registerInstancesWithLB.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>

  <step-type name='Deregister Instances with LoadBalancer'>
    <description>This step will deregister instances with an Amazon Load Balancer.</description>
    <properties>
      <property name='accessKeyId' required='true'>
        <property-ui type='textBox' label='Access Key ID' description='The EC2 access key ID to use to login.' />
      </property>
      <property name='secretKey' required='true'>
        <property-ui type='textBox' label='Secret Key' description='The EC2 Secret Key' />
      </property>
      <property name="loadBalancerName" required="true">
        <property-ui type="textBox" label="Load Balancer Name" description="The name of the load balancer in this EC2 account to deregister the instances from."/>
      </property>
      <property name="instanceIds" required='true'>
        <property-ui type='textAreaBox' label="Instance IDs" description='A comma-separated list of IDs of the instances to be deregistered.'/>
      </property>
      <property name="sdkJar" required="true">
        <property-ui type="textBox" label="AWS Jar" description="The full path to the aws sdk jar."/>
      </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:${sdkJar}:lib/commons-codec.jar:lib/activation-1.1.1.jar:lib/commons-logging.jar:lib/httpclient-cache.jar:lib/httpclient.jar:lib/httpcore.jar:lib/httpmime.jar:lib/javamail-1.4.1.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar:lib/CommonsUtil.jar' />
      <arg file='deregisterInstancesWithLB.groovy' />
      <arg file='${PLUGIN_INPUT_PROPS}' />
      <arg file='${PLUGIN_OUTPUT_PROPS}' />
    </command>
  </step-type>
</plugin>
