You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/03/27 23:45:49 UTC

[01/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Repository: incubator-stratos
Updated Branches:
  refs/heads/master 8bd322477 -> 60b2f3fac


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml
new file mode 100644
index 0000000..e6598ee
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml
@@ -0,0 +1,425 @@
+<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>7c4dd2bd-106d-4cd3-987c-35ee819180a6</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-067a4805</spotInstanceRequestId>
+            <spotPrice>0.040000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:13:07.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-aa67d410</spotInstanceRequestId>
+            <spotPrice>0.040000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:13:57.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-32e32810</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:15:52.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-46a36210</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T20:20:00.000Z</validUntil>
+            <launchGroup>foo</launchGroup>
+            <availabilityZoneGroup>azfoo</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:18:25.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-91780010</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T20:20:00.000Z</validUntil>
+            <launchGroup>foo</launchGroup>
+            <availabilityZoneGroup>azfoo</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:18:25.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-6f1fa605</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:19:27.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-a33eee10</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:21:16.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-aa690410</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:21:52.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-99ba4e06</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T20:26:00.000Z</validUntil>
+            <launchGroup>doo</launchGroup>
+            <availabilityZoneGroup>dooo</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:24:30.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-a617c406</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T20:26:00.000Z</validUntil>
+            <launchGroup>doo</launchGroup>
+            <availabilityZoneGroup>dooo</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:24:30.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-2147a405</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:25:19.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-c441c805</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:29:09.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-4658fe10</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T21:10:00.000Z</validUntil>
+            <launchGroup>check3</launchGroup>
+            <availabilityZoneGroup>check3</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:31:34.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-49a3ce10</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T21:10:00.000Z</validUntil>
+            <launchGroup>check3</launchGroup>
+            <availabilityZoneGroup>check3</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:31:34.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-91b30610</spotInstanceRequestId>
+            <spotPrice>0.010000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T21:10:00.000Z</validUntil>
+            <launchGroup>check3</launchGroup>
+            <availabilityZoneGroup>check3</availabilityZoneGroup>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>
+                                    </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:31:34.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-d8561606</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T20:34:10.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-4cdaa406</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>persistent</type>
+            <state>cancelled</state>
+            <validUntil>2011-03-07T22:25:00.000Z</validUntil>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <keyName>default</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>quick-start-1</groupName>
+                    </item>                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T22:23:19.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-e19f2206</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>open</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-07T22:32:50.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+    </spotInstanceRequestSet>
+</DescribeSpotInstanceRequestsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml
new file mode 100644
index 0000000..2b1a1a1
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>f2247378-7df0-4725-b55f-8ef58b557dcd</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-f4d44212</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T04:01:12.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <tagSet>
+                <item>
+                    <key>One</key>
+                    <value>one</value>
+                </item>
+                <item>
+                    <key>Two</key>
+                    <value>one</value>
+                </item>
+            </tagSet>            
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-43408412</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>jclouds#adriancole-ec2unssh</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T04:02:53.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <tagSet>
+                <item>
+                    <key>One</key>
+                    <value>two</value>
+                </item>
+                <item>
+                    <key>Two</key>
+                    <value>two</value>
+                </item>
+            </tagSet>            
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-e4c3fa14</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>closed</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T05:25:49.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <tagSet>
+                <item>
+                    <key>Two</key>
+                    <value>three</value>
+                </item>
+                <item>
+                    <key>Three</key>
+                    <value>three</value>
+                </item>
+                <item>
+                    <key>Four</key>
+                    <value />
+                </item>
+            </tagSet>            
+            <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
+        </item>
+    </spotInstanceRequestSet>
+</DescribeSpotInstanceRequestsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml
new file mode 100644
index 0000000..5cb54ba
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>f2247378-7df0-4725-b55f-8ef58b557dcd</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-f4d44212</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T04:01:12.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-43408412</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>cancelled</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>jclouds#adriancole-ec2unssh</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T04:02:53.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-e4c3fa14</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>closed</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T05:25:49.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-1ede0012</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>closed</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>jclouds#adriancole-ec2unssh</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T05:27:39.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-596fa211</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>closed</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T06:22:37.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-cc233214</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>closed</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-07-29T07:48:03.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-cf9dd211</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>active</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>jclouds#adriancole-ec2unssh</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <instanceId>i-1faa137e</instanceId>
+            <createTime>2011-07-29T08:05:45.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-6bba1e14</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>active</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>ec2-o</keyName>
+                <groupSet>
+                    <item>
+                        <groupName>jclouds#ec2-o#us-east-1</groupName>
+                    </item>
+                    <item>
+                        <groupName>ec2-o</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>true</enabled>
+                </monitoring>
+            </launchSpecification>
+            <instanceId>i-15982174</instanceId>
+            <createTime>2011-07-29T08:20:27.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
+        </item>
+    </spotInstanceRequestSet>
+</DescribeSpotInstanceRequestsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml
new file mode 100644
index 0000000..c25a536
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeSpotPriceHistoryResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>99777a75-2a2b-4296-a305-650c442d2d63</requestId>
+    <spotPriceHistorySet>
+        <item>
+            <instanceType>t1.micro</instanceType>
+            <productDescription>SUSE Linux</productDescription>
+            <spotPrice>0.013000</spotPrice>
+            <timestamp>2011-03-07T12:17:19.000Z</timestamp>
+            <availabilityZone>us-west-1a</availabilityZone>
+        </item>
+        <item>
+            <instanceType>m1.large</instanceType>
+            <productDescription>Linux/UNIX</productDescription>
+            <spotPrice>0.119000</spotPrice>
+            <timestamp>2011-03-07T16:29:16.000Z</timestamp>
+            <availabilityZone>us-west-1b</availabilityZone>
+        </item>
+        <item>
+            <instanceType>t1.micro</instanceType>
+            <productDescription>Windows</productDescription>
+            <spotPrice>0.013000</spotPrice>
+            <timestamp>2011-03-07T17:56:54.000Z</timestamp>
+            <availabilityZone>us-west-1c</availabilityZone>
+        </item>
+    </spotPriceHistorySet>
+</DescribeSpotPriceHistoryResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml
new file mode 100644
index 0000000..4991b1c
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml
@@ -0,0 +1,16 @@
+<UnmonitorInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <instancesSet>
+	  <item>
+	    <instanceId> i-43a4412a</instanceId>
+	    <monitoring>
+	      <state>pending</state>
+	    </monitoring>
+	  </item>
+	  <item>
+	    <instanceId>i-23a3397d</instanceId>
+	    <monitoring>
+	      <state>pending</state>
+	    </monitoring>
+	  </item>
+    </instancesSet>
+</UnmonitorInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml
new file mode 100644
index 0000000..7f64608
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>02401e8e-a4f5-4285-8ea8-6d742fbaadd8</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-228e6406</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>open</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4ea</groupId>
+                        <groupName>default</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>m1.large</instanceType>
+                <blockDeviceMapping>
+                    <item>
+                        <deviceName>/dev/sda1</deviceName>
+                        <ebs>
+                            <volumeSize>1</volumeSize>
+                            <deleteOnTermination>true</deleteOnTermination>
+                        </ebs>
+                    </item>
+                    <item>
+                        <deviceName>/dev/sda3</deviceName>
+                        <virtualName>vre1</virtualName>
+                    </item>
+                    <item>
+                        <deviceName>/dev/sda2</deviceName>
+                        <ebs>
+                            <snapshotId>snap-1ea27576</snapshotId>
+                            <volumeSize>1</volumeSize>
+                            <deleteOnTermination>true</deleteOnTermination>
+                        </ebs>
+                    </item>
+                </blockDeviceMapping>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+                <iamInstanceProfile>
+                     <arn>arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver</arn>
+                     <name>Webserver</name>
+                </iamInstanceProfile>
+            </launchSpecification>
+            <createTime>2011-03-08T03:30:36.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+    </spotInstanceRequestSet>
+</RequestSpotInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml
new file mode 100644
index 0000000..deca9e5
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>2ffc645f-6835-4d23-bd18-f6f53c253067</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-7c74f805</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>open</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>default</groupId>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping>
+                    <item>
+                        <deviceName>/dev/sda1</deviceName>
+                        <ebs>
+                            <volumeSize>120</volumeSize>
+                            <deleteOnTermination>true</deleteOnTermination>
+                        </ebs>
+                    </item>
+                </blockDeviceMapping>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-08T02:36:32.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-78ca7605</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>open</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>default</groupId>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping>
+                    <item>
+                        <deviceName>/dev/sda1</deviceName>
+                        <ebs>
+                            <volumeSize>120</volumeSize>
+                            <deleteOnTermination>true</deleteOnTermination>
+                        </ebs>
+                    </item>
+                </blockDeviceMapping>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-08T02:36:32.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+        <item>
+            <spotInstanceRequestId>sir-7e0f6005</spotInstanceRequestId>
+            <spotPrice>0.001000</spotPrice>
+            <type>one-time</type>
+            <state>open</state>
+            <launchSpecification>
+                <imageId>ami-595a0a1c</imageId>
+                <groupSet>
+                    <item>
+                        <groupId>default</groupId>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping>
+                    <item>
+                        <deviceName>/dev/sda1</deviceName>
+                        <ebs>
+                            <volumeSize>120</volumeSize>
+                            <deleteOnTermination>true</deleteOnTermination>
+                        </ebs>
+                    </item>
+                </blockDeviceMapping>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <createTime>2011-03-08T02:36:32.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+        </item>
+    </spotInstanceRequestSet>
+</RequestSpotInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml
new file mode 100644
index 0000000..8fdf40a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <requestId>50c73a72-cf38-462f-aba2-f59116380d36</requestId>
+    <imagesSet>
+        <item>
+            <imageId>ami-ccb35ea5</imageId>
+            <imageLocation>rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>411009282317</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-b51cf9dc</kernelId>
+            <ramdiskId>ari-b31cf9da</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping/>
+        </item>
+        <item>
+            <imageId>ami-c19db6b5</imageId>
+            <imageLocation>411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>411009282317</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-a22a01d6</kernelId>
+            <ramdiskId>ari-ac2a01d8</ramdiskId>
+            <name>RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha</name>
+            <description>RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-a222ddcb</snapshotId>
+                        <volumeSize>10</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+        </item>
+        <item>
+            <imageId>ami-710c2605</imageId>
+            <imageLocation>411009282317/RightImage Windows_2003_i386_v5.4.3</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>411009282317</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <platform>windows</platform>
+            <name>RightImage Windows_2003_i386_v5.4.3</name>
+            <description>Built by RightScale</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-9460affd</snapshotId>
+                        <volumeSize>35</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>hvm</virtualizationType>
+        </item>
+        <item>
+            <imageId>ami-c6a882b2</imageId>
+            <imageLocation>411009282317/RightImage_Windows_2008_x64_v5.5.5</imageLocation>
+            <imageOwnerId>411009282317</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <platform>windows</platform>
+            <name>RightImage_Windows_2008_x64_v5.5.5</name>            
+            <description>Built by RightScale</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName> 
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName> 
+                    <ebs>
+                        <snapshotId>snap-68b26c01</snapshotId>                     
+                        <volumeSize>80</volumeSize> 
+                        <deleteOnTermination>true</deleteOnTermination>            
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>hvm</virtualizationType>
+        </item>
+    </imagesSet>
+</DescribeImagesResponse>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml
new file mode 100644
index 0000000..50ff562
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>7faf9500-67ef-484b-9fa5-73b6df638bc8</requestId>
+    <reservationId>r-d3b815bc</reservationId>
+    <ownerId>993194456877</ownerId>
+    <groupSet>
+        <item>
+            <groupId>sg-3ffcd956</groupId>
+            <groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
+        </item>
+    </groupSet>
+    <instancesSet>
+        <item>
+            <instanceId>i-8949f0e8</instanceId>
+            <imageId>ami-ab5b9cc2</imageId>
+            <instanceState>
+                <code>0</code>
+                <name>pending</name>
+            </instanceState>
+            <privateDnsName/>
+            <dnsName/>
+            <reason/>
+            <keyName>jclouds#adriancoleec2cccluster</keyName>
+            <amiLaunchIndex>0</amiLaunchIndex>
+            <productCodes/>
+            <instanceType>cc1.4xlarge</instanceType>
+            <launchTime>2011-07-29T09:46:48.000Z</launchTime>
+            <placement>
+                <availabilityZone>us-east-1d</availabilityZone>
+                <groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
+                <tenancy>default</tenancy>
+            </placement>
+            <monitoring>
+                <state>disabled</state>
+            </monitoring>
+            <groupSet>
+                <item>
+                    <groupId>sg-3ffcd956</groupId>
+                    <groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <stateReason>
+                <code>pending</code>
+                <message>pending</message>
+            </stateReason>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping/>
+            <virtualizationType>hvm</virtualizationType>
+            <clientToken/>
+            <hypervisor>xen</hypervisor>
+        </item>
+    </instancesSet>
+</RunInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml
new file mode 100644
index 0000000..985b267
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <requestId>6104eee1-affd-49d7-92a0-516cab8a8ba6</requestId>
+    <imagesSet>
+        <item>
+            <imageId>ami-870de2ee</imageId>
+            <imageLocation>vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>133804938231</imageOwnerId>
+            <isPublic>false</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-94c527fd</kernelId>
+            <ramdiskId>ari-96c527ff</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+    </imagesSet>
+</DescribeImagesResponse>


[08/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java
new file mode 100644
index 0000000..e9f79e8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.LaunchSpecification.Builder;
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
+import org.jclouds.logging.Logger;
+import org.xml.sax.Attributes;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class LaunchSpecificationHandler extends HandlerForGeneratedRequestWithResult<LaunchSpecification> {
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   protected final DateCodec dateCodec;
+   protected final Builder builder;
+   protected final BlockDeviceMapping.Builder blockDeviceMappingBuilder;
+
+   @Inject
+   public LaunchSpecificationHandler(DateCodecFactory dateCodecFactory, LaunchSpecification.Builder builder,
+            BlockDeviceMapping.Builder blockDeviceMappingBuilder) {
+      this.dateCodec = dateCodecFactory.iso8601();
+      this.builder = builder;
+      this.blockDeviceMappingBuilder = blockDeviceMappingBuilder;
+   }
+
+   protected String currentOrNull() {
+      String returnVal = currentText.toString().trim();
+      return returnVal.equals("") ? null : returnVal;
+   }
+
+   protected StringBuilder currentText = new StringBuilder();
+
+   private boolean inBlockDeviceMapping;
+   private boolean inIamInstanceProfile;
+
+   private String groupId;
+
+   public void startElement(String uri, String name, String qName, Attributes attrs) {
+      if (qName.equals("blockDeviceMapping")) {
+         inBlockDeviceMapping = true;
+      } else if (equalsOrSuffix(qName, "iamInstanceProfile")) {
+         inIamInstanceProfile = true;
+      }
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("blockDeviceMapping")) {
+         inBlockDeviceMapping = false;
+      } else if (equalsOrSuffix(qName, "iamInstanceProfile")) {
+         inIamInstanceProfile = false;
+      } else if (qName.equals("item") && inBlockDeviceMapping) {
+         try {
+            builder.blockDeviceMapping(blockDeviceMappingBuilder.build());
+         } finally {
+            blockDeviceMappingBuilder.clear();
+         }
+      } else if (equalsOrSuffix(qName, "arn") && inIamInstanceProfile) {
+         builder.iamInstanceProfileArn(currentOrNull());
+      } else if (equalsOrSuffix(qName, "name") && inIamInstanceProfile) {
+         builder.iamInstanceProfileName(currentOrNull());         
+      } else if (qName.equals("deviceName")) {
+         blockDeviceMappingBuilder.deviceName(currentOrNull());
+      } else if (qName.equals("virtualName")) {
+         blockDeviceMappingBuilder.virtualName(currentOrNull());
+      } else if (qName.equals("snapshotId")) {
+         blockDeviceMappingBuilder.snapshotId(currentOrNull());
+      } else if (qName.equals("volumeSize")) {
+         String volumeSize = currentOrNull();
+         if (volumeSize != null)
+            blockDeviceMappingBuilder.sizeInGib(Integer.parseInt(volumeSize));
+      } else if (qName.equals("noDevice")) {
+         String noDevice = currentOrNull();
+         if (noDevice != null)
+            blockDeviceMappingBuilder.noDevice(Boolean.parseBoolean(noDevice));
+      } else if (qName.equals("deleteOnTermination")) {
+         String deleteOnTermination = currentOrNull();
+         if (deleteOnTermination != null)
+            blockDeviceMappingBuilder.deleteOnTermination(Boolean.parseBoolean(deleteOnTermination));
+      } else if (qName.equals("groupId")) {
+         groupId = currentOrNull();
+      } else if (qName.equals("groupName")) {
+         builder.securityGroupIdToName(groupId, currentOrNull());
+         groupId = null;
+      } else if (qName.equals("imageId")) {
+         builder.imageId(currentOrNull());
+      } else if (qName.equals("instanceType")) {
+         builder.instanceType(currentOrNull());
+      } else if (qName.equals("kernelId")) {
+         builder.kernelId(currentOrNull());
+      } else if (qName.equals("keyName")) {
+         builder.keyName(currentOrNull());
+      } else if (qName.equals("availabilityZone")) {
+         builder.availabilityZone(currentOrNull());
+      } else if (qName.equals("subnetId")) {
+         builder.subnetId(currentOrNull());
+      } else if (qName.equals("ramdiskId")) {
+         builder.ramdiskId(currentOrNull());
+      } else if (qName.equals("enabled")) {
+         String monitoringEnabled = currentOrNull();
+         if (monitoringEnabled != null)
+            builder.monitoringEnabled(Boolean.valueOf(monitoringEnabled));
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+
+   @Override
+   public LaunchSpecification getResult() {
+      try {
+         return builder.build();
+      } finally {
+         builder.clear();
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/MonitoringStateHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/MonitoringStateHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/MonitoringStateHandler.java
new file mode 100644
index 0000000..a751a82
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/MonitoringStateHandler.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Map;
+
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.collect.Maps;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class MonitoringStateHandler extends
+         ParseSax.HandlerWithResult<Map<String, MonitoringState>> {
+   private StringBuilder currentText = new StringBuilder();
+
+   private Map<String, MonitoringState> monitoringState = Maps.newHashMap();
+   private String instanceId;
+   private MonitoringState state;
+
+   public Map<String, MonitoringState> getResult() {
+      return monitoringState;
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("instanceId")) {
+         instanceId = currentText.toString().trim();
+      } else if (qName.equals("state")) {
+         state = MonitoringState.fromValue(currentText.toString().trim());
+      } else if (qName.equals("item")) {
+         monitoringState.put(instanceId, state);
+         this.instanceId = null;
+         this.state = null;
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java
new file mode 100644
index 0000000..8b084c7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.PlacementGroup.State;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class PlacementGroupHandler extends
+         ParseSax.HandlerForGeneratedRequestWithResult<PlacementGroup> {
+   private StringBuilder currentText = new StringBuilder();
+
+   @Inject
+   @Region
+   Supplier<String> defaultRegion;
+
+   private String name;
+   private String strategy = "cluster";
+   private State state;
+
+   public PlacementGroup getResult() {
+      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
+      if (region == null)
+         region = defaultRegion.get();
+      PlacementGroup returnVal = new PlacementGroup(region, name, strategy, state);
+      this.name = null;
+      this.strategy = "cluster";
+      this.state = null;
+      return returnVal;
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("groupName")) {
+         this.name = currentText.toString().trim();
+      } else if (qName.equals("strategy")) {
+         strategy = currentText.toString().trim();
+      } else if (qName.equals("state")) {
+         state = PlacementGroup.State.fromValue(currentText.toString().trim());
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java
new file mode 100644
index 0000000..a028764
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Set;
+
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.collect.Sets;
+
+/**
+ * 
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImageAttribute.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class ProductCodesHandler extends ParseSax.HandlerWithResult<Set<String>> {
+
+   private StringBuilder currentText = new StringBuilder();
+   private Set<String> productCodes = Sets.newHashSet();
+
+   public Set<String> getResult() {
+      return productCodes;
+   }
+
+   public void endElement(String uri, String name, String qName) {
+
+      if (qName.equalsIgnoreCase("productCode")) {
+         productCodes.add(currentText.toString().trim());
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java
new file mode 100644
index 0000000..63ffe3f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.ec2.domain.ReservedInstancesOffering;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ * 
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeReservedInstancesOfferingsResponseSetItemType.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class ReservedInstancesOfferingHandler extends
+      ParseSax.HandlerForGeneratedRequestWithResult<ReservedInstancesOffering> {
+   @Inject
+   @Region
+   Supplier<String> defaultRegion;
+
+   private StringBuilder currentText = new StringBuilder();
+
+   private String availabilityZone;
+   private long duration = 0;
+   private float fixedPrice = 0;
+   private String instanceType;
+   private String productDescription;
+   private String id;
+   private float usagePrice = 0;
+
+   public ReservedInstancesOffering getResult() {
+      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
+      if (region == null)
+         region = defaultRegion.get();
+
+      ReservedInstancesOffering returnVal = new ReservedInstancesOffering(region, availabilityZone, duration,
+            fixedPrice, instanceType, productDescription, id, usagePrice);
+      this.availabilityZone = null;
+      this.duration = 0;
+      this.fixedPrice = 0;
+      this.instanceType = null;
+      this.productDescription = null;
+      this.id = null;
+      this.usagePrice = 0;
+      return returnVal;
+   }
+
+   public void endElement(String uri, String name, String qName) {
+
+      if (qName.equalsIgnoreCase("reservedInstancesOfferingId")) {
+         this.id = currentText.toString().trim();
+      } else if (qName.equalsIgnoreCase("availabilityZone")) {
+         this.availabilityZone = currentText.toString().trim();
+      } else if (qName.equalsIgnoreCase("duration")) {
+         this.duration = Long.parseLong(currentText.toString().trim());
+      } else if (qName.equalsIgnoreCase("fixedPrice")) {
+         this.fixedPrice = Float.parseFloat(currentText.toString().trim());
+      } else if (qName.equalsIgnoreCase("instanceType")) {
+         this.instanceType = currentText.toString().trim();
+      } else if (qName.equalsIgnoreCase("productDescription")) {
+         this.productDescription = currentText.toString().trim();
+      } else if (qName.equalsIgnoreCase("usagePrice")) {
+         this.usagePrice = Float.parseFloat(currentText.toString().trim());
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
new file mode 100644
index 0000000..ba01984
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Spot> {
+   private StringBuilder currentText = new StringBuilder();
+
+   protected final DateCodec dateCodec;
+   protected final Supplier<String> defaultRegion;
+
+   @Inject
+   public SpotHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
+      this.dateCodec = dateCodecFactory.iso8601();
+      this.defaultRegion = defaultRegion;
+   }
+
+   private Spot.Builder builder = Spot.builder();
+
+   public Spot getResult() {
+      try {
+         String region = getRequest() == null ? null : AWSUtils.findRegionInArgsOrNull(getRequest());
+         if (region == null)
+            region = defaultRegion.get();
+         return builder.region(region).build();
+      } finally {
+         builder.clear();
+      }
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("instanceType")) {
+         builder.instanceType(currentText.toString().trim());
+      } else if (qName.equals("productDescription")) {
+         builder.productDescription(currentText.toString().trim());
+      } else if (qName.equals("spotPrice")) {
+         builder.spotPrice(Float.parseFloat(currentText.toString().trim()));
+      } else if (qName.equals("timestamp")) {
+         builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
+      } else if (qName.equals("availabilityZone")) {
+         builder.availabilityZone(currentText.toString().trim());
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java
new file mode 100644
index 0000000..302f1b4
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest.Builder;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.ec2.xml.TagSetHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.location.Region;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Supplier;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SpotInstanceRequest> {
+   private StringBuilder currentText = new StringBuilder();
+
+   protected final DateCodec dateCodec;
+   protected final Supplier<String> defaultRegion;
+   protected final Builder builder;
+   protected boolean inLaunchSpecification;
+   protected final LaunchSpecificationHandler launchSpecificationHandler;
+   protected boolean inTagSet;
+   protected final TagSetHandler tagSetHandler;
+
+   @Inject
+   public SpotInstanceHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
+         LaunchSpecificationHandler launchSpecificationHandler, TagSetHandler tagSetHandler,
+         SpotInstanceRequest.Builder builder) {
+      this.dateCodec = dateCodecFactory.iso8601();
+      this.defaultRegion = defaultRegion;
+      this.launchSpecificationHandler = launchSpecificationHandler;
+      this.tagSetHandler = tagSetHandler;
+      this.builder = builder;
+   }
+
+   public SpotInstanceRequest getResult() {
+      try {
+         String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
+         if (region == null)
+            region = defaultRegion.get();
+         return builder.region(region).build();
+      } finally {
+         builder.clear();
+      }
+   }
+
+   @Override
+   public void startElement(String uri, String name, String qName, Attributes attrs) throws SAXException {
+      if (equalsOrSuffix(qName, "launchSpecification")) {
+         inLaunchSpecification = true;
+      } else if (equalsOrSuffix(qName, "tagSet")) {
+         inTagSet = true;
+      }
+      if (inLaunchSpecification) {
+          launchSpecificationHandler.startElement(uri, name, qName, attrs);
+      } else if (inTagSet) {
+          tagSetHandler.startElement(uri, name, qName, attrs);
+      }
+   }
+
+   @Override
+   public void endElement(String uri, String name, String qName) throws SAXException {
+      if (equalsOrSuffix(qName, "tagSet")) {
+         inTagSet = false;
+         builder.tags(tagSetHandler.getResult());
+      } else if (inTagSet) {
+         tagSetHandler.endElement(uri, name, qName);
+      }
+
+      if (qName.equals("launchSpecification")) {
+         inLaunchSpecification = false;
+         builder.launchSpecification(launchSpecificationHandler.getResult());
+      } else if (inLaunchSpecification) {
+         launchSpecificationHandler.endElement(uri, name, qName);
+      }
+
+      if (qName.equals("spotInstanceRequestId")) {
+         builder.id(currentOrNull(currentText));
+      } else if (qName.equals("instanceId")) {
+         builder.instanceId(currentOrNull(currentText));
+      } else if (qName.equals("launchedAvailabilityZone")) {
+         builder.launchedAvailabilityZone(currentOrNull(currentText));
+      } else if (qName.equals("availabilityZoneGroup")) {
+         builder.availabilityZoneGroup(currentOrNull(currentText));
+      } else if (qName.equals("launchGroup")) {
+         builder.launchGroup(currentOrNull(currentText));
+      } else if (qName.equals("code")) {
+         builder.faultCode(currentOrNull(currentText));
+      } else if (qName.equals("message")) {
+         builder.faultMessage(currentOrNull(currentText));
+      } else if (qName.equals("spotPrice")) {
+         String price = currentOrNull(currentText);
+         if (price != null)
+            builder.spotPrice(Float.parseFloat(price));
+      } else if (qName.equals("type")) {
+         String type = currentOrNull(currentText);
+         if (type != null)
+            builder.type(SpotInstanceRequest.Type.fromValue(type));
+      } else if (qName.equals("state")) {
+         String rawState = currentOrNull(currentText);
+         if (rawState != null) {
+            builder.rawState(rawState);
+            builder.state(SpotInstanceRequest.State.fromValue(rawState));
+         }
+      } else if (qName.equals("createTime")) {
+         String createTime = currentOrNull(currentText);
+         if (createTime != null)
+            builder.createTime(dateCodec.toDate(createTime));
+      } else if (qName.equals("productDescription")) {
+         builder.productDescription(currentOrNull(currentText));
+      }
+      currentText = new StringBuilder();
+   }
+
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inLaunchSpecification) {
+         launchSpecificationHandler.characters(ch, start, length);
+      } else if (inTagSet) {
+         tagSetHandler.characters(ch, start, length);
+      } else {
+         currentText.append(ch, start, length);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java
new file mode 100644
index 0000000..7f08167
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.HandlerWithResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * @author Adrian Cole
+ */
+public class SpotInstancesHandler extends ParseSax.HandlerWithResult<Set<SpotInstanceRequest>> {
+
+   private final Builder<SpotInstanceRequest> spotRequests = ImmutableSet.builder();
+   private final SpotInstanceHandler spotRequestHandler;
+   private int itemDepth;
+
+   @Inject
+   public SpotInstancesHandler(SpotInstanceHandler spotRequestHandler) {
+      this.spotRequestHandler = spotRequestHandler;
+   }
+
+   public Set<SpotInstanceRequest> getResult() {
+      return spotRequests.build();
+   }
+
+   @Override
+   public HandlerWithResult<Set<SpotInstanceRequest>> setContext(HttpRequest request) {
+      spotRequestHandler.setContext(request);
+      return super.setContext(request);
+   }
+
+   @Override
+   public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+      if (qName.equals("item"))
+         itemDepth++;
+      if (itemDepth >= 1)
+         spotRequestHandler.startElement(uri, localName, qName, attributes);
+   }
+
+   @Override
+   public void endElement(String uri, String localName, String qName) throws SAXException {
+      if (qName.equals("item") && itemDepth == 1) {
+         spotRequests.add(spotRequestHandler.getResult());
+      }
+      if (qName.equals("item"))
+         itemDepth--;
+      if (itemDepth >= 1)
+         spotRequestHandler.endElement(uri, localName, qName);
+   }
+
+   public void characters(char ch[], int start, int length) {
+      if (itemDepth >= 1)
+         spotRequestHandler.characters(ch, start, length);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
new file mode 100644
index 0000000..636b065
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
@@ -0,0 +1 @@
+org.jclouds.aws.ec2.AWSEC2ProviderMetadata

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj
new file mode 100644
index 0000000..bd00ef7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj
@@ -0,0 +1,32 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements.  See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License.  You may obtain a copy of the License at
+;
+;     http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+(ns org.jclouds.aws.ec2-test
+  (:use
+    org.jclouds.aws.ec2
+    clojure.test))
+
+(deftest translate-enum-value-test
+  (is (= org.jclouds.aws.ec2.domain.SpotInstanceRequest$Type/ONE_TIME
+         (org.jclouds.aws.ec2/translate-enum-value :type :one-time))))
+
+(deftest spot-options-est
+  (is (spot-options {:type :one-time
+                     :valid-from (java.util.Date.)
+                     :valid-until (java.util.Date.)
+                     :launch-group "lg"
+                     :availability-zone-group "ag"})))

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java
new file mode 100644
index 0000000..42a6450
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
+import static org.jclouds.reflect.Reflection2.typeToken;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.View;
+import org.jclouds.aws.ec2.compute.config.ImageQuery;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.ec2.EC2Api;
+import org.testng.annotations.Test;
+
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "AWSEC2ContextBuilderTest")
+public class AWSEC2ContextBuilderTest {
+   private Map<String, String> queriesForProperties(Properties input) {
+      return ContextBuilder.newBuilder(new AWSEC2ProviderMetadata()).overrides(input).credentials("foo", "bar")
+               .buildInjector().getInstance(Key.get(new TypeLiteral<Map<String, String>>() {
+               }, ImageQuery.class));
+   }
+
+   public void testAssignability() {
+      View view = ContextBuilder.newBuilder(new AWSEC2ProviderMetadata()).credentials("foo", "bar")
+              .buildView(typeToken(ComputeServiceContext.class));
+      view.unwrapApi(EC2Api.class);
+      view.unwrapApi(AWSEC2Api.class);
+   }
+
+   public void testConvertImageSyntax() {
+      Properties input = new Properties();
+      input.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
+      Map<String, String> queries = queriesForProperties(input);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY),
+               "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine");
+   }
+
+   public void testConvertImageSyntaxWhenStar() {
+      Properties input = new Properties();
+      input.setProperty(PROPERTY_EC2_AMI_OWNERS, "*");
+      Map<String, String> queries = queriesForProperties(input);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine");
+   }
+
+   public void testBlankAmiOwnersRemovesAmiQuery() {
+      Properties input = new Properties();
+      input.setProperty(PROPERTY_EC2_AMI_OWNERS, "");
+      Map<String, String> queries = queriesForProperties(input);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null);
+      assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), null);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java
new file mode 100644
index 0000000..465cb63
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+
+import org.jclouds.providers.internal.BaseProviderMetadataTest;
+import org.testng.annotations.Test;
+
+/**
+ * The AWSEC2ProviderTest tests the org.jclouds.providers.AWSEC2Provider class.
+ * 
+ * @author Jeremy Whitlock <jw...@apache.org>
+ */
+@Test(groups = "unit", testName = "AWSEC2ProviderTest")
+public class AWSEC2ProviderTest extends BaseProviderMetadataTest {
+
+   public AWSEC2ProviderTest() {
+      super(new AWSEC2ProviderMetadata(), new AWSEC2ApiMetadata());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java
new file mode 100644
index 0000000..586c924
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.testng.Assert.assertEquals;
+
+import java.net.UnknownHostException;
+
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.ec2.domain.InstanceType;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class BindLaunchSpecificationToFormParamsTest {
+   BindLaunchSpecificationToFormParams binder = new BindLaunchSpecificationToFormParams();
+
+   @Test
+   public void testApplyWithBlockDeviceMappings() throws UnknownHostException {
+      LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
+            .mapNewVolumeToDevice("/dev/sda1", 120, true).build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.BlockDeviceMapping.1.DeviceName",
+            "/dev/sda1", "LaunchSpecification.BlockDeviceMapping.1.Ebs.VolumeSize", "120",
+            "LaunchSpecification.BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true"));
+   }
+
+   @Test
+   public void testApplyWithUserData() throws UnknownHostException {
+      LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
+            .userData("hello".getBytes()).build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.UserData",
+            base64().encode("hello".getBytes(UTF_8))));
+   }
+
+   @Test
+   public void testApplyWithSecurityId() throws UnknownHostException {
+      LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
+            .securityGroupId("sid-foo").build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.SecurityGroupId.1", "sid-foo"));
+   }
+
+   @Test
+   public void testApplyWithSubnetId() throws UnknownHostException {
+      LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
+            .subnetId("subnet-xyz").build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.SubnetId", "subnet-xyz"));
+   }
+
+   @Test
+   public void testApplyWithIAMInstanceProfileArn() {
+      LaunchSpecification spec = LaunchSpecification.builder()
+            .instanceType(InstanceType.T1_MICRO)
+            .imageId("ami-123")
+            .iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver")
+            .build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.IamInstanceProfile.Arn",
+            "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver"));
+   }
+
+   @Test
+   public void testApplyWithIAMInstanceProfileName() {
+      LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
+            .iamInstanceProfileName("Webserver").build();
+
+      assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
+            "LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.IamInstanceProfile.Name", "Webserver"));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java
new file mode 100644
index 0000000..2ae0422
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code BindTagsToIndexedFormParams}
+ * 
+ * @author grkvlt@apache.org
+ */
+@Test(groups = "unit")
+public class BindTagsToIndexedFormParamsTest {
+   Injector injector = Guice.createInjector();
+   BindTagsToIndexedFormParams binder = injector.getInstance(BindTagsToIndexedFormParams.class);
+
+   public void test() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+      request = binder.bindToRequest(request, ImmutableMap.<String, String>builder().put("one", "alpha").put("two", "beta").build());
+      assertEquals(request.getPayload().getRawContent(), "Tag.1.Key=one&Tag.1.Value=alpha&Tag.2.Key=two&Tag.2.Value=beta");
+   }
+
+   public void testEmpty() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+      request = binder.bindToRequest(request, ImmutableMap.<String, String>builder().put("empty", "").build());
+      assertEquals(request.getPayload().getRawContent(), "Tag.1.Key=empty&Tag.1.Value=");
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testMustBeArray() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+      binder.bindToRequest(request, new File("foo"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testNullIsBad() {
+      HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
+      binder.bindToRequest(request, null);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java
new file mode 100644
index 0000000..61f8169
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.blockUntilRunning;
+import static org.testng.Assert.assertEquals;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests the compute service abstraction of the EC2 api.
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "AWSEC2ComputeServiceExpectTest")
+public class AWSEC2ComputeServiceExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   private HttpResponse requestSpotInstancesResponse;
+   private HttpRequest describeSpotInstanceRequest;
+   private HttpResponse describeSpotInstanceResponse;
+
+   @BeforeClass
+   @Override
+   protected void setupDefaultRequests() {
+      super.setupDefaultRequests();
+      requestSpotInstancesResponse = HttpResponse.builder().statusCode(200)
+                       .payload(payloadFromResourceWithContentType(
+                             "/request_spot_instances-ebs.xml", MediaType.APPLICATION_XML)).build();
+   
+      describeSpotInstanceRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                       .endpoint("https://ec2." + region + ".amazonaws.com/")
+                       .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                       .addFormParam("Action", "DescribeSpotInstanceRequests")
+                       .addFormParam("SpotInstanceRequestId.1", "sir-228e6406").build());
+
+      describeSpotInstanceResponse = HttpResponse.builder().statusCode(200)
+                       .payload(payloadFromResourceWithContentType(
+                             "/request_spot_instances-ebs.xml", MediaType.APPLICATION_XML)).build();
+   }
+
+   public void testLaunchVPCSpotInstanceSubnetId() throws Exception {
+      HttpRequest requestSpotInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                          .endpoint("https://ec2." + region + ".amazonaws.com/")
+                          .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                          .addFormParam("Action", "RequestSpotInstances")
+                          .addFormParam("InstanceCount", "1")
+                          .addFormParam("LaunchSpecification.ImageId", "ami-be3adfd7")
+                          .addFormParam("LaunchSpecification.InstanceType", "m1.small")
+                          .addFormParam("LaunchSpecification.KeyName", "Demo")
+                          .addFormParam("LaunchSpecification.Placement.AvailabilityZone", "us-east-1a")
+                          .addFormParam("LaunchSpecification.SubnetId", "subnet-xyz")
+                          .addFormParam("LaunchSpecification.UserData", "I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK")
+                          .addFormParam("SpotPrice", "1.0").build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+      requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(requestSpotInstancesRequest, requestSpotInstancesResponse);
+      requestResponseMap.put(describeSpotInstanceRequest, describeSpotInstanceResponse);
+
+      ComputeService createsVPCSpotInstance = requestsSendResponses(requestResponseMap.build());
+
+      Template template = createsVPCSpotInstance.templateBuilder().locationId("us-east-1a").build();
+
+      template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(1f).subnetId("subnet-xyz").keyPair("Demo").blockUntilRunning(false);
+
+      NodeMetadata node = Iterables.getOnlyElement(createsVPCSpotInstance.createNodesInGroup("test", 1, template));
+      assertEquals(node.getId(), "us-east-1/sir-228e6406");
+   }
+
+   String iamInstanceProfileArn = "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver";
+
+   public void testLaunchSpotInstanceIAMInstanceProfileArn() throws Exception {
+      HttpRequest requestSpotInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                          .endpoint("https://ec2." + region + ".amazonaws.com/")
+                          .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                          .addFormParam("Action", "RequestSpotInstances")
+                          .addFormParam("InstanceCount", "1")
+                          .addFormParam("LaunchSpecification.IamInstanceProfile.Arn", iamInstanceProfileArn)
+                          .addFormParam("LaunchSpecification.ImageId", "ami-be3adfd7")
+                          .addFormParam("LaunchSpecification.InstanceType", "m1.small")
+                          .addFormParam("LaunchSpecification.Placement.AvailabilityZone", "us-east-1a")
+                          .addFormParam("LaunchSpecification.SecurityGroup.1", "jclouds#test")
+                          .addFormParam("LaunchSpecification.UserData", "I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK")
+                          .addFormParam("SpotPrice", "1.0").build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+      requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(requestSpotInstancesRequest, requestSpotInstancesResponse);
+      requestResponseMap.put(describeSpotInstanceRequest, describeSpotInstanceResponse);
+
+      ComputeService createsSpotInstance = requestsSendResponses(requestResponseMap.build());
+
+      Template template = createsSpotInstance.templateBuilder().locationId("us-east-1a").build();
+
+      template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(1f).iamInstanceProfileArn(iamInstanceProfileArn)
+            .noKeyPair().blockUntilRunning(false);
+
+      NodeMetadata node = Iterables.getOnlyElement(createsSpotInstance.createNodesInGroup("test", 1, template));
+      assertEquals(node.getId(), "us-east-1/sir-228e6406");
+   }
+
+   public void testLaunchSpotInstanceIAMInstanceProfileName() throws Exception {
+      HttpRequest requestSpotInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                          .endpoint("https://ec2." + region + ".amazonaws.com/")
+                          .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                          .addFormParam("Action", "RequestSpotInstances")
+                          .addFormParam("InstanceCount", "1")
+                          .addFormParam("LaunchSpecification.IamInstanceProfile.Name", "Webserver")
+                          .addFormParam("LaunchSpecification.ImageId", "ami-be3adfd7")
+                          .addFormParam("LaunchSpecification.InstanceType", "m1.small")
+                          .addFormParam("LaunchSpecification.Placement.AvailabilityZone", "us-east-1a")
+                          .addFormParam("LaunchSpecification.SecurityGroup.1", "jclouds#test")
+                          .addFormParam("LaunchSpecification.UserData", "I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK")
+                          .addFormParam("SpotPrice", "1.0").build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+      requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(requestSpotInstancesRequest, requestSpotInstancesResponse);
+      requestResponseMap.put(describeSpotInstanceRequest, describeSpotInstanceResponse);
+
+      ComputeService createsSpotInstance = requestsSendResponses(requestResponseMap.build());
+
+      Template template = createsSpotInstance.templateBuilder().locationId("us-east-1a").build();
+
+      template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(1f).iamInstanceProfileName("Webserver")
+            .noKeyPair().blockUntilRunning(false);
+
+      NodeMetadata node = Iterables.getOnlyElement(createsSpotInstance.createNodesInGroup("test", 1, template));
+      assertEquals(node.getId(), "us-east-1/sir-228e6406");
+   }
+
+   public void testCreateNodeWithIAMInstanceProfileArn() throws Exception {
+      HttpRequest runInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+            .endpoint("https://ec2." + region + ".amazonaws.com/")
+            .addHeader("Host", "ec2." + region + ".amazonaws.com")
+            .addFormParam("Action", "RunInstances")
+            .addFormParam("IamInstanceProfile.Arn", iamInstanceProfileArn)
+            .addFormParam("ImageId", "ami-be3adfd7")
+            .addFormParam("InstanceType", "m1.small")
+            .addFormParam("MaxCount", "1")
+            .addFormParam("MinCount", "1")
+            .addFormParam("SecurityGroup.1", "jclouds#test")
+            .addFormParam("UserData", "I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK").build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+      requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(runInstancesRequest, runInstancesResponse);
+      requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
+      requestResponseMap.put(describeImageRequest, describeImagesResponse);
+
+      ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
+
+      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+            blockUntilRunning(false).iamInstanceProfileArn(iamInstanceProfileArn).noKeyPair()));
+      assertEquals(node.getId(), "us-east-1/i-2baa5550");
+   }
+
+   public void testCreateNodeWithIAMInstanceProfileName() throws Exception {
+      HttpRequest runInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+            .endpoint("https://ec2." + region + ".amazonaws.com/")
+            .addHeader("Host", "ec2." + region + ".amazonaws.com")
+            .addFormParam("Action", "RunInstances")
+            .addFormParam("IamInstanceProfile.Name", "Webserver")
+            .addFormParam("ImageId", "ami-be3adfd7")
+            .addFormParam("InstanceType", "m1.small")
+            .addFormParam("MaxCount", "1")
+            .addFormParam("MinCount", "1")
+            .addFormParam("SecurityGroup.1", "jclouds#test")
+            .addFormParam("UserData", "I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK").build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+      requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+      requestResponseMap.put(runInstancesRequest, runInstancesResponse);
+      requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
+      requestResponseMap.put(describeImageRequest, describeImagesResponse);
+
+      ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
+
+      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+            blockUntilRunning(false).iamInstanceProfileName("Webserver").noKeyPair()));
+      assertEquals(node.getId(), "us-east-1/i-2baa5550");
+   }
+
+   public void testListNodesWhereImageDoesntExist() throws Exception {
+      HttpRequest describeInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "DescribeInstances").build());
+
+      HttpRequest describeSpotInstancesRequest = formSigner.filter(HttpRequest.builder().method("POST")
+                          .endpoint("https://ec2." + region + ".amazonaws.com/")
+                          .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                          .addFormParam("Action", "DescribeSpotInstanceRequests").build());
+
+      HttpResponse noSpotInstancesResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromStringWithContentType(
+                  "<DescribeSpotInstanceRequestsResponse><spotInstanceRequestSet></spotInstanceRequestSet></DescribeSpotInstanceRequestsResponse>",
+                  MediaType.APPLICATION_XML)).build();
+      
+      HttpResponse noImagesResponse = HttpResponse.builder().statusCode(200)
+                          .payload(payloadFromStringWithContentType(
+                                 "<DescribeImagesResponse><imagesSet></imagesSet></DescribeImagesResponse>",
+                                 MediaType.APPLICATION_XML)).build();
+      
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeImagesRequest, noImagesResponse);
+      requestResponseMap.put(describeInstancesRequest, describeInstanceResponse);
+      requestResponseMap.put(describeSpotInstancesRequest, noSpotInstancesResponse);
+
+      ComputeService listsWithoutImages = requestsSendResponses(requestResponseMap.build());
+
+      NodeMetadata node = Iterables.getOnlyElement(listsWithoutImages.listNodesDetailsMatching(NodePredicates.all()));
+      assertEquals(node.getId(), "us-east-1/i-2baa5550");
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java
new file mode 100644
index 0000000..83bb96c
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Sets.newTreeSet;
+import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
+import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
+import static org.jclouds.ec2.util.IpPermissions.permit;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.cloudwatch.CloudWatchApi;
+import org.jclouds.cloudwatch.domain.Dimension;
+import org.jclouds.cloudwatch.domain.EC2Constants;
+import org.jclouds.cloudwatch.domain.GetMetricStatistics;
+import org.jclouds.cloudwatch.domain.GetMetricStatisticsResponse;
+import org.jclouds.cloudwatch.domain.Statistics;
+import org.jclouds.cloudwatch.domain.Unit;
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.ec2.features.KeyPairApi;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.scriptbuilder.domain.Statements;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest")
+public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
+
+   public AWSEC2ComputeServiceLiveTest() {
+      provider = "aws-ec2";
+      group = "ec2";
+   }
+
+   @Override
+   @Test
+   public void testExtendedOptionsAndLogin() throws Exception {
+      String region = "us-west-2";
+
+      AWSSecurityGroupApi securityGroupApi = view.unwrapApi(AWSEC2Api.class).getSecurityGroupApi().get();
+
+      KeyPairApi keyPairApi = view.unwrapApi(AWSEC2Api.class).getKeyPairApi().get();
+
+      InstanceApi instanceApi = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get();
+
+      String group = this.group + "o";
+
+      Date before = new Date();
+
+      ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group);
+
+      ImmutableSet<String> tags = ImmutableSet.of(group);
+
+      // note that if you change the location, you must also specify image parameters
+      Template template = client.templateBuilder().locationId(region).osFamily(AMZN_LINUX).os64Bit(true).build();
+      template.getOptions().tags(tags);
+      template.getOptions().userMetadata(userMetadata);
+      template.getOptions().tags(tags);
+      template.getOptions().as(AWSEC2TemplateOptions.class).enableMonitoring();
+      template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(0.3f);
+
+      String startedId = null;
+      try {
+         cleanupExtendedStuffInRegion(region, securityGroupApi, keyPairApi, group);
+
+         Thread.sleep(3000);// eventual consistency if deletes actually occurred.
+
+         // create a security group that allows ssh in so that our scripts later
+         // will work
+         String groupId = securityGroupApi.createSecurityGroupInRegionAndReturnId(region, group, group);
+
+         securityGroupApi.authorizeSecurityGroupIngressInRegion(region, groupId, permit(IpProtocol.TCP).port(22));
+
+         template.getOptions().as(AWSEC2TemplateOptions.class).securityGroupIds(groupId);
+
+         // create a keypair to pass in as well
+         KeyPair result = keyPairApi.createKeyPairInRegion(region, group);
+         template.getOptions().as(AWSEC2TemplateOptions.class).keyPair(result.getKeyName());
+
+         // pass in the private key, so that we can run a script with it
+         assert result.getKeyMaterial() != null : result;
+         template.getOptions().overrideLoginPrivateKey(result.getKeyMaterial());
+
+         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
+         NodeMetadata first = getOnlyElement(nodes);
+
+         checkUserMetadataContains(first, userMetadata);
+         checkTagsInNodeEquals(first, tags);
+
+         assert first.getCredentials() != null : first;
+         assert first.getCredentials().identity != null : first;
+
+         startedId = first.getProviderId();
+
+         AWSRunningInstance instance = AWSRunningInstance.class.cast(getOnlyElement(getOnlyElement(instanceApi
+                  .describeInstancesInRegion(region, startedId))));
+
+         assertEquals(instance.getKeyName(), group);
+         assert instance.getSpotInstanceRequestId() != null;
+         assertEquals(instance.getMonitoringState(), MonitoringState.ENABLED);
+
+         // generate some load
+         ListenableFuture<ExecResponse> future = client.submitScriptOnNode(first.getId(), Statements
+                  .exec("while true; do true; done"), runAsRoot(false).nameTask("cpuSpinner"));
+
+         // monitoring granularity for free tier is 5 minutes, so lets make sure we have data.
+         Thread.sleep(TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES));
+
+         // stop the spinner
+         future.cancel(true);
+
+         CloudWatchApi monitoringApi = ContextBuilder.newBuilder(new AWSCloudWatchProviderMetadata())
+                                                     .credentials(identity, credential)
+                                                     .modules(setupModules())
+                                                     .buildApi(CloudWatchApi.class);
+
+         try {
+            GetMetricStatisticsResponse datapoints = monitoringApi.getMetricApiForRegion(instance.getRegion())
+                     .getMetricStatistics(GetMetricStatistics.builder()
+                                                             .dimension(new Dimension(EC2Constants.Dimension.INSTANCE_ID, instance.getId()))
+                                                             .unit(Unit.PERCENT)
+                                                             .namespace("AWS/EC2")
+                                                             .metricName("CPUUtilization")
+                                                             .startTime(before)
+                                                             .endTime(new Date())
+                                                             .period(60)
+                                                             .statistic(Statistics.AVERAGE)
+                                                             .build());
+            assert datapoints.size() > 0 : instance;
+         } finally {
+            monitoringApi.close();
+         }
+
+         // make sure we made our dummy group and also let in the user's group
+         assertEquals(newTreeSet(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group, group));
+
+         // make sure our dummy group has no rules
+         SecurityGroup secgroup = getOnlyElement(securityGroupApi.describeSecurityGroupsInRegion(instance
+                  .getRegion(), "jclouds#" + group));
+
+         assert secgroup.size() == 0 : secgroup;
+
+         // try to run a script with the original keyPair
+         runScriptWithCreds(group, first.getOperatingSystem(), LoginCredentials.builder().user(
+                  first.getCredentials().identity).privateKey(result.getKeyMaterial()).build());
+
+      } finally {
+         client.destroyNodesMatching(NodePredicates.inGroup(group));
+         if (startedId != null) {
+            // ensure we didn't delete these resources!
+            assertEquals(keyPairApi.describeKeyPairsInRegion(region, group).size(), 1);
+            assertEquals(securityGroupApi.describeSecurityGroupsInRegion(region, group).size(), 1);
+         }
+         cleanupExtendedStuffInRegion(region, securityGroupApi, keyPairApi, group);
+      }
+   }
+}


[06/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java
new file mode 100644
index 0000000..11e1526
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java
@@ -0,0 +1,418 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.options;
+
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.authorizePublicKey;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.blockOnPort;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.enableMonitoring;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.iamInstanceProfileArn;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.iamInstanceProfileName;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.inboundPorts;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.installPrivateKey;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.keyPair;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.noKeyPair;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroupIds;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroups;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.compute.options.TemplateOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests possible uses of AWSEC2TemplateOptions and
+ * AWSEC2TemplateOptions.Builder.*
+ * 
+ * @author Adrian Cole
+ */
+public class AWSEC2TemplateOptionsTest {
+
+   public void testAs() {
+      TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.as(AWSEC2TemplateOptions.class), options);
+   }
+
+   @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+   public void testsecurityGroupIdsIterableBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds(ImmutableSet.of("groupId1", ""));
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testsecurityGroupIdsIterableEmptyNotOk() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds(ImmutableSet.<String> of());
+   }
+
+   @Test
+   public void testsecurityGroupIdsIterable() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds(ImmutableSet.of("groupId1", "groupId2"));
+      assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
+
+   }
+
+   @Test
+   public void testsecurityGroupIdsIterableStatic() {
+      AWSEC2TemplateOptions options = securityGroupIds(ImmutableSet.of("groupId1", "groupId2"));
+      assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+   public void testsecurityGroupIdsVarArgsBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds("mygroupId", "");
+   }
+
+   @Test
+   public void testsecurityGroupIdsVarArgs() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds("groupId1", "groupId2");
+      assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testsecurityGroupIdsVarArgsEmptyNotOk() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroupIds();
+   }
+
+   @Test
+   public void testDefaultGroupIdsVarArgsEmpty() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getGroupIds(), ImmutableSet.of());
+   }
+
+   @Test
+   public void testsecurityGroupIdsVarArgsStatic() {
+      AWSEC2TemplateOptions options = securityGroupIds("groupId1", "groupId2");
+      assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+   public void testsecurityGroupsIterableBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups(ImmutableSet.of("group1", ""));
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testsecurityGroupsIterableEmptyNotOk() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups(ImmutableSet.<String> of());
+   }
+
+   @Test
+   public void testsecurityGroupsIterable() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups(ImmutableSet.of("group1", "group2"));
+      assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
+
+   }
+
+   @Test
+   public void testsecurityGroupsIterableStatic() {
+      AWSEC2TemplateOptions options = securityGroups(ImmutableSet.of("group1", "group2"));
+      assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+   public void testsecurityGroupsVarArgsBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups("mygroup", "");
+   }
+
+   @Test
+   public void testsecurityGroupsVarArgs() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups("group1", "group2");
+      assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testsecurityGroupsVarArgsEmptyNotOk() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.securityGroups();
+   }
+
+   @Test
+   public void testDefaultGroupsVarArgsEmpty() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getGroups(), ImmutableSet.of());
+   }
+
+   @Test
+   public void testsecurityGroupsVarArgsStatic() {
+      AWSEC2TemplateOptions options = securityGroups("group1", "group2");
+      assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "use noKeyPair option to request boot without a keypair")
+   public void testkeyPairBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.keyPair("");
+   }
+
+   @Test(expectedExceptions = IllegalStateException.class)
+   public void testkeyPairAndNoKeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.keyPair("mykeypair");
+      options.noKeyPair();
+   }
+
+   @Test(expectedExceptions = IllegalStateException.class)
+   public void testNoKeyPairAndKeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.noKeyPair();
+      options.keyPair("mykeypair");
+   }
+
+   @Test
+   public void testkeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.keyPair("mykeypair");
+      assertEquals(options.getKeyPair(), "mykeypair");
+   }
+
+   @Test
+   public void testNullkeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getKeyPair(), null);
+   }
+
+   @Test
+   public void testkeyPairStatic() {
+      AWSEC2TemplateOptions options = keyPair("mykeypair");
+      assertEquals(options.getKeyPair(), "mykeypair");
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testkeyPairNPE() {
+      keyPair(null);
+   }
+
+   @Test
+   public void testnoKeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.noKeyPair();
+      assertEquals(options.getKeyPair(), null);
+      assert !options.shouldAutomaticallyCreateKeyPair();
+   }
+
+   @Test
+   public void testFalsenoKeyPair() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getKeyPair(), null);
+      assert options.shouldAutomaticallyCreateKeyPair();
+   }
+
+   @Test
+   public void testnoKeyPairStatic() {
+      AWSEC2TemplateOptions options = noKeyPair();
+      assertEquals(options.getKeyPair(), null);
+      assert !options.shouldAutomaticallyCreateKeyPair();
+   }
+
+   @Test
+   public void testMonitoringEnabledDefault() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assert !options.isMonitoringEnabled();
+   }
+
+   @Test
+   public void testMonitoringEnabled() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.enableMonitoring();
+      assert options.isMonitoringEnabled();
+   }
+
+   @Test
+   public void testEnableMonitoringStatic() {
+      AWSEC2TemplateOptions options = enableMonitoring();
+      assertEquals(options.getKeyPair(), null);
+      assert options.isMonitoringEnabled();
+   }
+
+   // superclass tests
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testinstallPrivateKeyBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.installPrivateKey("whompy");
+   }
+
+   @Test
+   public void testinstallPrivateKey() throws IOException {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
+      assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
+   }
+
+   @Test
+   public void testNullinstallPrivateKey() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getPrivateKey(), null);
+   }
+
+   @Test
+   public void testinstallPrivateKeyStatic() throws IOException {
+      AWSEC2TemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
+      assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testinstallPrivateKeyNPE() {
+      installPrivateKey(null);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testauthorizePublicKeyBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.authorizePublicKey("whompy");
+   }
+
+   @Test
+   public void testauthorizePublicKey() throws IOException {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.authorizePublicKey("ssh-rsa");
+      assertEquals(options.getPublicKey(), "ssh-rsa");
+   }
+
+   @Test
+   public void testNullauthorizePublicKey() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getPublicKey(), null);
+   }
+
+   @Test
+   public void testauthorizePublicKeyStatic() throws IOException {
+      AWSEC2TemplateOptions options = authorizePublicKey("ssh-rsa");
+      assertEquals(options.getPublicKey(), "ssh-rsa");
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testauthorizePublicKeyNPE() {
+      authorizePublicKey(null);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testblockOnPortBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.blockOnPort(-1, -1);
+   }
+
+   @Test
+   public void testblockOnPort() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.blockOnPort(22, 30);
+      assertEquals(options.getPort(), 22);
+      assertEquals(options.getSeconds(), 30);
+
+   }
+
+   @Test
+   public void testNullblockOnPort() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getPort(), -1);
+      assertEquals(options.getSeconds(), -1);
+   }
+
+   @Test
+   public void testblockOnPortStatic() {
+      AWSEC2TemplateOptions options = blockOnPort(22, 30);
+      assertEquals(options.getPort(), 22);
+      assertEquals(options.getSeconds(), 30);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testinboundPortsBadFormat() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.inboundPorts(-1, -1);
+   }
+
+   @Test
+   public void testinboundPorts() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.inboundPorts(22, 30);
+      assertEquals(options.getInboundPorts()[0], 22);
+      assertEquals(options.getInboundPorts()[1], 30);
+
+   }
+
+   @Test
+   public void testDefaultOpen22() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getInboundPorts()[0], 22);
+   }
+
+   @Test
+   public void testinboundPortsStatic() {
+      AWSEC2TemplateOptions options = inboundPorts(22, 30);
+      assertEquals(options.getInboundPorts()[0], 22);
+      assertEquals(options.getInboundPorts()[1], 30);
+   }
+
+   @Test
+   public void testIAMInstanceProfileArn() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+      assertEquals(options.getIAMInstanceProfileArn(), "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+   }
+
+   @Test
+   public void testNullIAMInstanceProfileArn() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getIAMInstanceProfileArn(), null);
+   }
+
+   @Test
+   public void testIAMInstanceProfileArnStatic() {
+      AWSEC2TemplateOptions options = iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+      assertEquals(options.getIAMInstanceProfileArn(), "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testIAMInstanceProfileArnNPE() {
+      iamInstanceProfileArn(null);
+   }
+
+   @Test
+   public void testIAMInstanceProfileName() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      options.iamInstanceProfileName("Webserver");
+      assertEquals(options.getIAMInstanceProfileName(), "Webserver");
+   }
+
+   @Test
+   public void testNullIAMInstanceProfileName() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      assertEquals(options.getIAMInstanceProfileName(), null);
+   }
+
+   @Test
+   public void testIAMInstanceProfileNameStatic() {
+      AWSEC2TemplateOptions options = iamInstanceProfileName("Webserver");
+      assertEquals(options.getIAMInstanceProfileName(), "Webserver");
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testIAMInstanceProfileNameNPE() {
+      iamInstanceProfileName(null);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java
new file mode 100644
index 0000000..433fd7f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.config.BaseComputeServiceContextModule;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule;
+import org.jclouds.ec2.compute.functions.EC2ImageParser;
+import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
+import org.jclouds.ec2.domain.Image;
+import org.jclouds.ec2.xml.DescribeImagesResponseHandlerTest;
+import org.jclouds.json.Json;
+import org.jclouds.json.config.GsonModule;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.inject.Guice;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "AWSEC2ImageParserTest")
+public class AWSEC2ImageParserTest {
+   public void testParseAlesticCanonicalImage() {
+
+      Set<org.jclouds.compute.domain.Image> result = convertImages("/alestic_canonical.xml");
+
+      assertEquals(
+            Iterables.get(result, 0),
+            new ImageBuilder()
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04")
+                              .description("ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml")
+                              .is64Bit(false).build())
+                  .description("ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml")
+                  .defaultCredentials(LoginCredentials.builder().user("ubuntu").build()).id("us-east-1/ami-7e28ca17")
+                  .providerId("ami-7e28ca17").location(defaultLocation).version("20091130")
+                  .userMetadata(ImmutableMap.of(
+                     "owner", "099720109477",
+                     "rootDeviceType", "instance-store",
+                     "virtualizationType", "paravirtual",
+                     "hypervisor", "xen"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE)
+                  .backendStatus("available")
+                  .build());
+      assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+      assertEquals(
+            Iterables.get(result, 4),
+            new ImageBuilder()
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04")
+                              .description("alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml").is64Bit(false)
+                              .build()).description("alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml")
+                  .defaultCredentials(LoginCredentials.builder().user("ubuntu").build()).id("us-east-1/ami-c0fa1ea9")
+                  .providerId("ami-c0fa1ea9").location(defaultLocation).version("20080905")
+                  .userMetadata(ImmutableMap.of("owner", "063491364108", "rootDeviceType", "instance-store"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build());
+      assertEquals(Iterables.get(result, 4).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+      assertEquals(
+            Iterables.get(result, 6),
+            new ImageBuilder()
+                  .name("ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.UBUNTU).arch("paravirtual").version("10.04")
+                              .description("099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
+                              .is64Bit(false).build())
+                  .description("099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
+                  .defaultCredentials(LoginCredentials.builder().user("ubuntu").build()).id("us-east-1/ami-10f3a255")
+                  .providerId("ami-10f3a255").location(defaultLocation).version("20100827")
+                  .userMetadata(ImmutableMap.of(
+                     "owner", "099720109477",
+                     "rootDeviceType", "ebs",
+                     "virtualizationType", "paravirtual",
+                     "hypervisor", "xen"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build());
+      assertEquals(Iterables.get(result, 6).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+   }
+
+   public void testParseVostokImage() {
+
+      Set<org.jclouds.compute.domain.Image> result = convertImages("/vostok.xml");
+
+      assertEquals(
+            Iterables.get(result, 0),
+            new ImageBuilder()
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("")
+                              .description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml")
+                              .is64Bit(false).build())
+                  .description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml")
+                  .defaultCredentials(LoginCredentials.builder().user("root").build()).id("us-east-1/ami-870de2ee")
+                  .providerId("ami-870de2ee").location(defaultLocation).version("5622")
+                  .userMetadata(ImmutableMap.of("owner", "133804938231", "rootDeviceType", "instance-store"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build());
+
+   }
+
+   public void testParseCCImage() {
+
+      Set<org.jclouds.compute.domain.Image> result = convertImages("/describe_images_cc.xml");
+
+      assertEquals(
+            Iterables.get(result, 0),
+            new ImageBuilder()
+                  .name("EC2 CentOS 5.4 HVM AMI")
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.CENTOS).arch("hvm").version("5.4")
+                              .description("amazon/EC2 CentOS 5.4 HVM AMI").is64Bit(true).build())
+                  .description("EC2 CentOS 5.4 HVM AMI")
+                  .defaultCredentials(LoginCredentials.builder().user("root").build()).id("us-east-1/ami-7ea24a17")
+                  .providerId("ami-7ea24a17").location(defaultLocation)
+                  .userMetadata(ImmutableMap.of(
+                     "owner", "206029621532",
+                     "rootDeviceType", "ebs",
+                     "virtualizationType", "hvm",
+                     "hypervisor", "xen"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build());
+      assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+   }
+
+   public void testParseRightScaleImage() {
+
+      Set<org.jclouds.compute.domain.Image> result = convertImages("/rightscale_images.xml");
+
+      assertEquals(
+            Iterables.get(result, 0),
+            new ImageBuilder()
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.CENTOS).arch("paravirtual").version("5.4")
+                              .description("rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml").is64Bit(true)
+                              .build()).description("rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml")
+                  .defaultCredentials(LoginCredentials.builder().user("root").build()).id("us-east-1/ami-ccb35ea5")
+                  .providerId("ami-ccb35ea5").location(defaultLocation).version("4.4.10")
+                  .userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build());
+      assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+      assertEquals(
+            new Gson().toJson(Iterables.get(result, 1)),
+            "{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"authenticateSudo\":false,\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-c19db6b5\",\"name\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"paravirtual\",\"hypervisor\":\"xen\"}}");
+
+      assertEquals(
+            new Gson().toJson(Iterables.get(result, 2)),
+            "{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"authenticateSudo\":false,\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-710c2605\",\"name\":\"RightImage Windows_2003_i386_v5.4.3\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"hvm\",\"hypervisor\":\"xen\"}}");
+   }
+
+   public void testParseAmznImage() {
+
+      Set<org.jclouds.compute.domain.Image> result = convertImages("/amzn_images.xml");
+
+      assertEquals(
+            Iterables.get(result, 0),
+            new ImageBuilder()
+                  .name("amzn-ami-0.9.7-beta.i386-ebs")
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.AMZN_LINUX).arch("paravirtual")
+                              .version("0.9.7-beta").description("137112412989/amzn-ami-0.9.7-beta.i386-ebs")
+                              .is64Bit(false).build()).description("Amazon")
+                  .defaultCredentials(LoginCredentials.builder().user("ec2-user").build()).id("us-east-1/ami-82e4b5c7")
+                  .providerId("ami-82e4b5c7").location(defaultLocation).version("0.9.7-beta")
+                  .userMetadata(ImmutableMap.of(
+                     "owner", "137112412989",
+                     "rootDeviceType", "ebs",
+                     "virtualizationType", "paravirtual",
+                     "hypervisor", "xen"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build());
+      assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+      assertEquals(
+            Iterables.get(result, 3),
+            new ImageBuilder()
+                  .name("amzn-ami-0.9.7-beta.x86_64-S3")
+                  .operatingSystem(
+                        new OperatingSystem.Builder().family(OsFamily.AMZN_LINUX).arch("paravirtual")
+                              .version("0.9.7-beta")
+                              .description("amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml").is64Bit(true)
+                              .build()).description("Amazon Linux AMI x86_64 S3")
+                  .defaultCredentials(LoginCredentials.builder().user("ec2-user").build()).id("us-east-1/ami-f2e4b5b7")
+                  .providerId("ami-f2e4b5b7").location(defaultLocation).version("0.9.7-beta")
+                  .userMetadata(ImmutableMap.of(
+                     "owner", "137112412989",
+                     "rootDeviceType", "ebs",
+                     "virtualizationType", "paravirtual",
+                     "hypervisor", "xen"))
+                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build());
+      assertEquals(Iterables.get(result, 3).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
+
+   }
+
+   static Location defaultLocation = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1")
+         .description("us-east-1").build();
+
+   public static Set<org.jclouds.compute.domain.Image> convertImages(String resource) {
+
+      Map<OsFamily, Map<String, String>> map = new BaseComputeServiceContextModule() {
+      }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
+            .getInstance(Json.class));
+
+      Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
+      EC2ImageParser parser = new EC2ImageParser(EC2ComputeServiceDependenciesModule.toPortableImageStatus,
+               new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map, Suppliers
+                        .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
+                        .ofInstance(defaultLocation), new AWSEC2ReviseParsedImage(map));
+      return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java
new file mode 100644
index 0000000..e63a9b4
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.jclouds.compute.config.BaseComputeServiceContextModule;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.Image;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.domain.VirtualizationType;
+import org.jclouds.json.Json;
+import org.jclouds.json.config.GsonModule;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+
+public class AWSEC2ReviseParsedImageTest {
+    private Map<OsFamily, Map<String, String>> osVersionMap;
+
+    @BeforeClass
+    public void testFixtureSetUp() {
+        osVersionMap = new BaseComputeServiceContextModule() {
+        }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
+                .getInstance(Json.class));
+    }
+
+    @Test
+    public void testNewWindowsName() throws Exception {
+
+        ReviseParsedImage rpi = new AWSEC2ReviseParsedImage(osVersionMap);
+
+        Image from = newImage("amazon", "Windows_Server-2008-R2_SP1-English-64Bit-Base-2012.03.13");
+        OperatingSystem.Builder osBuilder = OperatingSystem.builder().description("test");
+      ImageBuilder builder = new ImageBuilder().id("1").operatingSystem(osBuilder.build()).status(
+               org.jclouds.compute.domain.Image.Status.AVAILABLE).description("test");
+        OsFamily family = OsFamily.WINDOWS;
+
+        rpi.reviseParsedImage(from, builder, family, osBuilder);
+        OperatingSystem os = osBuilder.build();
+        assertEquals(os.getFamily(), OsFamily.WINDOWS);
+        assertEquals(os.getVersion(), "2008");
+        assertEquals(builder.build().getVersion(), "2012.03.13");
+    }
+
+    @Test
+    public void testOldWindowsName() throws Exception {
+
+        ReviseParsedImage rpi = new AWSEC2ReviseParsedImage(osVersionMap);
+
+        Image from = newImage("amazon", "Windows-2008R2-SP1-English-Base-2012.01.12");
+        OperatingSystem.Builder osBuilder = OperatingSystem.builder().description("test");
+        ImageBuilder builder = new ImageBuilder().id("1").operatingSystem(osBuilder.build()).status(
+                 org.jclouds.compute.domain.Image.Status.AVAILABLE).description("test");
+        OsFamily family = OsFamily.WINDOWS;
+
+        rpi.reviseParsedImage(from, builder, family, osBuilder);
+        OperatingSystem os = osBuilder.build();
+        assertEquals(os.getFamily(), OsFamily.WINDOWS);
+        assertEquals(os.getVersion(), "2008");
+        assertEquals(builder.build().getVersion(), "2012.01.12");
+    }
+
+    private static Image newImage(String imageOwnerId, String imageName) {
+        String region = "us-east-1";
+        Image.Architecture architecture = Image.Architecture.X86_64;
+        String description = "";
+        String imageId = "";
+        Image.ImageState imageState = Image.ImageState.AVAILABLE;
+        Image.ImageType imageType = Image.ImageType.MACHINE;
+        boolean isPublic = true;
+        Iterable<String> productCodes = ImmutableSet.of();
+        String kernelId = "";
+        String platform = "";
+        String ramdiskId = "";
+        RootDeviceType rootDeviceType = RootDeviceType.EBS;
+        String rootDeviceName = "";
+        Map<String, Image.EbsBlockDevice> ebsBlockDevices = ImmutableMap.of();
+        Map<String, String> tags = ImmutableMap.of();
+        VirtualizationType virtualizationType = VirtualizationType.HVM;
+        Hypervisor hypervisor = Hypervisor.XEN;
+      Image from = new Image(region, architecture, imageName, description, imageId, imageOwnerId + "/" + imageName,
+            imageOwnerId, imageState, "available", imageType, isPublic, productCodes, kernelId, platform, ramdiskId,
+            rootDeviceType, rootDeviceName, ebsBlockDevices, tags, virtualizationType, hypervisor);
+        return from;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java
new file mode 100644
index 0000000..1cc6fcf
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java
@@ -0,0 +1,957 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.keyPair;
+import static org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.CREDENTIALS;
+import static org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.KEYPAIR;
+import static org.testng.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.inject.Provider;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial;
+import org.jclouds.aws.ec2.functions.CreatePlacementGroupIfNeeded;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.EC2TemplateBuilderTest;
+import org.jclouds.ec2.compute.domain.EC2HardwareBuilder;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
+import org.jclouds.ec2.compute.options.EC2TemplateOptions;
+import org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions;
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.scriptbuilder.domain.Statements;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", singleThreaded = true, testName = "CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest")
+public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
+   private static final Provider<RunInstancesOptions> OPTIONS_PROVIDER = new javax.inject.Provider<RunInstancesOptions>() {
+
+      @Override
+      public RunInstancesOptions get() {
+         return new AWSRunInstancesOptions();
+      }
+
+   };
+
+   @Test(enabled = false)
+   public void testExecuteWithDefaultOptionsEC2() throws SecurityException, NoSuchMethodException {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      Hardware size = EC2HardwareBuilder.m1_small().build();
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+      String generatedGroup = "group";
+      Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
+            CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
+            new Method[] {
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class
+                        .getDeclaredMethod("getOptionsProvider"),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
+
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      Template template = createMock(Template.class);
+
+      // setup expectations
+      expect(strategy.getOptionsProvider()).andReturn(OPTIONS_PROVIDER);
+      expect(template.getHardware()).andReturn(size).atLeastOnce();
+      expect(template.getOptions()).andReturn(options).atLeastOnce();
+      expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
+      expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            systemGeneratedKeyPairName);
+      expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getSubnetId()).andReturn(null);
+      expect(options.getUserData()).andReturn(null);
+      expect(options.isMonitoringEnabled()).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(template);
+      replay(strategy);
+
+      // run
+      RunInstancesOptions customize = strategy.execute(region, group, template);
+      assertEquals(customize.buildQueryParameters(), ImmutableMultimap.<String, String> of());
+      assertEquals(
+            customize.buildFormParameters().entries(),
+            ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+                  generatedGroup, "KeyName", systemGeneratedKeyPairName).entries());
+      assertEquals(customize.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
+      assertEquals(customize.buildStringPayload(), null);
+
+      // verify mocks
+      verify(options);
+      verify(template);
+      verify(strategy);
+   }
+
+   @Test(enabled = false)
+   public void testExecuteForCCAutomatic() throws SecurityException, NoSuchMethodException {
+      // setup constants
+      String region = Region.US_EAST_1;
+      String group = "group";
+      Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE;
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+      String generatedGroup = "group";
+      Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
+            CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
+            new Method[] {
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class
+                        .getDeclaredMethod("getOptionsProvider"),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
+
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      Template template = createMock(Template.class);
+
+      // setup expectations
+      expect(strategy.getOptionsProvider()).andReturn(OPTIONS_PROVIDER);
+      expect(template.getHardware()).andReturn(size).atLeastOnce();
+      expect(template.getOptions()).andReturn(options).atLeastOnce();
+      expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
+      expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            systemGeneratedKeyPairName);
+      expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            generatedGroup);
+      expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getSubnetId()).andReturn(null);
+      expect(options.getUserData()).andReturn(null);
+      expect(options.isMonitoringEnabled()).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(template);
+      replay(strategy);
+
+      // run
+      RunInstancesOptions customize = strategy.execute(region, group, template);
+      assertEquals(customize.buildQueryParameters(), ImmutableMultimap.<String, String> of());
+      assertEquals(
+            customize.buildFormParameters().entries(),
+            ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+                  generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup)
+                  .entries());
+      assertEquals(customize.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
+      assertEquals(customize.buildStringPayload(), null);
+
+      // verify mocks
+      verify(options);
+      verify(template);
+      verify(strategy);
+   }
+
+   @Test(enabled = false)
+   public void testExecuteForCCUserSpecified() throws SecurityException, NoSuchMethodException {
+      // setup constants
+      String region = Region.US_EAST_1;
+      String group = "group";
+      Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE;
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+      String generatedGroup = "group";
+      Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
+            CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
+            new Method[] {
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class
+                        .getDeclaredMethod("getOptionsProvider"),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
+
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      Template template = createMock(Template.class);
+
+      // setup expectations
+      expect(strategy.getOptionsProvider()).andReturn(OPTIONS_PROVIDER);
+      expect(template.getHardware()).andReturn(size).atLeastOnce();
+      expect(template.getOptions()).andReturn(options).atLeastOnce();
+      expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
+      expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            systemGeneratedKeyPairName);
+      expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            generatedGroup);
+      expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getSubnetId()).andReturn(null);
+      expect(options.getUserData()).andReturn(null);
+      expect(options.isMonitoringEnabled()).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(template);
+      replay(strategy);
+
+      // run
+      RunInstancesOptions customize = strategy.execute(region, group, template);
+      assertEquals(customize.buildQueryParameters(), ImmutableMultimap.<String, String> of());
+      assertEquals(
+            customize.buildFormParameters().entries(),
+            ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+                  generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup)
+                  .entries());
+      assertEquals(customize.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
+      assertEquals(customize.buildStringPayload(), null);
+
+      // verify mocks
+      verify(options);
+      verify(template);
+      verify(strategy);
+   }
+
+   @Test(enabled = false)
+   public void testExecuteWithSubnet() throws SecurityException, NoSuchMethodException {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      Hardware size = EC2HardwareBuilder.m1_small().build();
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
+            CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
+            new Method[] {
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class
+                        .getDeclaredMethod("getOptionsProvider"),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
+
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      Template template = createMock(Template.class);
+
+      // setup expectations
+      expect(strategy.getOptionsProvider()).andReturn(OPTIONS_PROVIDER);
+      expect(template.getHardware()).andReturn(size).atLeastOnce();
+      expect(template.getOptions()).andReturn(options).atLeastOnce();
+      expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
+      expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            systemGeneratedKeyPairName);
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getSubnetId()).andReturn("1");
+      expect(options.getUserData()).andReturn(null);
+      expect(options.isMonitoringEnabled()).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(template);
+      replay(strategy);
+
+      // run
+      RunInstancesOptions customize = strategy.execute(region, group, template);
+      assertEquals(customize.buildQueryParameters(), ImmutableMultimap.<String, String> of());
+      assertEquals(
+            customize.buildFormParameters().entries(),
+            ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "SubnetId", "1", "KeyName",
+                  systemGeneratedKeyPairName).entries());
+      assertEquals(customize.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
+      assertEquals(customize.buildStringPayload(), null);
+
+      // verify mocks
+      verify(options);
+      verify(template);
+      verify(strategy);
+   }
+
+   @Test(enabled = false)
+   public void testExecuteWithUserData() throws SecurityException, NoSuchMethodException {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      Hardware size = EC2HardwareBuilder.m1_small().build();
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+      String generatedGroup = "group";
+      Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
+            CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
+            new Method[] {
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class
+                        .getDeclaredMethod("getOptionsProvider"),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
+                        TemplateOptions.class),
+                  CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
+                        "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
+
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      Template template = createMock(Template.class);
+
+      // setup expectations
+      expect(strategy.getOptionsProvider()).andReturn(OPTIONS_PROVIDER);
+      expect(template.getHardware()).andReturn(size).atLeastOnce();
+      expect(template.getOptions()).andReturn(options).atLeastOnce();
+      expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
+      expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
+            systemGeneratedKeyPairName);
+      expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getSubnetId()).andReturn(null);
+      expect(options.getUserData()).andReturn("hello".getBytes());
+      expect(options.isMonitoringEnabled()).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(template);
+      replay(strategy);
+
+      // run
+      RunInstancesOptions customize = strategy.execute(region, group, template);
+      assertEquals(customize.buildQueryParameters(), ImmutableMultimap.<String, String> of());
+      assertEquals(
+            customize.buildFormParameters().entries(),
+            ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "SecurityGroup.1", "group",
+                  "KeyName", systemGeneratedKeyPairName, "UserData", base64().encode("hello".getBytes(UTF_8))).entries());
+      assertEquals(customize.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
+      assertEquals(customize.buildStringPayload(), null);
+
+      // verify mocks
+      verify(options);
+      verify(template);
+      verify(strategy);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_reusesKeyWhenToldToWithRunScriptButNoCredentials() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedKeyPair = "myKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // setup expectations
+      expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
+      expect(options.getPublicKey()).andReturn(null).times(2);
+      expect(options.getLoginPrivateKey()).andReturn(null);
+      expect(options.getRunScript()).andReturn(Statements.exec("echo foo"));
+      expect(strategy.credentialsMap.containsKey(new RegionAndName(region, userSuppliedKeyPair))).andReturn(false);
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), userSuppliedKeyPair);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_reusesKeyWhenToldToWithRunScriptAndCredentialsAlreadyInMap() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedKeyPair = "myKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // setup expectations
+      expect(options.getPublicKey()).andReturn(null).times(2);
+      expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
+      expect(options.getLoginPrivateKey()).andReturn(null);
+      expect(options.getRunScript()).andReturn(Statements.exec("echo foo"));
+      expect(strategy.credentialsMap.containsKey(new RegionAndName(region, userSuppliedKeyPair))).andReturn(true);
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), userSuppliedKeyPair);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_ImportPublicKeyWhenOptionIsSet() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedKeyPair = "myKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // we specify we have a public key we want to use for authentication
+      expect(options.getPublicKey()).andReturn("ssh-rsa").times(2);
+      expect(options.getLoginPrivateKey()).andReturn(CREDENTIALS.getPrivateKey()).atLeastOnce();
+
+      // Here, we import the keypair and place it into the cache
+      expect(strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group, "ssh-rsa")))
+            .andReturn(KEYPAIR);
+      expect(options.dontAuthorizePublicKey()).andReturn(options);
+      expect(strategy.credentialsMap.put(new RegionAndName(region, group), KEYPAIR)).andReturn(null);
+      expect(options.getRunScript()).andReturn(Statements.exec("echo foo"));
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), userSuppliedKeyPair);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   @Test
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_importsKeyPairAndUnsetsTemplateInstructionWhenPublicKeySuppliedAndAddsCredentialToMapWhenOverridingCredsAreSet() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = keyPair(group).authorizePublicKey("ssh-rsa").overrideLoginCredentials(
+            LoginCredentials.builder().user("foo").privateKey(CREDENTIALS.credential).build());
+      KeyPair keyPair = new KeyPair(region, group, "//TODO", null, null);
+
+      // setup expectations
+      expect(
+            strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group,
+                  CREDENTIALS.credential))).andReturn(keyPair);
+      expect(
+            strategy.credentialsMap.put(new RegionAndName(region, group),
+                  keyPair.toBuilder().keyMaterial(CREDENTIALS.credential).build())).andReturn(null);
+
+      // replay mocks
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), group);
+
+      // verify mocks
+      verifyStrategy(strategy);
+   }
+
+   @Test
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_importsKeyPairAndUnsetsTemplateInstructionWhenPublicKeySupplied() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      AWSEC2TemplateOptions options = keyPair(group).authorizePublicKey("ssh-rsa");
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+
+      KeyPair keyPair = new KeyPair(region, "jclouds#" + group, "fingerprint", null, null);
+
+      // setup expectations
+      expect(strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group, "ssh-rsa")))
+            .andReturn(keyPair);
+      expect(strategy.credentialsMap.put(new RegionAndName(region, group), keyPair)).andReturn(null);
+
+      // replay mocks
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), "jclouds#" + group);
+
+      // verify mocks
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_createsNewKeyPairAndReturnsItsNameWhenNoPublicKeySupplied() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedKeyPair = null;
+      boolean shouldAutomaticallyCreateKeyPair = true;
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // setup expectations
+      expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
+      expect(options.shouldAutomaticallyCreateKeyPair()).andReturn(shouldAutomaticallyCreateKeyPair);
+      expect(strategy.credentialsMap.containsKey(new RegionAndName(region, group))).andReturn(true);
+      expect(strategy.credentialsMap.get(new RegionAndName(region, group))).andReturn(keyPair);
+      expect(options.getPublicKey()).andReturn(null).times(2);
+      expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
+      expect(options.getRunScript()).andReturn(null);
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options),
+            systemGeneratedKeyPairName);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_returnsExistingKeyIfAlreadyPresent() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // setup expectations
+      expect(options.getLoginPrivateKey()).andReturn(null);
+      expect(options.getRunScript()).andReturn(Statements.exec("echo hello"));
+      expect(options.getPublicKey()).andReturn(null).times(2);
+      expect(options.getKeyPair()).andReturn(systemGeneratedKeyPairName);
+      expect(strategy.credentialsMap.containsKey(new RegionAndName(region, systemGeneratedKeyPairName)))
+            .andReturn(true);
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options),
+            systemGeneratedKeyPairName);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_doesntCreateAKeyPairAndReturnsNullWhenToldNotTo() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedKeyPair = null;
+      boolean shouldAutomaticallyCreateKeyPair = false; // here's the important
+      // part!
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      KeyPair keyPair = createMock(KeyPair.class);
+
+      // setup expectations
+      expect(options.getPublicKey()).andReturn(null).times(2);
+      expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
+      expect(options.getRunScript()).andReturn(null);
+      expect(options.shouldAutomaticallyCreateKeyPair()).andReturn(shouldAutomaticallyCreateKeyPair);
+
+      // replay mocks
+      replay(options);
+      replay(keyPair);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options), null);
+
+      // verify mocks
+      verify(options);
+      verify(keyPair);
+      verifyStrategy(strategy);
+   }
+
+   public void testGetSecurityGroupsForTagAndOptions_createsNewGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesntExist() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String generatedMarkerGroup = "jclouds#group";
+      Set<String> groupNames = ImmutableSet.<String> of();
+      int[] ports = {};
+      boolean shouldAuthorizeSelf = true;
+      Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
+      expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
+      RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
+            ports, shouldAuthorizeSelf);
+      expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules)).andReturn(group);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testGetSecurityGroupsForTagAndOptions_createsNewGroupByDefaultWhenPortsAreSpecifiedWhenDoesntExist() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String generatedMarkerGroup = "jclouds#group";
+      Set<String> groupNames = ImmutableSet.<String> of();
+      int[] ports = { 22, 80 };
+      boolean shouldAuthorizeSelf = true;
+      Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
+      expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
+      RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
+            ports, shouldAuthorizeSelf);
+      expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesExist() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String generatedMarkerGroup = "jclouds#group";
+      Set<String> groupNames = ImmutableSet.<String> of();
+      int[] ports = {};
+      boolean shouldAuthorizeSelf = true;
+      Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
+      expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
+      RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
+            ports, shouldAuthorizeSelf);
+      expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesExistAndAcceptsUserSuppliedGroups() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String generatedMarkerGroup = "jclouds#group";
+      Set<String> groupNames = ImmutableSet.<String> of("group1", "group2");
+      int[] ports = {};
+      boolean shouldAuthorizeSelf = true;
+      boolean groupExisted = true;
+      Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup, "group1", "group2");
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of());
+      expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
+      RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
+            ports, shouldAuthorizeSelf);
+
+      expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules))
+            .andReturn(groupExisted ? "group" : null);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesExistAndAcceptsUserSuppliedGroupIds() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String generatedMarkerGroup = "jclouds#group";
+      Set<String> groupNames = ImmutableSet.<String> of();
+      int[] ports = {};
+      boolean shouldAuthorizeSelf = true;
+      boolean groupExisted = true;
+      Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup);
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getGroupIds()).andReturn(ImmutableSet.<String> of("group1", "group2"));
+      expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
+      RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
+            ports, shouldAuthorizeSelf);
+
+      expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules))
+            .andReturn(groupExisted ? "group" : null);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewPlacementGroupUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedPlacementGroup = "myPlacementGroup";
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      PlacementGroup placementGroup = createMock(PlacementGroup.class);
+
+      // setup expectations
+      expect(options.getPlacementGroup()).andReturn(userSuppliedPlacementGroup);
+
+      // replay mocks
+      replay(options);
+      replay(placementGroup);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options),
+            userSuppliedPlacementGroup);
+
+      // verify mocks
+      verify(options);
+      verify(placementGroup);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewPlacementGroupUnlessUserSpecifiedOtherwise_createsNewPlacementGroupAndReturnsItsNameByDefault() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedPlacementGroup = null;
+      boolean shouldAutomaticallyCreatePlacementGroup = true;
+      String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+
+      // setup expectations
+      expect(options.getPlacementGroup()).andReturn(userSuppliedPlacementGroup);
+      expect(options.shouldAutomaticallyCreatePlacementGroup()).andReturn(shouldAutomaticallyCreatePlacementGroup);
+      expect(strategy.placementGroupMap.getUnchecked(new RegionAndName(region, generatedMarkerGroup))).andReturn(
+            generatedMarkerGroup);
+
+      // replay mocks
+      replay(options);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options),
+            generatedMarkerGroup);
+
+      // verify mocks
+      verify(options);
+      verifyStrategy(strategy);
+   }
+
+   public void testCreateNewPlacementGroupUnlessUserSpecifiedOtherwise_doesntCreateAPlacementGroupAndReturnsNullWhenToldNotTo() {
+      // setup constants
+      String region = Region.AP_SOUTHEAST_1;
+      String group = "group";
+      String userSuppliedPlacementGroup = null;
+      boolean shouldAutomaticallyCreatePlacementGroup = false; // here's the
+                                                               // important
+      // part!
+
+      // create mocks
+      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
+      AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
+      PlacementGroup placementGroup = createMock(PlacementGroup.class);
+
+      // setup expectations
+      expect(options.getPlacementGroup()).andReturn(userSuppliedPlacementGroup);
+      expect(options.shouldAutomaticallyCreatePlacementGroup()).andReturn(shouldAutomaticallyCreatePlacementGroup);
+
+      // replay mocks
+      replay(options);
+      replay(placementGroup);
+      replayStrategy(strategy);
+
+      // run
+      assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options), null);
+
+      // verify mocks
+      verify(options);
+      verify(placementGroup);
+      verifyStrategy(strategy);
+   }
+
+   private void verifyStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) {
+      verify(strategy.makeKeyPair);
+      verify(strategy.credentialsMap);
+      verify(strategy.securityGroupMap);
+      verify(strategy.placementGroupMap);
+      verify(strategy.importExistingKeyPair);
+      verify(strategy.createPlacementGroupIfNeeded);
+   }
+
+   @SuppressWarnings("unchecked")
+   private CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
+      Function<RegionAndName, KeyPair> makeKeyPair = createMock(Function.class);
+      ConcurrentMap<RegionAndName, KeyPair> credentialsMap = createMock(ConcurrentMap.class);
+      LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
+      LoadingCache<RegionAndName, String> placementGroupMap = createMock(LoadingCache.class);
+      Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair = createMock(Function.class);
+      CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
+      GroupNamingConvention.Factory namingConventionFactory = createMock(GroupNamingConvention.Factory.class);
+      GroupNamingConvention namingConvention = createMock(GroupNamingConvention.class);
+      expect(namingConventionFactory.create()).andReturn(namingConvention).anyTimes();
+      expect(namingConvention.sharedNameForGroup("group")).andReturn("jclouds#group").anyTimes();
+      replay(namingConventionFactory);
+      replay(namingConvention);
+
+      return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(makeKeyPair, credentialsMap,
+            securityGroupMap, OPTIONS_PROVIDER, placementGroupMap, createPlacementGroupIfNeeded, importExistingKeyPair,
+            namingConventionFactory);
+   }
+
+   private void replayStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) {
+      replay(strategy.makeKeyPair);
+      replay(strategy.credentialsMap);
+      replay(strategy.securityGroupMap);
+      replay(strategy.placementGroupMap);
+      replay(strategy.importExistingKeyPair);
+      replay(strategy.createPlacementGroupIfNeeded);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java
new file mode 100644
index 0000000..e09c4ac
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.ec2.domain.Image;
+import org.jclouds.ec2.features.AMIApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code AMIApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class AWSAMIApiLiveTest extends AMIApiLiveTest {
+
+   public AWSAMIApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   public void testDescribeImagesCC() {
+      Set<? extends Image> ccResults = client.describeImagesInRegion(Region.US_EAST_1,
+            filters(ImmutableMultimap.<String, String> builder()//
+                  .put("virtualization-type", "hvm")//
+                  .put("architecture", "x86_64")//
+                  .putAll("owner-id", ImmutableSet.<String> of("137112412989", "099720109477"))//
+                  .put("hypervisor", "xen")//
+                  .put("state", "available")//
+                  .put("image-type", "machine")//
+                  .put("root-device-type", "ebs")//
+                  .build()).ownedBy("137112412989", "099720109477"));
+      assertNotNull(ccResults);
+      assert ccResults.size() >= 34 : ccResults;
+   }
+}


[02/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java
new file mode 100644
index 0000000..99b7f2d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.location.Region;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code SpotInstancesHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "SpotInstancesHandlerTest")
+public class SpotInstancesHandlerTest extends BaseEC2HandlerTest {
+
+   private DateService dateService;
+
+   @BeforeTest
+   @Override
+   protected void setUpInjector() {
+      injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            bind(new TypeLiteral<Supplier<String>>(){}).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1"));
+         }
+
+      });
+      factory = injector.getInstance(ParseSax.Factory.class);
+      dateService = injector.getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+   public void testDescribe() {
+
+      InputStream is = getClass().getResourceAsStream("/describe_spot_instance_requests.xml");
+      SpotInstancesHandler handler = injector.getInstance(SpotInstancesHandler.class);
+      addDefaultRegionToHandler(handler);
+      Set<SpotInstanceRequest> result = factory.create(handler).parse(is);
+      assertEquals(result.size(), 18);
+   }
+
+   public void testRequest() {
+      InputStream is = getClass().getResourceAsStream("/request_spot_instances.xml");
+      SpotInstancesHandler handler = injector.getInstance(SpotInstancesHandler.class);
+      addDefaultRegionToHandler(handler);
+      Set<SpotInstanceRequest> result = factory.create(handler).parse(is);
+      assertEquals(result.size(), 3);
+   }
+
+   public void testParseTags() {
+       Set<SpotInstanceRequest> result = factory.create(injector.getInstance(SpotInstancesHandler.class)).parse(
+            getClass().getResourceAsStream("/describe_spot_instance_tags.xml"));
+       Iterable<Map<String, String>> tags = Iterables.transform(result, new Function<SpotInstanceRequest, Map<String, String>>() {
+	       @Override
+	       public Map<String, String> apply(SpotInstanceRequest input) {
+		       return input.getTags();
+	       }
+       });
+
+       assertEquals(
+               Iterables.get(tags, 0),
+               ImmutableMap.of("One", "one", "Two", "one"));
+       assertEquals(
+               Iterables.get(tags, 1),
+               ImmutableMap.of("One", "two", "Two", "two"));
+       assertEquals(
+               Iterables.get(tags, 2),
+               ImmutableMap.of("Two", "three", "Three", "three", "Four", ""));
+   }
+
+   public void testParseNoNPE() {
+      factory.create(injector.getInstance(SpotInstancesHandler.class)).parse(
+            getClass().getResourceAsStream("/describe_spot_instances_1.xml"));
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml
new file mode 100644
index 0000000..ac3fcd8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0"?>
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <requestId>6104eee1-affd-49d7-92a0-516cab8a8ba6</requestId>
+    <imagesSet>
+        <item>
+            <imageId>ami-7e28ca17</imageId>
+            <imageLocation>ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-92ba58fb</kernelId>
+            <ramdiskId>ari-94ba58fd</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-19a34270</imageId>
+            <imageLocation>alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>063491364108</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-a71cf9ce</kernelId>
+            <ramdiskId>ari-a51cf9cc</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-bb709dd2</imageId>
+            <imageLocation>ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-5f15f636</kernelId>
+            <ramdiskId>ari-d5709dbc</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-190fe070</imageId>
+            <imageLocation>ubuntu-images-testing-us/ubuntu-lucid-daily-amd64-desktop-20100317.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-11c72878</kernelId>
+            <name>ubuntu-images-testing/ubuntu-lucid-daily-amd64-desktop-20100317</name>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-c0fa1ea9</imageId>
+            <imageLocation>alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>063491364108</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-a71cf9ce</kernelId>
+            <ramdiskId>ari-a51cf9cc</ramdiskId>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-c597c680</imageId>
+            <imageLocation>ubuntu-images-us-west-1/ubuntu-lucid-10.04-i386-server-20100427.1.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-3197c674</kernelId>
+            <name>ubuntu-images/ubuntu-lucid-10.04-i386-server-20100427.1</name>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping/>        
+        </item>
+        <item>
+            <imageId>aki-fd15f694</imageId>
+            <imageLocation>ubuntu-kernels-us/ubuntu-karmic-amd64-linux-image-2.6.31-302-ec2-v-2.6.31-302.7-kernel.img.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>kernel</imageType>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping />
+        </item>
+        <item>
+            <imageId>ami-10f3a255</imageId>
+            <imageLocation>099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>099720109477</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-a8f0a1ed</kernelId>
+            <name>ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827</name>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-76eff01e</snapshotId>
+                        <volumeSize>15</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>paravirtual</virtualizationType>
+        </item>
+    </imagesSet>
+</DescribeImagesResponse>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml
new file mode 100644
index 0000000..82f97dc
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <requestId>6104eee1-affd-49d7-92a0-516cab8a8ba6</requestId>
+    <imagesSet>
+        <item>
+            <imageId>ami-82e4b5c7</imageId>
+            <imageLocation>137112412989/amzn-ami-0.9.7-beta.i386-ebs</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>137112412989</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-99a0f1dc</kernelId>
+            <name>amzn-ami-0.9.7-beta.i386-ebs</name>
+            <description>Amazon</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-e98b7b82</snapshotId>
+                        <volumeSize>10</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>paravirtual</virtualizationType>
+        </item>
+        <item>
+            <imageId>ami-8ce4b5c9</imageId>
+            <imageLocation>137112412989/amzn-ami-0.9.7-beta.x86_64-ebs</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>137112412989</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-9ba0f1de</kernelId>
+            <name>amzn-ami-0.9.7-beta.x86_64-ebs</name>
+            <description>Amazon</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-8d8b7be6</snapshotId>
+                        <volumeSize>10</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>paravirtual</virtualizationType>
+        </item>
+        <item>
+            <imageId>ami-f0e4b5b5</imageId>
+            <imageLocation>amzn-ami-us-west-1/amzn-ami-0.9.7-beta.i386.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>137112412989</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>i386</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-99a0f1dc</kernelId>
+            <name>amzn-ami-0.9.7-beta.i386-S3</name>
+            <description>Amazon Linux AMI i386 S3</description>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping/>
+            <virtualizationType>paravirtual</virtualizationType>
+        </item>
+        <item>
+            <imageId>ami-f2e4b5b7</imageId>
+            <imageLocation>amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>137112412989</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-9ba0f1de</kernelId>
+            <name>amzn-ami-0.9.7-beta.x86_64-S3</name>
+            <description>Amazon Linux AMI x86_64 S3</description>
+            <rootDeviceType>instance-store</rootDeviceType>
+            <blockDeviceMapping/>
+            <virtualizationType>paravirtual</virtualizationType>
+        </item>
+    </imagesSet>
+</DescribeImagesResponse>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml
new file mode 100644
index 0000000..aa5522f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml
@@ -0,0 +1,9 @@
+<DescribeImageAttributeResponse
+    xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+    <imageId>ami-61a54008</imageId>
+    <productCodes>
+        <item>
+            <productCode>774F4FF8</productCode>
+        </item>
+    </productCodes>
+</DescribeImageAttributeResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml
new file mode 100644
index 0000000..3484748
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
+    <requestId>31e35e56-dd3e-43d3-9c3b-656cb202d6e7</requestId>
+    <imagesSet>
+        <item>
+            <imageId>ami-7ea24a17</imageId>
+            <imageLocation>amazon/EC2 CentOS 5.4 HVM AMI</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>206029621532</imageOwnerId>
+            <isPublic>true</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <imageOwnerAlias>amazon</imageOwnerAlias>
+            <name>EC2 CentOS 5.4 HVM AMI</name>
+            <description>EC2 CentOS 5.4 HVM AMI</description>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-1099e578</snapshotId>
+                        <volumeSize>20</volumeSize>
+                        <deleteOnTermination>true</deleteOnTermination>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>hvm</virtualizationType>
+        </item>
+    </imagesSet>
+</DescribeImagesResponse>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml
new file mode 100644
index 0000000..5d6bf68
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml
@@ -0,0 +1,55 @@
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>b3e1c7ee-1f34-4582-9493-695c9425c679</requestId>
+    <reservationSet>
+        <item>
+            <reservationId>r-51cb663e</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-15f4d17c</groupId>
+                    <groupName>jclouds#ec2-e#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-059c2564</instanceId>
+                    <imageId>ami-eb71b682</imageId>
+                    <instanceState>
+                        <code>0</code>
+                        <name>pending</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason/>
+                    <keyName>jclouds#ec2-e#us-east-1#85</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>m1.small</instanceType>
+                    <launchTime>2011-07-29T08:29:49.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-407d9529</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-15f4d17c</groupId>
+                            <groupName>jclouds#ec2-e#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>i386</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+    </reservationSet>
+</DescribeInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml
new file mode 100644
index 0000000..380a5bf
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml
@@ -0,0 +1,986 @@
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>b2238f71-750f-4eed-8f5c-eb4e6f66b687</requestId>
+    <reservationSet>
+        <item>
+            <reservationId>r-7f54f610</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1df4d174</groupId>
+                    <groupName>jclouds#ec2-#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-8f348aee</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:04:49 GMT)</reason>
+                    <keyName>jclouds#ec2-#us-east-1#95</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T05:35:18.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+                <item>
+                    <instanceId>i-91348af0</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
+                    <keyName>jclouds#ec2-#us-east-1#95</keyName>
+                    <amiLaunchIndex>1</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T05:35:18.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-7be24f14</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-dbf5d0b2</groupId>
+                    <groupName>jclouds#ec2-o#us-east-1</groupName>
+                </item>
+                <item>
+                    <groupId>sg-d9f5d0b0</groupId>
+                    <groupName>ec2-o</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-43b00922</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:03:24 GMT)</reason>
+                    <keyName>ec2-o</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T07:57:49.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>enabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-dbf5d0b2</groupId>
+                            <groupName>jclouds#ec2-o#us-east-1</groupName>
+                        </item>
+                        <item>
+                            <groupId>sg-d9f5d0b0</groupId>
+                            <groupName>ec2-o</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <instanceLifecycle>spot</instanceLifecycle>
+                    <spotInstanceRequestId>sir-cc233214</spotInstanceRequestId>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+            <requesterId>854251627541</requesterId>
+        </item>
+        <item>
+            <reservationId>r-7bfe5314</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-25f4d14c</groupId>
+                    <groupName>jclouds#ec2-r#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-ddb70ebc</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:04:22 GMT)</reason>
+                    <keyName>jclouds#ec2-r#us-east-1#3</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:04:18.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-25f4d14c</groupId>
+                            <groupName>jclouds#ec2-r#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-7bf95414</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1df4d174</groupId>
+                    <groupName>jclouds#ec2-#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-e9a91088</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
+                    <keyName>jclouds#ec2-#us-east-1#73</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:05:48.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+                <item>
+                    <instanceId>i-eba9108a</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
+                    <keyName>jclouds#ec2-#us-east-1#73</keyName>
+                    <amiLaunchIndex>1</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:05:48.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-5df95432</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1ff4d176</groupId>
+                    <groupName>jclouds#ec2-block#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-c9a910a8</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:06:01 GMT)</reason>
+                    <keyName>jclouds#ec2-block#us-east-1#61</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:05:58.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1ff4d176</groupId>
+                            <groupName>jclouds#ec2-block#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-f3f9549c</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-15f4d17c</groupId>
+                    <groupName>jclouds#ec2-e#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-77a81116</instanceId>
+                    <imageId>ami-eb71b682</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:06:19 GMT)</reason>
+                    <keyName>jclouds#ec2-e#us-east-1#6</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>m1.small</instanceType>
+                    <launchTime>2011-07-29T08:06:15.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-407d9529</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-15f4d17c</groupId>
+                            <groupName>jclouds#ec2-e#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>i386</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-2df85542</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-43eacf2a</groupId>
+                    <groupName>jclouds#ec2-s#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-a5a811c4</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:06:59 GMT)</reason>
+                    <keyName>jclouds#ec2-s#us-east-1#40</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:06:55.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-43eacf2a</groupId>
+                            <groupName>jclouds#ec2-s#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-bffb56d0</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-65eacf0c</groupId>
+                    <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-1faa137e</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:10:04 GMT)</reason>
+                    <keyName>jclouds#adriancole-ec2unssh</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:09:14.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-65eacf0c</groupId>
+                            <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <instanceLifecycle>spot</instanceLifecycle>
+                    <spotInstanceRequestId>sir-cf9dd211</spotInstanceRequestId>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+            <requesterId>854251627541</requesterId>
+        </item>
+        <item>
+            <reservationId>r-c3cf62ac</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-dbf5d0b2</groupId>
+                    <groupName>jclouds#ec2-o#us-east-1</groupName>
+                </item>
+                <item>
+                    <groupId>sg-d9f5d0b0</groupId>
+                    <groupName>ec2-o</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-15982174</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+:
+                    <reason>User initiated (2011-07-29 08:27:01 GMT)</reason>
+                    <keyName>ec2-o</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:25:33.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>enabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-dbf5d0b2</groupId>
+                            <groupName>jclouds#ec2-o#us-east-1</groupName>
+                        </item>
+                        <item>
+                            <groupId>sg-d9f5d0b0</groupId>
+                            <groupName>ec2-o</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <instanceLifecycle>spot</instanceLifecycle>
+                    <spotInstanceRequestId>sir-6bba1e14</spotInstanceRequestId>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+            <requesterId>854251627541</requesterId>
+        </item>
+        <item>
+            <reservationId>r-b1c964de</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-25f4d14c</groupId>
+                    <groupName>jclouds#ec2-r#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-b19a23d0</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:28:17 GMT)</reason>
+                    <keyName>jclouds#ec2-r#us-east-1#63</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:28:06.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-25f4d14c</groupId>
+                            <groupName>jclouds#ec2-r#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-87c865e8</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1df4d174</groupId>
+                    <groupName>jclouds#ec2-#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-679c2506</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>16</code>
+                        <name>running</name>
+                    </instanceState>
+                    <privateDnsName>domU-12-31-39-09-F9-1C.compute-1.internal</privateDnsName>
+                    <dnsName>ec2-50-19-39-139.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#ec2-#us-east-1#99</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:29:21.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.210.254.234</privateIpAddress>
+                    <ipAddress>50.19.39.139</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-6d7b6306</volumeId>
+                                <status>attached</status>
+                                <attachTime>2011-07-29T08:29:39.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+                <item>
+                    <instanceId>i-699c2508</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>16</code>
+                        <name>running</name>
+                    </instanceState>
+                    <privateDnsName>domU-12-31-39-09-86-A9.compute-1.internal</privateDnsName>
+                    <dnsName>ec2-184-72-215-58.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#ec2-#us-east-1#99</keyName>
+                    <amiLaunchIndex>1</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:29:21.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.210.137.83</privateIpAddress>
+                    <ipAddress>184.72.215.58</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-617b630a</volumeId>
+                                <status>attached</status>
+                                <attachTime>2011-07-29T08:29:42.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-61cb660e</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1ff4d176</groupId>
+                    <groupName>jclouds#ec2-block#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-539c2532</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:29:36 GMT)</reason>
+                    <keyName>jclouds#ec2-block#us-east-1#48</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:29:32.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1ff4d176</groupId>
+                            <groupName>jclouds#ec2-block#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-51cb663e</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-15f4d17c</groupId>
+                    <groupName>jclouds#ec2-e#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-059c2564</instanceId>
+                    <imageId>ami-eb71b682</imageId>
+                    <instanceState>
+                        <code>0</code>
+                        <name>pending</name>
+                    </instanceState>
+                    <dnsName>ec2-184-72-215-58.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#ec2-#us-east-1#99</keyName>
+                    <amiLaunchIndex>1</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:29:21.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.210.137.83</privateIpAddress>
+                    <ipAddress>184.72.215.58</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1df4d174</groupId>
+                            <groupName>jclouds#ec2-#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-617b630a</volumeId>
+                                <status>attached</status>
+                                <attachTime>2011-07-29T08:29:42.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-61cb660e</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-1ff4d176</groupId>
+                    <groupName>jclouds#ec2-block#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-539c2532</instanceId>
+                    <imageId>ami-8e1fece7</imageId>
+                    <instanceState>
+                        <code>48</code>
+                        <name>terminated</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason>User initiated (2011-07-29 08:29:36 GMT)</reason>
+                    <keyName>jclouds#ec2-block#us-east-1#48</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-07-29T08:29:32.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1b</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-1ff4d176</groupId>
+                            <groupName>jclouds#ec2-block#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <stateReason>
+                        <code>Client.UserInitiatedShutdown</code>
+                        <message>Client.UserInitiatedShutdown: User initiated shutdown</message>
+                    </stateReason>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+        <item>
+            <reservationId>r-51cb663e</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-15f4d17c</groupId>
+                    <groupName>jclouds#ec2-e#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-059c2564</instanceId>
+                    <imageId>ami-eb71b682</imageId>
+                    <instanceState>
+                        <code>0</code>
+                        <name>pending</name>
+                    </instanceState>
+                    <privateDnsName/>
+                    <dnsName/>
+                    <reason/>
+                    <keyName>jclouds#ec2-e#us-east-1#85</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>m1.small</instanceType>
+                    <launchTime>2011-07-29T08:29:49.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-407d9529</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-15f4d17c</groupId>
+                            <groupName>jclouds#ec2-e#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>i386</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping/>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+    </reservationSet>
+</DescribeInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml
new file mode 100644
index 0000000..1e15ce9
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>440faed2-0331-488d-a04d-d8c9aba85307</requestId>
+    <reservationSet/>
+</DescribeInstancesResponse>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml
new file mode 100644
index 0000000..9d606b8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>a03c1896-0543-485f-a732-ebc83873a3ca</requestId>
+    <reservationSet>
+        <item>
+            <reservationId>r-0f4c2160</reservationId>
+            <ownerId>993194456877</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-ef052b86</groupId>
+                    <groupName>jclouds#zkclustertest#us-east-1</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-911444f0</instanceId>
+                    <imageId>ami-63be790a</imageId>
+                    <instanceState>
+                        <code>16</code>
+                        <name>running</name>
+                    </instanceState>
+                    <privateDnsName>ip-10-212-81-7.ec2.internal</privateDnsName>
+                    <dnsName>ec2-174-129-173-155.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#zkclustertest#us-east-1#23</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-08-16T13:40:50.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.212.81.7</privateIpAddress>
+                    <ipAddress>174.129.173.155</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-ef052b86</groupId>
+                            <groupName>jclouds#zkclustertest#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-5829fc32</volumeId>
+                                <status>attached</status>
+                                <attachTime>2011-08-16T13:41:19.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                    <tagSet>
+                       <item>
+                           <key>Name</key>
+                           <value>ec2-o</value>
+                       </item>
+                       <item>
+                           <key>Empty</key>
+                           <value />
+                       </item>
+                    </tagSet>            
+                </item>
+                <item>
+                    <instanceId>i-931444f2</instanceId>
+                    <imageId>ami-63be790a</imageId>
+                    <instanceState>
+                        <code>16</code>
+                        <name>running</name>
+                    </instanceState>
+                    <privateDnsName>ip-10-212-185-8.ec2.internal</privateDnsName>
+                    <dnsName>ec2-50-19-207-248.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#zkclustertest#us-east-1#23</keyName>
+                    <amiLaunchIndex>1</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>t1.micro</instanceType>
+                    <launchTime>2011-08-16T13:40:50.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1c</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-427d952b</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.212.185.8</privateIpAddress>
+                    <ipAddress>50.19.207.248</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-ef052b86</groupId>
+                            <groupName>jclouds#zkclustertest#us-east-1</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-5029fc3a</volumeId>
+                                <status>attached</status>
+                                <attachTime>2011-08-16T13:41:19.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <hypervisor>xen</hypervisor>
+                    <iamInstanceProfile>
+                        <arn>arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver</arn>
+                        <id>AIPAD5ARO2C5EXAMPLE3G</id>
+                    </iamInstanceProfile>
+                </item>
+            </instancesSet>
+        </item>
+    </reservationSet>
+</DescribeInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml
new file mode 100644
index 0000000..0013106
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>dcd37ecf-e5b6-462b-99a8-112427b3e3a2</requestId>
+    <reservationSet>
+        <item>
+            <reservationId>r-3f056a58</reservationId>
+            <ownerId>095072994936</ownerId>
+            <groupSet>
+                <item>
+                    <groupId>sg-f788299f</groupId>
+                    <groupName>launchpad_sec_group</groupName>
+                </item>
+                <item>
+                    <groupId>sg-7e512116</groupId>
+                    <groupName>jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae</groupName>
+                </item>
+            </groupSet>
+            <instancesSet>
+                <item>
+                    <instanceId>i-32451248</instanceId>
+                    <imageId>ami-bf8131d6</imageId>
+                    <instanceState>
+                        <code>0</code>
+                        <name>pending</name>
+                    </instanceState>
+                    <privateDnsName>ip-10-194-149-220.ec2.internal</privateDnsName>
+                    <dnsName>ec2-23-20-17-42.compute-1.amazonaws.com</dnsName>
+                    <reason/>
+                    <keyName>jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae#105</keyName>
+                    <amiLaunchIndex>0</amiLaunchIndex>
+                    <productCodes/>
+                    <instanceType>c1.medium</instanceType>
+                    <launchTime>2012-09-14T20:01:34.000Z</launchTime>
+                    <placement>
+                        <availabilityZone>us-east-1d</availabilityZone>
+                        <groupName/>
+                        <tenancy>default</tenancy>
+                    </placement>
+                    <kernelId>aki-825ea7eb</kernelId>
+                    <monitoring>
+                        <state>disabled</state>
+                    </monitoring>
+                    <privateIpAddress>10.194.149.220</privateIpAddress>
+                    <ipAddress>23.20.17.42</ipAddress>
+                    <groupSet>
+                        <item>
+                            <groupId>sg-f788299f</groupId>
+                            <groupName>launchpad_sec_group</groupName>
+                        </item>
+                        <item>
+                            <groupId>sg-7e512116</groupId>
+                            <groupName>jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae</groupName>
+                        </item>
+                    </groupSet>
+                    <architecture>x86_64</architecture>
+                    <rootDeviceType>ebs</rootDeviceType>
+                    <rootDeviceName>/dev/sda1</rootDeviceName>
+                    <blockDeviceMapping>
+                        <item>
+                            <deviceName>/dev/sda1</deviceName>
+                            <ebs>
+                                <volumeId>vol-b2beb3c9</volumeId>
+                                <status>attaching</status>
+                                <attachTime>2012-09-14T20:01:37.000Z</attachTime>
+                                <deleteOnTermination>true</deleteOnTermination>
+                            </ebs>
+                        </item>
+                    </blockDeviceMapping>
+                    <virtualizationType>paravirtual</virtualizationType>
+                    <clientToken/>
+                    <tagSet>
+                        <item>
+                            <key>Name</key>
+                            <value>4c858090-f66c-4225-aa57-6fcaa42198ae-32451248</value>
+                        </item>
+                    </tagSet>
+                    <hypervisor>xen</hypervisor>
+                </item>
+            </instancesSet>
+        </item>
+    </reservationSet>
+</DescribeInstancesResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml
new file mode 100644
index 0000000..33de035
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml
@@ -0,0 +1,10 @@
+<DescribePlacementGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
+   <requestID>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestID>
+   <placementGroupSet>
+      <item>
+         <groupName>XYZ-cluster</groupName>
+         <strategy>cluster</strategy>
+         <state>available</state>
+      </item>
+   </placementGroupSet>
+</DescribePlacementGroupsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml
new file mode 100644
index 0000000..d08a605
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml
@@ -0,0 +1,15 @@
+<DescribeReservedInstancesOfferingsResponse
+	xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+	<reservedInstancesOfferingsSet>
+		<item>
+			<reservedInstancesOfferingId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8
+			</reservedInstancesOfferingId>
+			<instanceType>m1.small</instanceType>
+			<availabilityZone>us-east-1a</availabilityZone>
+			<duration>12</duration>
+			<fixedPrice>0.00</fixedPrice>
+			<usagePrice>0.00</usagePrice>
+			<productDescription>m1.small offering in us-east-1a</productDescription>
+		</item>
+	</reservedInstancesOfferingsSet>
+</DescribeReservedInstancesOfferingsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml
new file mode 100644
index 0000000..e444aa5
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml
@@ -0,0 +1,35 @@
+<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+        <requestId>xxxxxxxxxxxxxxxx</requestId>
+        <securityGroupInfo>
+            <item>
+                <ownerId>123123123123</ownerId>
+                <groupId>sg-11111111</groupId>
+                <groupName>default</groupName>
+                <groupDescription>default VPC security group</groupDescription>
+                <vpcId>vpc-99999999</vpcId>
+                <ipPermissions>
+                    <item>
+                        <ipProtocol>-1</ipProtocol>
+                        <groups>
+                            <item>
+                                <userId>123123123123</userId>
+                                <groupId>sg-11111111</groupId>
+                            </item>
+                        </groups>
+                        <ipRanges/>
+                    </item>
+                </ipPermissions>
+                <ipPermissionsEgress>
+                    <item>
+                        <ipProtocol>-1</ipProtocol>
+                        <groups/>
+                        <ipRanges>
+                            <item>
+                                <cidrIp>0.0.0.0/0</cidrIp>
+                            </item>
+                        </ipRanges>
+                    </item>
+                </ipPermissionsEgress>
+            </item>
+    </securityGroupInfo>
+</DescribeSecurityGroupsResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml
new file mode 100644
index 0000000..964b246
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-06-01/">
+    <requestId>d9da716a-5cd4-492e-83b9-6777ac16d6cf</requestId>
+    <spotInstanceRequestSet>
+        <item>
+            <spotInstanceRequestId>sir-1ede0012</spotInstanceRequestId>
+            <spotPrice>0.300000</spotPrice>
+            <type>one-time</type>
+            <state>active</state>
+            <launchSpecification>
+                <imageId>ami-8e1fece7</imageId>
+                <keyName>jclouds#adriancole-ec2unssh</keyName>
+                <groupSet>
+                    <item>
+                        <groupId>sg-83e1c4eb</groupId>
+                        <groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
+                    </item>
+                </groupSet>
+                <instanceType>t1.micro</instanceType>
+                <blockDeviceMapping/>
+                <monitoring>
+                    <enabled>false</enabled>
+                </monitoring>
+            </launchSpecification>
+            <instanceId>i-ef308e8e</instanceId>
+            <createTime>2011-07-29T05:27:39.000Z</createTime>
+            <productDescription>Linux/UNIX</productDescription>
+            <tagSet>
+                <item>
+                    <key>Name</key>
+                    <value>ec2-o</value>
+                </item>
+                <item>
+                    <key>Spot</key>
+                    <value>spot-value</value>
+                </item>
+                <item>
+                    <key>Empty</key>
+                    <value />
+                </item>
+            </tagSet>            
+            <launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
+        </item>
+    </spotInstanceRequestSet>
+</DescribeSpotInstanceRequestsResponse>
\ No newline at end of file


[11/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
new file mode 100644
index 0000000..e6fb402
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.or;
+
+import java.util.concurrent.ConcurrentMap;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial;
+import org.jclouds.aws.ec2.functions.CreatePlacementGroupIfNeeded;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.options.EC2TemplateOptions;
+import org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.logging.Logger;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions extends
+      CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions {
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+   @VisibleForTesting
+   final LoadingCache<RegionAndName, String> placementGroupMap;
+   @VisibleForTesting
+   final CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded;
+   @VisibleForTesting
+   final Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair;
+
+   @Inject
+   public CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(
+         Function<RegionAndName, KeyPair> makeKeyPair, ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
+         @Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
+         Provider<RunInstancesOptions> optionsProvider,
+         @Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
+         CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded,
+         Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair, 
+         GroupNamingConvention.Factory namingConvention) {
+      super(makeKeyPair, credentialsMap, securityGroupMap, optionsProvider, namingConvention);
+      this.placementGroupMap = placementGroupMap;
+      this.createPlacementGroupIfNeeded = createPlacementGroupIfNeeded;
+      this.importExistingKeyPair = importExistingKeyPair;
+   }
+
+   public AWSRunInstancesOptions execute(String region, String group, Template template) {
+      AWSRunInstancesOptions instanceOptions = AWSRunInstancesOptions.class
+            .cast(super.execute(region, group, template));
+
+      String placementGroupName = template.getHardware().getId().startsWith("cc") ? createNewPlacementGroupUnlessUserSpecifiedOtherwise(
+            region, group, template.getOptions()) : null;
+
+      if (placementGroupName != null)
+         instanceOptions.inPlacementGroup(placementGroupName);
+
+      AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
+      if (awsTemplateOptions.isMonitoringEnabled())
+         instanceOptions.enableMonitoring();
+      if (awsTemplateOptions.getIAMInstanceProfileArn() != null)
+         instanceOptions.withIAMInstanceProfileArn(awsTemplateOptions.getIAMInstanceProfileArn());
+      if (awsTemplateOptions.getIAMInstanceProfileName() != null)
+         instanceOptions.withIAMInstanceProfileName(awsTemplateOptions.getIAMInstanceProfileName());
+
+      return instanceOptions;
+   }
+
+   @VisibleForTesting
+   String createNewPlacementGroupUnlessUserSpecifiedOtherwise(String region, String group, TemplateOptions options) {
+      String placementGroupName = null;
+      boolean shouldAutomaticallyCreatePlacementGroup = true;
+      if (options instanceof EC2TemplateOptions) {
+         placementGroupName = AWSEC2TemplateOptions.class.cast(options).getPlacementGroup();
+         if (placementGroupName == null)
+            shouldAutomaticallyCreatePlacementGroup = AWSEC2TemplateOptions.class.cast(options)
+                  .shouldAutomaticallyCreatePlacementGroup();
+      }
+      if (placementGroupName == null && shouldAutomaticallyCreatePlacementGroup) {
+         // placementGroupName must be unique within an account per
+         // http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using_cluster_computing.html
+         placementGroupName = String.format("jclouds#%s#%s", group, region);
+         RegionAndName regionAndName = new RegionAndName(region, placementGroupName);
+         // make this entry as needed
+         placementGroupMap.getUnchecked(regionAndName);
+      }
+      return placementGroupName;
+   }
+
+   @Override
+   public String createNewKeyPairUnlessUserSpecifiedOtherwise(String region, String group, TemplateOptions options) {
+      RegionAndName key = new RegionAndName(region, group);
+      KeyPair pair;
+      if (and(hasPublicKeyMaterial, or(doesntNeedSshAfterImportingPublicKey, hasLoginCredential)).apply(options)) {
+         pair = importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group, options.getPublicKey()));
+         options.dontAuthorizePublicKey();
+         if (hasLoginCredential.apply(options))
+            pair = pair.toBuilder().keyMaterial(options.getLoginPrivateKey()).build();
+         credentialsMap.put(key, pair);
+      } else {
+         if (hasPublicKeyMaterial.apply(options)) {
+            logger.warn("to avoid creating temporary keys in aws-ec2, use templateOption overrideLoginCredentialWith(id_rsa)");
+         }
+         return super.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options);
+      }
+      return pair.getKeyName();
+   }
+
+   public static final Predicate<TemplateOptions> hasPublicKeyMaterial = new Predicate<TemplateOptions>() {
+
+      @Override
+      public boolean apply(TemplateOptions options) {
+         return options.getPublicKey() != null;
+      }
+
+   };
+
+   public static final Predicate<TemplateOptions> doesntNeedSshAfterImportingPublicKey = new Predicate<TemplateOptions>() {
+
+      @Override
+      public boolean apply(TemplateOptions options) {
+         return options.getRunScript() == null && options.getPrivateKey() == null;
+      }
+
+   };
+
+   public static final Predicate<TemplateOptions> hasLoginCredential = new Predicate<TemplateOptions>() {
+
+      @Override
+      public boolean apply(TemplateOptions options) {
+         return options.getLoginPrivateKey() != null;
+      }
+
+   };
+
+   @Override
+   protected boolean userSpecifiedTheirOwnGroups(TemplateOptions options) {
+      return options instanceof AWSEC2TemplateOptions
+            && AWSEC2TemplateOptions.class.cast(options).getGroupIds().size() > 0
+            || super.userSpecifiedTheirOwnGroups(options);
+   }
+
+   @Override
+   protected void addSecurityGroups(String region, String group, Template template, RunInstancesOptions instanceOptions) {
+      AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
+      AWSRunInstancesOptions awsInstanceOptions = AWSRunInstancesOptions.class.cast(instanceOptions);
+      if (awsTemplateOptions.getGroupIds().size() > 0)
+         awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
+      String subnetId = awsTemplateOptions.getSubnetId();
+      if (subnetId != null) {
+         AWSRunInstancesOptions.class.cast(instanceOptions).withSubnetId(subnetId);
+      } else {
+         super.addSecurityGroups(region, group, template, instanceOptions);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java
new file mode 100644
index 0000000..0abc94f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.suppliers;
+
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_8xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc2_8xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cg1_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.g2_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.hi1_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.hs1_8xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.i2_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.i2_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.i2_8xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.i2_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_medium;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m3_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m3_large;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m3_medium;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m3_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.t1_micro;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.compute.config.ClusterCompute;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2HardwareSupplier extends EC2HardwareSupplier {
+
+   private final Set<String> ccAmis;
+
+   @Inject
+   public AWSEC2HardwareSupplier(@ClusterCompute Set<String> ccAmis) {
+      this.ccAmis = ccAmis;
+   }
+
+   @Override
+   public Set<? extends Hardware> get() {
+      Builder<Hardware> sizes = ImmutableSet.builder();
+      sizes.add(cc1_4xlarge().supportsImageIds(ccAmis).build());
+      sizes.add(cg1_4xlarge().supportsImageIds(ccAmis).build());
+      sizes.add(cc2_8xlarge().supportsImageIds(ccAmis).build());
+      sizes.add(hi1_4xlarge().supportsImageIds(ccAmis).build());
+      sizes.add(hs1_8xlarge().supportsImageIds(ccAmis).build());
+      sizes.add(g2_2xlarge().supportsImageIds(ccAmis).build());
+
+      sizes.add(t1_micro().build());
+      sizes.add(c1_medium().build());
+      sizes.add(c1_xlarge().build());
+      sizes.add(c3_xlarge().build());
+      sizes.add(c3_2xlarge().build());
+      sizes.add(c3_4xlarge().build());
+      sizes.add(c3_8xlarge().build());
+      sizes.add(i2_xlarge().build());
+      sizes.add(i2_2xlarge().build());
+      sizes.add(i2_4xlarge().build());
+      sizes.add(i2_8xlarge().build());
+      sizes.add(m1_large().build());
+      sizes.add(m1_small().build());
+      sizes.add(m1_medium().build());
+      sizes.add(m1_xlarge().build());
+      sizes.add(m2_xlarge().build());
+      sizes.add(m2_2xlarge().build());
+      sizes.add(m2_4xlarge().build());
+      sizes.add(m3_medium().build());
+      sizes.add(m3_large().build());
+      sizes.add(m3_xlarge().build());
+      sizes.add(m3_2xlarge().build());
+
+      return sizes.build();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java
new file mode 100644
index 0000000..03fadb8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.suppliers;
+
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.aws.ec2.compute.config.ClusterCompute;
+import org.jclouds.aws.ec2.compute.config.ImageQuery;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap;
+import org.jclouds.location.Region;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Splitter;
+import com.google.common.base.Supplier;
+import com.google.common.base.Throwables;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ForwardingSet;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2ImageSupplier implements Supplier<Set<? extends Image>> {
+   
+   // TODO could/should this sub-class EC2ImageSupplier? Or does that confuse guice?
+   
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+   
+   private final Set<String> clusterComputeIds;
+   private final CallForImages.Factory factory;
+   private final ListeningExecutorService userExecutor;
+
+   private final Supplier<Set<String>> regions;
+   private final Map<String, String> queries;
+   private final Iterable<String> clusterRegions;
+   private final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache;
+   
+   @Inject
+   protected AWSEC2ImageSupplier(@Region Supplier<Set<String>> regions,
+            @ImageQuery Map<String, String> queries, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions,
+            Supplier<LoadingCache<RegionAndName, ? extends Image>> cache,
+            CallForImages.Factory factory, @ClusterCompute Set<String> clusterComputeIds,
+            @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+      this.factory = factory;
+      this.regions = regions;
+      this.queries = queries;
+      this.clusterRegions = Splitter.on(',').split(clusterRegions);
+      this.cache = cache;
+      this.clusterComputeIds = clusterComputeIds;
+      this.userExecutor = userExecutor;
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Override
+   public Set<? extends Image> get() {
+      String amiQuery = queries.get(PROPERTY_EC2_AMI_QUERY);
+      String ccAmiQuery = queries.get(PROPERTY_EC2_CC_AMI_QUERY);
+
+      ListenableFuture<Iterable<Image>> normalImages = images(regions.get(), amiQuery, PROPERTY_EC2_AMI_QUERY);
+      ImmutableSet<Image> clusterImages;
+      try {
+         clusterImages = ImmutableSet.copyOf(images(clusterRegions, ccAmiQuery, PROPERTY_EC2_CC_AMI_QUERY).get());
+      } catch (Exception e) {
+         logger.warn(e, "Error parsing images in query %s", ccAmiQuery);
+         throw Throwables.propagate(e);
+      }
+      Iterables.addAll(clusterComputeIds, transform(clusterImages, new Function<Image, String>() {
+
+         @Override
+         public String apply(Image arg0) {
+            return arg0.getId();
+         }
+
+      }));
+      Iterable<? extends Image> parsedImages;
+      try {
+         parsedImages = ImmutableSet.copyOf(concat(clusterImages, normalImages.get()));
+      } catch (Exception e) {
+         logger.warn(e, "Error parsing images in query %s", amiQuery);
+         throw Throwables.propagate(e);
+      }
+
+      final Map<RegionAndName, ? extends Image> imageMap = ImagesToRegionAndIdMap.imagesToMap(parsedImages);
+      cache.get().invalidateAll();
+      cache.get().asMap().putAll(Map.class.cast(imageMap));
+      logger.debug("<< images(%d)", imageMap.size());
+      
+      // TODO Used to be mutable; was this assumed anywhere?
+      return new ForwardingSet<Image>() {
+         protected Set<Image> delegate() {
+            return ImmutableSet.copyOf(cache.get().asMap().values());
+         }
+      };
+   }
+   
+   private ListenableFuture<Iterable<Image>> images(Iterable<String> regions, String query, String tag) {
+      if (query == null) {
+         logger.debug(">> no %s specified, skipping image parsing", tag);
+         return Futures.<Iterable<Image>> immediateFuture(ImmutableSet.<Image> of());
+      } else {
+         return userExecutor.submit(factory.parseImagesFromRegionsUsingFilter(regions, QueryStringToMultimap.INSTANCE
+                  .apply(query)));
+      }
+   }
+
+   public static enum QueryStringToMultimap implements Function<String, Multimap<String, String>> {
+      INSTANCE;
+      @Override
+      public Multimap<String, String> apply(String arg0) {
+         ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
+         for (String pair : Splitter.on(';').split(arg0)) {
+            String[] keyValue = pair.split("=");
+            if (keyValue.length == 1)
+               builder.putAll(keyValue[0], ImmutableSet.<String> of());
+            else
+               builder.putAll(keyValue[0], Splitter.on(',').split(keyValue[1]));
+         }
+         return builder.build();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java
new file mode 100644
index 0000000..7fcc7de
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.suppliers;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters;
+
+import java.util.Map.Entry;
+import java.util.concurrent.Callable;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.functions.EC2ImageParser;
+import org.jclouds.ec2.compute.strategy.DescribeImagesParallel;
+import org.jclouds.ec2.options.DescribeImagesOptions;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.inject.assistedinject.Assisted;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class CallForImages implements Callable<Iterable<Image>> {
+   public interface Factory {
+      CallForImages parseImagesFromRegionsUsingFilter(Iterable<String> regions, Multimap<String, String> filter);
+   }
+
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+
+   private final Iterable<String> regions;
+   private final DescribeImagesParallel describer;
+   private final EC2ImageParser parser;
+   private final Multimap<String, String> filter;
+
+   @Inject
+   protected CallForImages(DescribeImagesParallel describer, EC2ImageParser parser, @Assisted Iterable<String> regions,
+            @Assisted Multimap<String, String> filter) {
+      this.regions = regions;
+      this.describer = describer;
+      this.filter = filter;
+      this.parser = parser;
+   }
+
+   public Iterable<Image> call() {
+
+      logger.debug(">> providing images");
+
+      Builder<String, DescribeImagesOptions> builder = ImmutableMap.builder();
+      for (String region : regions)
+         builder.put(region, filters(filter));
+
+      Iterable<Entry<String, DescribeImagesOptions>> queries = builder.build().entrySet();
+
+      Iterable<Image> returnVal = filter(transform(describer.apply(queries), parser), Predicates.notNull());
+      if (logger.isDebugEnabled())
+         logger.debug("<< images(%s)", Iterables.size(returnVal));
+      return returnVal;
+   }
+
+   @Override
+   public String toString() {
+      return String.format("describingImages(filter=%s,regions=%s)", filter, regions);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
new file mode 100644
index 0000000..a227e8f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.config;
+
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.config.BaseEC2HttpApiModule;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.ec2.features.AMIApi;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.ec2.features.SecurityGroupApi;
+import org.jclouds.rest.ConfiguresHttpApi;
+
+import com.google.common.base.Function;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Configures the EC2 connection.
+ * 
+ * @author Adrian Cole
+ */
+@ConfiguresHttpApi
+public class AWSEC2HttpApiModule extends BaseEC2HttpApiModule<AWSEC2Api> {
+
+   public AWSEC2HttpApiModule() {
+      super(AWSEC2Api.class);
+   }
+
+   @Singleton
+   @Provides
+   EC2Api provide(AWSEC2Api in) {
+      return in;
+   }
+
+   @Singleton
+   @Provides
+   InstanceApi getInstanceApi(AWSEC2Api in) {
+      return in.getInstanceApi().get();
+   }
+
+   @Singleton
+   @Provides
+   SecurityGroupApi getSecurityGroupApi(AWSEC2Api in) {
+      return in.getSecurityGroupApi().get();
+   }
+
+   @Singleton
+   @Provides
+   AMIApi getAMIApi(AWSEC2Api in) {
+      return in.getAMIApi().get();
+   }
+
+   @Override
+   protected void configure() {
+      bind(RunInstancesOptions.class).to(AWSRunInstancesOptions.class);
+      bind(new TypeLiteral<Function<SpotInstanceRequest, AWSRunningInstance>>() {
+      }).to(SpotInstanceRequestToAWSRunningInstance.class);
+      super.configure();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java
new file mode 100644
index 0000000..03b8188
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java
@@ -0,0 +1,337 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.SinceApiVersion;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * 
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-RunningInstancesItemType.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class AWSRunningInstance extends RunningInstance {
+   
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   @Override
+   public Builder toBuilder() {
+      return new Builder().fromRunningInstance(this);
+   }
+   
+   public static class Builder extends org.jclouds.ec2.domain.RunningInstance.Builder<Builder> {
+      private MonitoringState monitoringState;
+      private String placementGroup;
+      private Set<String> productCodes = Sets.newLinkedHashSet();
+      private String subnetId;
+      private String spotInstanceRequestId;
+      private String vpcId;
+      private Hypervisor hypervisor;
+      private Map<String, String> securityGroupIdToNames = Maps.newLinkedHashMap();
+      private String iamInstanceProfileArn;
+      private String iamInstanceProfileId;
+
+      public Builder securityGroupIdToNames(Map<String, String> securityGroupIdToNames) {
+         this.securityGroupIdToNames = ImmutableMap.copyOf(checkNotNull(securityGroupIdToNames,
+               "securityGroupIdToNames"));
+         return this;
+      }
+
+      public Builder securityGroupIdToName(String key, String value) {
+         if (key != null && value != null)
+            this.securityGroupIdToNames.put(key, value);
+         return this;
+      }
+
+      public Builder monitoringState(MonitoringState monitoringState) {
+         this.monitoringState = monitoringState;
+         return this;
+      }
+
+      public Builder placementGroup(String placementGroup) {
+         this.placementGroup = placementGroup;
+         return this;
+      }
+
+      public Builder productCodes(Iterable<String> productCodes) {
+         this.productCodes = ImmutableSet.copyOf(checkNotNull(productCodes, "productCodes"));
+         return this;
+      }
+
+      public Builder productCode(String productCode) {
+         if (productCode != null)
+            this.productCodes.add(productCode);
+         return this;
+      }
+
+      public Builder subnetId(String subnetId) {
+         this.subnetId = subnetId;
+         return this;
+      }
+
+      public Builder spotInstanceRequestId(String spotInstanceRequestId) {
+         this.spotInstanceRequestId = spotInstanceRequestId;
+         return this;
+      }
+
+      public Builder vpcId(String vpcId) {
+         this.vpcId = vpcId;
+         return this;
+      }
+      
+      public Builder hypervisor(Hypervisor hypervisor) {
+         this.hypervisor = hypervisor;
+         return this;
+      }
+
+      /**
+       * @see AWSRunningInstance#getIAMInstanceProfile()
+       */
+      public Builder iamInstanceProfileArn(String iamInstanceProfileArn) {
+         this.iamInstanceProfileArn = iamInstanceProfileArn;
+         return this;
+      }
+
+      /**
+       * @see AWSRunningInstance#getIAMInstanceProfile()
+       */
+      public Builder iamInstanceProfileId(String iamInstanceProfileId) {
+         this.iamInstanceProfileId = iamInstanceProfileId;
+         return this;
+      }
+
+      @Override
+      public AWSRunningInstance build() {
+         Optional<IAMInstanceProfile> iamInstanceProfile = Optional.absent();
+         if (iamInstanceProfileArn != null && iamInstanceProfileId != null) {
+            iamInstanceProfile = Optional.of(IAMInstanceProfile.forArnAndId(iamInstanceProfileArn,
+                  iamInstanceProfileId));
+         }
+         return new AWSRunningInstance(region, securityGroupIdToNames, amiLaunchIndex, dnsName, imageId, instanceId,
+               instanceState, rawState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone,
+               virtualizationType, platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType,
+               rootDeviceName, ebsBlockDevices, monitoringState, placementGroup, productCodes, subnetId,
+               spotInstanceRequestId, vpcId, hypervisor, tags, iamInstanceProfile);
+      }
+      
+      @Override
+      public Builder fromRunningInstance(RunningInstance in) {
+         super.fromRunningInstance(in);
+         if (in instanceof AWSRunningInstance) {
+            AWSRunningInstance awsIn = AWSRunningInstance.class.cast(in);
+            monitoringState(awsIn.monitoringState).placementGroup(awsIn.placementGroup)
+                  .productCodes(awsIn.productCodes).subnetId(awsIn.subnetId)
+                  .spotInstanceRequestId(awsIn.spotInstanceRequestId).vpcId(awsIn.vpcId).hypervisor(awsIn.hypervisor)
+                  .securityGroupIdToNames(awsIn.securityGroupIdToNames);
+            if (awsIn.getIAMInstanceProfile().isPresent()) {
+               iamInstanceProfileArn(awsIn.getIAMInstanceProfile().get().getArn());
+               iamInstanceProfileId(awsIn.getIAMInstanceProfile().get().getId());
+            }
+         }
+         return this;
+      }
+
+      @Override
+      protected Builder self() {
+         return this;
+      }
+
+   }
+
+   private final MonitoringState monitoringState;
+   @Nullable
+   private final String placementGroup;
+   private final Set<String> productCodes;
+   @Nullable
+   private final String subnetId;
+   @Nullable
+   private final String spotInstanceRequestId;
+   @Nullable
+   private final String vpcId;
+   private final Hypervisor hypervisor;
+   private final Map<String, String> securityGroupIdToNames;
+   private final Optional<IAMInstanceProfile> iamInstanceProfile;
+
+   protected AWSRunningInstance(String region, Map<String, String> securityGroupIdToNames, String amiLaunchIndex,
+            String dnsName, String imageId, String instanceId, InstanceState instanceState, String rawState,
+            String instanceType, String ipAddress, String kernelId, String keyName, Date launchTime,
+            String availabilityZone, String virtualizationType, String platform, String privateDnsName,
+            String privateIpAddress, String ramdiskId, String reason, RootDeviceType rootDeviceType,
+            String rootDeviceName, Map<String, BlockDevice> ebsBlockDevices, MonitoringState monitoringState,
+            String placementGroup, Iterable<String> productCodes, String subnetId, String spotInstanceRequestId,
+            String vpcId, Hypervisor hypervisor, Map<String, String> tags, Optional<IAMInstanceProfile> iamInstanceProfile) {
+      super(region, securityGroupIdToNames.values(), amiLaunchIndex, dnsName, imageId, instanceId, instanceState,
+               rawState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType,
+               platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName,
+               ebsBlockDevices, tags);
+      this.monitoringState = checkNotNull(monitoringState, "monitoringState");
+      this.placementGroup = placementGroup;
+      this.productCodes = ImmutableSet.copyOf(checkNotNull(productCodes, "productCodes"));
+      this.subnetId = subnetId;
+      this.spotInstanceRequestId = spotInstanceRequestId;
+      this.vpcId = vpcId;
+      this.hypervisor = checkNotNull(hypervisor, "hypervisor");
+      this.securityGroupIdToNames = ImmutableMap.<String, String> copyOf(checkNotNull(securityGroupIdToNames,
+            "securityGroupIdToNames"));
+      this.iamInstanceProfile = checkNotNull(iamInstanceProfile, "iamInstanceProfile of %s", instanceId);
+   }
+
+   public Map<String, String> getSecurityGroupIdToNames() {
+      return securityGroupIdToNames;
+   }
+
+   /**
+    * State of monitoring for the instance.
+    */
+   public MonitoringState getMonitoringState() {
+      return monitoringState;
+   }
+
+   /**
+    * The name of the placement group the instance is in (for cluster compute
+    * instances).
+    */
+   public String getPlacementGroup() {
+      return placementGroup;
+   }
+
+   /**
+    * Product codes attached to this instance.
+    */
+   public Set<String> getProductCodes() {
+      return productCodes;
+   }
+
+   /**
+    * The ID of the Spot Instance request
+    */
+   public String getSpotInstanceRequestId() {
+      return spotInstanceRequestId;
+   }
+
+   /**
+    * Specifies the VPC in which the instance is running (Amazon Virtual Private
+    * Cloud).
+    */
+   public String getVpcId() {
+      return vpcId;
+   }
+   
+   /**
+    * hypervisor of the VM
+    * @see Hypervisor
+    */
+   public Hypervisor getHypervisor() {
+      return hypervisor;
+   }
+   
+   /**
+    * Specifies the subnet ID in which the instance is running (Amazon Virtual
+    * Private Cloud).
+    */
+   public String getSubnetId() {
+      return subnetId;
+   }
+
+   /**
+    * The IAM Instance Profile (IIP) associated with the instance.
+    */
+   @SinceApiVersion("2012-06-01")
+   public Optional<IAMInstanceProfile> getIAMInstanceProfile() {
+      return iamInstanceProfile;
+   }
+
+   @Override
+   protected ToStringHelper string() {
+      return super.string().add("monitoringState", monitoringState).add("placementGroup", placementGroup)
+               .add("subnetId", subnetId).add("spotInstanceRequestId", spotInstanceRequestId).add("vpcId", vpcId)
+               .add("hypervisor", hypervisor).add("iamInstanceProfile", iamInstanceProfile.orNull());
+   }
+
+   public static class IAMInstanceProfile {
+      public static IAMInstanceProfile forArnAndId(String arn, String id) {
+         return new IAMInstanceProfile(arn, id);
+      }
+
+      private final String arn;
+      private final String id;
+
+      private IAMInstanceProfile(String arn, String id) {
+         this.arn = checkNotNull(arn, "arn");
+         this.id = checkNotNull(id, "id for %s", arn);
+      }
+
+      /**
+       * The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instance.
+       */
+      public String getArn() {
+         return arn;
+      }
+
+      /**
+       * The ID of the IAM Instance Profile ID (IIP) associated with the instance.
+       */
+      public String getId() {
+         return id;
+      }
+
+      @Override
+      public int hashCode() {
+         return Objects.hashCode(arn, id);
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+         if (this == obj)
+            return true;
+         if (obj == null || getClass() != obj.getClass())
+            return false;
+         IAMInstanceProfile that = IAMInstanceProfile.class.cast(obj);
+         return equal(this.arn, that.arn) && equal(this.id, that.id);
+      }
+
+      @Override
+      public String toString() {
+         return toStringHelper("").add("arn", arn).add("id", id).toString();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java
new file mode 100644
index 0000000..34c46be
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java
@@ -0,0 +1,547 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.ec2.domain.BlockDeviceMapping.MapEBSSnapshotToDevice;
+import org.jclouds.ec2.domain.BlockDeviceMapping.MapEphemeralDeviceToDevice;
+import org.jclouds.ec2.domain.BlockDeviceMapping.MapNewVolumeToDevice;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.SinceApiVersion;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * 
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RequestSpotInstances.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class LaunchSpecification {
+
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   public static class Builder {
+      protected ImmutableMap.Builder<String, String> securityGroupIdToNames = ImmutableMap.builder();
+      protected String imageId;
+      protected String instanceType;
+      protected String kernelId;
+      protected String keyName;
+      protected String availabilityZone;
+      protected String subnetId;
+      protected String ramdiskId;
+      protected Boolean monitoringEnabled;
+      protected ImmutableSet.Builder<BlockDeviceMapping> blockDeviceMappings = ImmutableSet
+            .builder();
+      protected ImmutableSet.Builder<String> securityGroupIds = ImmutableSet.builder();
+      protected ImmutableSet.Builder<String> securityGroupNames = ImmutableSet.builder();
+      protected byte[] userData;
+      private String iamInstanceProfileArn;
+      private String iamInstanceProfileName;
+
+      public void clear() {
+         securityGroupIdToNames = ImmutableMap.builder();
+         imageId = null;
+         instanceType = null;
+         kernelId = null;
+         keyName = null;
+         availabilityZone = null;
+         subnetId = null;
+         ramdiskId = null;
+         monitoringEnabled = false;
+         blockDeviceMappings = ImmutableSet.builder();
+         securityGroupIds = ImmutableSet.builder();
+         securityGroupNames = ImmutableSet.builder();
+         userData = null;
+         iamInstanceProfileArn = null;
+         iamInstanceProfileName = null;
+      }
+
+      public Builder securityGroupIdToNames(Map<String, String> securityGroupIdToNames) {
+         this.securityGroupIdToNames.putAll(checkNotNull(securityGroupIdToNames, "securityGroupIdToNames"));
+         return this;
+      }
+
+      public Builder securityGroupIdToName(String groupId, String groupName) {
+         if (groupId != null && groupName != null)
+            this.securityGroupIdToNames.put(checkNotNull(groupId, "groupId"), checkNotNull(groupName, "groupName"));
+         return this;
+      }
+
+      public Builder imageId(String imageId) {
+         this.imageId = imageId;
+         return this;
+      }
+
+      public Builder monitoringEnabled(Boolean monitoringEnabled) {
+         this.monitoringEnabled = monitoringEnabled;
+         return this;
+      }
+
+      public Builder instanceType(String instanceType) {
+         this.instanceType = instanceType;
+         return this;
+      }
+
+      public Builder kernelId(String kernelId) {
+         this.kernelId = kernelId;
+         return this;
+      }
+
+      public Builder keyName(String keyName) {
+         this.keyName = keyName;
+         return this;
+      }
+
+      public Builder availabilityZone(String availabilityZone) {
+         this.availabilityZone = availabilityZone;
+         return this;
+      }
+      
+      public Builder subnetId(String subnetId) {
+         this.subnetId = subnetId;
+         return this;
+      }
+      
+      public Builder ramdiskId(String ramdiskId) {
+         this.ramdiskId = ramdiskId;
+         return this;
+      }
+
+      public Builder mapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib,
+            boolean deleteOnTermination) {
+         blockDeviceMappings.add(new MapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination));
+         return this;
+      }
+
+      public Builder mapNewVolumeToDevice(String deviceName, int sizeInGib, boolean deleteOnTermination) {
+         blockDeviceMappings.add(new MapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination));
+         return this;
+      }
+
+      public Builder mapEphemeralDeviceToDevice(String deviceName, String virtualName) {
+         blockDeviceMappings.add(new MapEphemeralDeviceToDevice(deviceName, virtualName));
+         return this;
+      }
+
+      public Builder blockDeviceMapping(BlockDeviceMapping blockDeviceMapping) {
+         this.blockDeviceMappings.add(checkNotNull(blockDeviceMapping, "blockDeviceMapping"));
+         return this;
+      }
+
+      public Builder blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings) {
+         this.blockDeviceMappings.addAll(checkNotNull(blockDeviceMappings, "blockDeviceMappings"));
+         return this;
+      }
+
+      public Builder securityGroupIds(Iterable<String> securityGroupIds) {
+         this.securityGroupIds.addAll(checkNotNull(securityGroupIds, "securityGroupIds"));
+         return this;
+      }
+
+      public Builder securityGroupId(String securityGroupId) {
+         if (securityGroupId != null)
+            this.securityGroupIds.add(securityGroupId);
+         return this;
+      }
+
+      public Builder securityGroupNames(Iterable<String> securityGroupNames) {
+         this.securityGroupNames.addAll(checkNotNull(securityGroupNames, "securityGroupNames"));
+         return this;
+      }
+
+      public Builder securityGroupName(String securityGroupName) {
+         if (securityGroupName != null)
+            this.securityGroupNames.add(securityGroupName);
+         return this;
+      }
+
+      public Builder userData(byte[] userData) {
+         this.userData = userData;
+         return this;
+      }
+
+      /**
+       * @see LaunchSpecification#getIAMInstanceProfile()
+       */
+      public Builder iamInstanceProfileArn(String iamInstanceProfileArn) {
+         this.iamInstanceProfileArn = iamInstanceProfileArn;
+         return this;
+      }
+
+      /**
+       * @see LaunchSpecification#getIAMInstanceProfile()
+       */
+      public Builder iamInstanceProfileName(String iamInstanceProfileName) {
+         this.iamInstanceProfileName = iamInstanceProfileName;
+         return this;
+      }
+
+      public LaunchSpecification build() {
+         Optional<IAMInstanceProfileRequest> iamInstanceProfile;
+         if (iamInstanceProfileArn != null && iamInstanceProfileName != null) {
+            iamInstanceProfile = Optional.of(IAMInstanceProfileRequest.forArnAndName(iamInstanceProfileArn,
+                  iamInstanceProfileName));
+         } else if (iamInstanceProfileArn != null) {
+            iamInstanceProfile = Optional.of(IAMInstanceProfileRequest.forArn(iamInstanceProfileArn));
+         } else if (iamInstanceProfileName != null) {
+            iamInstanceProfile = Optional.of(IAMInstanceProfileRequest.forName(iamInstanceProfileName));
+         } else {
+            iamInstanceProfile = Optional.absent();
+         }
+         return new LaunchSpecification(instanceType, imageId, kernelId, ramdiskId, availabilityZone, subnetId,
+               keyName, securityGroupIdToNames.build(), blockDeviceMappings.build(), monitoringEnabled,
+               securityGroupIds.build(), securityGroupNames.build(), userData, iamInstanceProfile);
+      }
+
+      public static Builder fromLaunchSpecification(LaunchSpecification in) {
+         Builder builder = new Builder();
+         builder.instanceType(in.getInstanceType()).imageId(in.getImageId()).kernelId(in.getKernelId())
+               .ramdiskId(in.getRamdiskId()).availabilityZone(in.getAvailabilityZone()).subnetId(in.getSubnetId())
+               .keyName(in.getKeyName()).securityGroupIdToNames(in.getSecurityGroupIdToNames())
+               .securityGroupIds(in.getSecurityGroupIds()).securityGroupNames(in.getSecurityGroupNames())
+               .blockDeviceMappings(in.getBlockDeviceMappings()).monitoringEnabled(in.isMonitoringEnabled())
+               .userData(in.getUserData());
+         if (in.getIAMInstanceProfile().isPresent()) {
+            builder.iamInstanceProfileArn(in.getIAMInstanceProfile().get().getArn().orNull());
+            builder.iamInstanceProfileName(in.getIAMInstanceProfile().get().getName().orNull());
+         }
+         return builder;
+      }
+   }
+
+   protected final String instanceType;
+   protected final String imageId;
+   protected final String kernelId;
+   protected final String ramdiskId;
+   protected final String availabilityZone;
+   protected final String subnetId;
+   protected final String keyName;
+   protected final Map<String, String> securityGroupIdToNames;
+   protected final Set<? extends BlockDeviceMapping> blockDeviceMappings;
+   protected final Set<String> securityGroupIds;
+   protected final Set<String> securityGroupNames;
+   protected final Boolean monitoringEnabled;
+   protected final byte[] userData;
+   protected final Optional<IAMInstanceProfileRequest> iamInstanceProfile;
+
+   public LaunchSpecification(String instanceType, String imageId, String kernelId, String ramdiskId,
+         String availabilityZone, String subnetId, String keyName, Map<String, String> securityGroupIdToNames,
+         Iterable<? extends BlockDeviceMapping> blockDeviceMappings, Boolean monitoringEnabled,
+         Set<String> securityGroupIds, Set<String> securityGroupNames, byte[] userData,
+         Optional<IAMInstanceProfileRequest> iamInstanceProfile) {
+      this.instanceType = checkNotNull(instanceType, "instanceType");
+      this.imageId = checkNotNull(imageId, "imageId");
+      this.kernelId = kernelId;
+      this.ramdiskId = ramdiskId;
+      this.availabilityZone = availabilityZone;
+      this.subnetId = subnetId;
+      this.keyName = keyName;
+      this.securityGroupIdToNames = ImmutableMap.copyOf(checkNotNull(securityGroupIdToNames, "securityGroupIdToNames"));
+      this.blockDeviceMappings = ImmutableSortedSet.copyOf(checkNotNull(blockDeviceMappings, "blockDeviceMappings"));
+      this.securityGroupIds = ImmutableSortedSet.copyOf(checkNotNull(securityGroupIds, "securityGroupIds"));
+      this.securityGroupNames = ImmutableSortedSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
+      this.monitoringEnabled = monitoringEnabled;
+      this.userData = userData;
+      this.iamInstanceProfile = checkNotNull(iamInstanceProfile, "iamInstanceProfile");
+   }
+
+   public Map<String, String> getSecurityGroupIdToNames() {
+      return securityGroupIdToNames;
+   }
+
+   /**
+    * Image ID of the AMI used to launch the instance.
+    */
+   public String getImageId() {
+      return imageId;
+   }
+
+   /**
+    * CloudWatch support
+    */
+   public Boolean isMonitoringEnabled() {
+      return monitoringEnabled;
+   }
+
+   /**
+    * The instance type.
+    */
+   public String getInstanceType() {
+      return instanceType;
+   }
+
+   /**
+    * Optional. Kernel associated with this instance.
+    */
+   public String getKernelId() {
+      return kernelId;
+   }
+
+   /**
+    * If this instance was launched with an associated key pair, this displays
+    * the key pair name.
+    */
+   public String getKeyName() {
+      return keyName;
+   }
+
+   /**
+    * The location where the instance launched.
+    */
+   public String getAvailabilityZone() {
+      return availabilityZone;
+   }
+   
+   /**
+    * The ID of the subnet in which to launch the Spot Instance.
+    */
+   @Nullable
+   public String getSubnetId() {
+      return subnetId;
+   }
+
+   /**
+    * Optional. RAM disk associated with this instance.
+    */
+   public String getRamdiskId() {
+      return ramdiskId;
+   }
+
+   /**
+    * volumes mappings associated with the instance.
+    */
+   public Set<? extends BlockDeviceMapping> getBlockDeviceMappings() {
+      return blockDeviceMappings;
+   }
+
+   /**
+    * Names of the security groups.
+    */
+   public Set<String> getSecurityGroupNames() {
+      return securityGroupNames;
+   }
+
+   /**
+    * Ids of the security groups.
+    */
+   public Set<String> getSecurityGroupIds() {
+      return securityGroupIds;
+   }
+
+   /**
+    * User Data
+    */
+   public byte[] getUserData() {
+      return userData;
+   }
+
+   /**
+    * The IAM Instance Profile (IIP) associated with the instance.
+    */
+   @SinceApiVersion("2012-06-01")
+   public Optional<IAMInstanceProfileRequest> getIAMInstanceProfile() {
+      return iamInstanceProfile;
+   }
+
+   @Override
+   public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
+      result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
+      result = prime * result + ((blockDeviceMappings == null) ? 0 : blockDeviceMappings.hashCode());
+      result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
+      result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
+      result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode());
+      result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
+      result = prime * result + ((monitoringEnabled == null) ? 0 : monitoringEnabled.hashCode());
+      result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
+      result = prime * result + ((securityGroupIdToNames == null) ? 0 : securityGroupIdToNames.hashCode());
+      result = prime * result + ((securityGroupIds == null) ? 0 : securityGroupIds.hashCode());
+      result = prime * result + ((securityGroupNames == null) ? 0 : securityGroupNames.hashCode());
+      result = prime * result + ((!iamInstanceProfile.isPresent()) ? 0 : iamInstanceProfile.get().hashCode());
+      result = prime * result + Arrays.hashCode(userData);
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      LaunchSpecification other = (LaunchSpecification) obj;
+      if (availabilityZone == null) {
+         if (other.availabilityZone != null)
+            return false;
+      } else if (!availabilityZone.equals(other.availabilityZone))
+         return false;
+      if (subnetId == null) {
+         if (other.subnetId != null)
+            return false;
+      } else if (!subnetId.equals(other.subnetId))
+         return false;      
+      if (blockDeviceMappings == null) {
+         if (other.blockDeviceMappings != null)
+            return false;
+      } else if (!blockDeviceMappings.equals(other.blockDeviceMappings))
+         return false;
+      if (imageId == null) {
+         if (other.imageId != null)
+            return false;
+      } else if (!imageId.equals(other.imageId))
+         return false;
+      if (instanceType == null) {
+         if (other.instanceType != null)
+            return false;
+      } else if (!instanceType.equals(other.instanceType))
+         return false;
+      if (kernelId == null) {
+         if (other.kernelId != null)
+            return false;
+      } else if (!kernelId.equals(other.kernelId))
+         return false;
+      if (keyName == null) {
+         if (other.keyName != null)
+            return false;
+      } else if (!keyName.equals(other.keyName))
+         return false;
+      if (monitoringEnabled == null) {
+         if (other.monitoringEnabled != null)
+            return false;
+      } else if (!monitoringEnabled.equals(other.monitoringEnabled))
+         return false;
+      if (ramdiskId == null) {
+         if (other.ramdiskId != null)
+            return false;
+      } else if (!ramdiskId.equals(other.ramdiskId))
+         return false;
+      if (securityGroupIdToNames == null) {
+         if (other.securityGroupIdToNames != null)
+            return false;
+      } else if (!securityGroupIdToNames.equals(other.securityGroupIdToNames))
+         return false;
+      if (securityGroupIds == null) {
+         if (other.securityGroupIds != null)
+            return false;
+      } else if (!securityGroupIds.equals(other.securityGroupIds))
+         return false;
+      if (securityGroupNames == null) {
+         if (other.securityGroupNames != null)
+            return false;
+      } else if (!securityGroupNames.equals(other.securityGroupNames))
+         return false;
+      if (!iamInstanceProfile.isPresent()) {
+         if (other.iamInstanceProfile.isPresent())
+            return false;
+      } else if (!iamInstanceProfile.get().equals(other.iamInstanceProfile.orNull()))
+         return false;
+      if (!Arrays.equals(userData, other.userData))
+         return false;
+      return true;
+   }
+
+   public Builder toBuilder() {
+      return Builder.fromLaunchSpecification(this);
+   }
+
+   @Override
+   public String toString() {
+      return "[instanceType=" + instanceType + ", imageId=" + imageId + ", kernelId=" + kernelId + ", ramdiskId="
+            + ramdiskId + ", availabilityZone=" + availabilityZone + ", subnetId=" + subnetId + ", keyName=" + keyName
+            + ", securityGroupIdToNames=" + securityGroupIdToNames + ", blockDeviceMappings=" + blockDeviceMappings
+            + ", securityGroupIds=" + securityGroupIds + ", securityGroupNames=" + securityGroupNames
+            + ", monitoringEnabled=" + monitoringEnabled + ", userData=" + Arrays.toString(userData)
+            + ", iamInstanceProfile=" + iamInstanceProfile.orNull() + "]";
+   }
+
+   @SinceApiVersion("2012-06-01")
+   public static class IAMInstanceProfileRequest {
+
+      public static IAMInstanceProfileRequest forArn(String arn) {
+         return new IAMInstanceProfileRequest(Optional.of(checkNotNull(arn, "arn")), Optional.<String> absent());
+      }
+
+      public static IAMInstanceProfileRequest forName(String name) {
+         return new IAMInstanceProfileRequest(Optional.<String> absent(), Optional.of(checkNotNull(name, "name")));
+      }
+
+      public static IAMInstanceProfileRequest forArnAndName(String arn, String name) {
+         return new IAMInstanceProfileRequest(Optional.of(checkNotNull(arn, "arn")), Optional.of(checkNotNull(name, "name")));
+      }
+
+      private final Optional<String> arn;
+      private final Optional<String> name;
+
+      private IAMInstanceProfileRequest(Optional<String> arn, Optional<String> name) {
+         this.arn = checkNotNull(arn, "arn");
+         this.name = checkNotNull(name, "name for %s", arn);
+      }
+
+      /**
+       * The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instance.
+       */
+      public Optional<String> getArn() {
+         return arn;
+      }
+
+      /**
+       * The name of the IAM Instance Profile (IIP) to associate with the instance.
+       */
+      public Optional<String> getName() {
+         return name;
+      }
+
+      @Override
+      public int hashCode() {
+         return Objects.hashCode(arn, name);
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+         if (this == obj)
+            return true;
+         if (obj == null || getClass() != obj.getClass())
+            return false;
+         IAMInstanceProfileRequest that = IAMInstanceProfileRequest.class.cast(obj);
+         return equal(this.arn, that.arn) && equal(this.name, that.name);
+      }
+
+      @Override
+      public String toString() {
+         return toStringHelper("").omitNullValues().add("arn", arn.orNull()).add("name", name.orNull()).toString();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java
new file mode 100644
index 0000000..d5f4019
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * 
+ * State of monitoring for the instance.
+ * 
+ * @author Adrian Cole
+ * @see InstanceClient#runInstances
+ * @see MonitoringClient#monitorInstances
+ * @see MonitoringClient#UnmonitorInstances
+ */
+public enum MonitoringState {
+
+   PENDING, ENABLED, DISABLING, DISABLED, UNRECOGNIZED;
+
+   public String value() {
+      return name().toLowerCase();
+   }
+
+   @Override
+   public String toString() {
+      return value();
+   }
+
+   public static MonitoringState fromValue(String state) {
+      try {
+         return valueOf(checkNotNull(state, "state").toUpperCase());
+      } catch (IllegalArgumentException e) {
+         return UNRECOGNIZED;
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java
new file mode 100644
index 0000000..be38522
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A placement group is a logical grouping of instances.
+ * 
+ * <p/>
+ * You first create a cluster placement group, then launch multiple cluster compute instances into
+ * the group. Currently cluster compute instances are available only in the US-East (Northern
+ * Virginia) Region. You must give each placement group a name that is unique within your account.
+ * For more information about cluster placement groups, see Cluster Compute Instance Concepts.
+ * <p/>
+ * Note
+ * <p/>
+ * You can't merge cluster placement groups. Instead you must terminate the instances in one of the
+ * groups, and then relaunch the instances into the other group.
+ * 
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribePlacementGroups.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class PlacementGroup implements Comparable<PlacementGroup> {
+   public static enum State {
+      PENDING, AVAILABLE, DELETING, DELETED, UNRECOGNIZED;
+      public String value() {
+         return name().toLowerCase();
+      }
+
+      @Override
+      public String toString() {
+         return value();
+      }
+
+      public static State fromValue(String state) {
+         try {
+            return valueOf(checkNotNull(state, "state").toUpperCase());
+         } catch (IllegalArgumentException e) {
+            return UNRECOGNIZED;
+         }
+      }
+   }
+
+   private final String region;
+   private final String name;
+   private final String strategy;
+   private final State state;
+
+   public PlacementGroup(String region, String name, String strategy, State state) {
+      this.region = checkNotNull(region, "region");
+      this.name = checkNotNull(name, "name");
+      this.strategy = checkNotNull(strategy, "strategy");
+      this.state = checkNotNull(state, "state");
+   }
+
+   @Override
+   public int compareTo(PlacementGroup o) {
+      return name.compareTo(o.name);
+   }
+
+   /**
+    * To be removed in jclouds 1.6 <h4>Warning</h4>
+    * 
+    * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+    * alternate means to determine context.
+    */
+   @Deprecated
+   public String getRegion() {
+      return region;
+   }
+
+   /**
+    * @return Name of the placement group.
+    */
+   public String getName() {
+      return name;
+   }
+
+   /**
+    * @return The placement strategy.
+    */
+   public String getStrategy() {
+      return strategy;
+   }
+
+   /**
+    * @return Status of the placement group.
+    */
+   public State getState() {
+      return state;
+   }
+
+   @Override
+   public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((name == null) ? 0 : name.hashCode());
+      result = prime * result + ((region == null) ? 0 : region.hashCode());
+      result = prime * result + ((state == null) ? 0 : state.hashCode());
+      result = prime * result + ((strategy == null) ? 0 : strategy.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      PlacementGroup other = (PlacementGroup) obj;
+      if (name == null) {
+         if (other.name != null)
+            return false;
+      } else if (!name.equals(other.name))
+         return false;
+      if (region == null) {
+         if (other.region != null)
+            return false;
+      } else if (!region.equals(other.region))
+         return false;
+      if (state == null) {
+         if (other.state != null)
+            return false;
+      } else if (!state.equals(other.state))
+         return false;
+      if (strategy == null) {
+         if (other.strategy != null)
+            return false;
+      } else if (!strategy.equals(other.strategy))
+         return false;
+      return true;
+   }
+
+   @Override
+   public String toString() {
+      return "[name=" + name + ", region=" + region + ", state=" + state + ", strategy=" + strategy + "]";
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java
new file mode 100644
index 0000000..fdfbac9
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import org.jclouds.ec2.compute.domain.RegionAndName;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class RegionNameAndPublicKeyMaterial extends RegionAndName {
+   private final String publicKeyMaterial;
+
+   public RegionNameAndPublicKeyMaterial(String region, String tag, String publicKeyMaterial) {
+      super(region, tag);
+      this.publicKeyMaterial = publicKeyMaterial;
+   }
+
+   // intentionally not overriding equals or hash-code so that we can search only by region/tag in a
+   // map
+
+   public String getPublicKeyMaterial() {
+      return publicKeyMaterial;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
new file mode 100644
index 0000000..3a4bac6
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+
+/**
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class Spot implements Comparable<Spot> {
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   public static class Builder {
+      private String region;
+      private String instanceType;
+      private String productDescription;
+      private float spotPrice;
+      private Date timestamp;
+      private String availabilityZone;
+
+      public void clear() {
+         this.region = null;
+         this.instanceType = null;
+         this.productDescription = null;
+         this.spotPrice = 0.0f;
+         this.timestamp = null;
+         this.availabilityZone = null;
+      }
+
+      public Builder region(String region) {
+         this.region = region;
+         return this;
+      }
+
+      public Builder instanceType(String instanceType) {
+         this.instanceType = instanceType;
+         return this;
+      }
+
+      public Builder productDescription(String productDescription) {
+         this.productDescription = productDescription;
+         return this;
+      }
+
+      public Builder spotPrice(float spotPrice) {
+         this.spotPrice = spotPrice;
+         return this;
+      }
+
+      public Builder timestamp(Date timestamp) {
+         this.timestamp = timestamp;
+         return this;
+      }
+
+      public Builder availabilityZone(String availabilityZone) {
+         this.availabilityZone = availabilityZone;
+         return this;
+      }
+
+      public Spot build() {
+         return new Spot(region, instanceType, productDescription, spotPrice, timestamp, availabilityZone);
+      }
+   }
+
+   private final String region;
+   private final String instanceType;
+   private final String productDescription;
+   private final float spotPrice;
+   private final Date timestamp;
+   private final String availabilityZone;
+
+   public Spot(String region, String instanceType, String productDescription, float spotPrice, Date timestamp,
+               String availabilityZone) {
+      this.region = checkNotNull(region, "region");
+      this.instanceType = checkNotNull(instanceType, "instanceType");
+      this.productDescription = checkNotNull(productDescription, "productDescription");
+      this.spotPrice = spotPrice;
+      this.timestamp = checkNotNull(timestamp, "timestamp");
+      this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
+   }
+
+   /**
+    * To be removed in jclouds 1.6 <h4>Warning</h4>
+    * 
+    * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+    * alternate means to determine context.
+    */
+   @Deprecated
+   public String getRegion() {
+      return region;
+   }
+
+   public String getInstanceType() {
+      return instanceType;
+   }
+
+   public String getProductDescription() {
+      return productDescription;
+   }
+
+   public float getSpotPrice() {
+      return spotPrice;
+   }
+
+   public Date getTimestamp() {
+      return timestamp;
+   }
+
+   public String getAvailabilityZone() {
+      return availabilityZone;
+   }
+
+   @Override
+   public int compareTo(Spot o) {
+      return Float.compare(spotPrice, o.spotPrice);
+   }
+
+   @Override
+   public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
+      result = prime * result + ((productDescription == null) ? 0 : productDescription.hashCode());
+      result = prime * result + ((region == null) ? 0 : region.hashCode());
+      result = prime * result + Float.floatToIntBits(spotPrice);
+      result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
+      result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      Spot other = (Spot) obj;
+      if (instanceType == null) {
+         if (other.instanceType != null)
+            return false;
+      } else if (!instanceType.equals(other.instanceType))
+         return false;
+      if (productDescription == null) {
+         if (other.productDescription != null)
+            return false;
+      } else if (!productDescription.equals(other.productDescription))
+         return false;
+      if (region == null) {
+         if (other.region != null)
+            return false;
+      } else if (!region.equals(other.region))
+         return false;
+      if (Float.floatToIntBits(spotPrice) != Float.floatToIntBits(other.spotPrice))
+         return false;
+      if (timestamp == null) {
+         if (other.timestamp != null)
+            return false;
+      } else if (!timestamp.equals(other.timestamp))
+         return false;
+      if (availabilityZone == null) {
+         if (other.availabilityZone != null)
+            return false;
+      } else if (!availabilityZone.equals(other.availabilityZone)) {
+         return false;
+      }
+      return true;
+   }
+
+   @Override
+   public String toString() {
+      return "[region=" + region + ", instanceType=" + instanceType + ", productDescription=" + productDescription
+            + ", spotPrice=" + spotPrice + ", timestamp=" + timestamp + ", availabilityZone="
+              + availabilityZone + "]";
+   }
+
+}


[12/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java
new file mode 100644
index 0000000..f088bcd
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import java.util.Set;
+
+import org.jclouds.aws.ec2.compute.suppliers.AWSEC2ImageSupplier;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.ec2.compute.config.EC2BindComputeSuppliersByClass;
+
+import com.google.common.base.Supplier;
+/**
+ * @author Aled Sage
+ */
+public class AWSEC2BindComputeSuppliersByClass extends EC2BindComputeSuppliersByClass {
+   @Override
+   protected Class<? extends Supplier<Set<? extends Image>>> defineImageSupplier() {
+      return AWSEC2ImageSupplier.class;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java
new file mode 100644
index 0000000..5341d57
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateBuilderImpl;
+import org.jclouds.aws.ec2.compute.functions.AWSRunningInstanceToNodeMetadata;
+import org.jclouds.aws.ec2.compute.functions.PresentSpotRequestsAndInstances;
+import org.jclouds.aws.ec2.compute.strategy.AWSEC2CreateNodesInGroupThenAddToSet;
+import org.jclouds.aws.ec2.compute.strategy.AWSEC2DestroyNodeStrategy;
+import org.jclouds.aws.ec2.compute.strategy.AWSEC2GetNodeMetadataStrategy;
+import org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy;
+import org.jclouds.aws.ec2.compute.strategy.AWSEC2ReviseParsedImage;
+import org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions;
+import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier;
+import org.jclouds.compute.config.BaseComputeServiceContextModule;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.ec2.compute.config.EC2BindComputeStrategiesByClass;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.PresentInstances;
+import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
+import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
+import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
+import org.jclouds.ec2.compute.options.EC2TemplateOptions;
+import org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions;
+import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet;
+import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy;
+import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy;
+import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy;
+import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
+import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier;
+import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.suppliers.SetAndThrowAuthorizationExceptionSupplier;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.base.Throwables;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.Atomics;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContextModule {
+   @Override
+   protected void configure() {
+      super.configure();
+      installDependencies();
+      install(new EC2BindComputeStrategiesByClass());
+      install(new AWSEC2BindComputeSuppliersByClass());
+      bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class);
+      bind(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class).to(
+               CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class);
+      bind(EC2HardwareSupplier.class).to(AWSEC2HardwareSupplier.class);
+      bind(EC2TemplateBuilderImpl.class).to(AWSEC2TemplateBuilderImpl.class);
+      bind(EC2GetNodeMetadataStrategy.class).to(AWSEC2GetNodeMetadataStrategy.class);
+      bind(EC2ListNodesStrategy.class).to(AWSEC2ListNodesStrategy.class);
+      bind(EC2DestroyNodeStrategy.class).to(AWSEC2DestroyNodeStrategy.class);
+      bind(PresentInstances.class).to(PresentSpotRequestsAndInstances.class);
+      bind(EC2CreateNodesInGroupThenAddToSet.class).to(AWSEC2CreateNodesInGroupThenAddToSet.class);
+      bind(RunningInstanceToNodeMetadata.class).to(AWSRunningInstanceToNodeMetadata.class);
+   }
+
+   protected void installDependencies() {
+      install(new AWSEC2ComputeServiceDependenciesModule());
+   }
+   
+   @Override
+   protected boolean shouldEagerlyParseImages(Injector injector) {
+      Map<String, String> queries = injector.getInstance(Key.get(new TypeLiteral<Map<String, String>>() {
+      }, ImageQuery.class));
+      // If no queries defined, then will never lookup all images
+      return queries.size() > 0;
+   }
+
+   // duplicates EC2ComputeServiceContextModule; but that's easiest thing to do with guice; could extract to common util
+   // TODO: have a another look at this (Adrian)
+   @Override
+   protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(
+            AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
+            final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
+      final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key
+               .get(new TypeLiteral<Supplier<LoadingCache<RegionAndName, ? extends Image>>>() {
+               }));
+      return new Supplier<Set<? extends Image>>() {
+         @Override
+         public Set<? extends Image> get() {
+            return ImmutableSet.copyOf(cache.get().asMap().values());
+         }
+      };
+   }
+
+   // duplicates EC2ComputeServiceContextModule; but that's easiest thing to do with guice; could extract to common util
+   @Provides
+   @Singleton
+   protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
+            final RegionAndIdToImage delegate) {
+      return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
+         private final AtomicReference<AuthorizationException> authException = Atomics.newReference();
+
+         @Override
+         public Image load(final RegionAndName key) throws Exception {
+            // raw lookup of an image
+            Supplier<Image> rawSupplier = new Supplier<Image>() {
+               @Override public Image get() {
+                  try {
+                     return delegate.load(key);
+                  } catch (ExecutionException e) {
+                     throw Throwables.propagate(e);
+                  }
+               }
+            };
+            return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get();
+         }
+         
+      });
+   }
+
+   @Provides
+   @Singleton
+   protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
+            final RegionAndNameToImageSupplier supplier) {
+      return supplier;
+   }
+
+   /**
+    * With amazon linux 2011.09, ssh starts after package updates, which slows the boot process and
+    * runs us out of ssh retries (context property {@code "jclouds.ssh.max-retries"}).
+    * 
+    * @see <a href="http://aws.amazon.com/amazon-linux-ami/latest-release-notes/" />
+    * @see AWSEC2PropertiesBuilder#defaultProperties
+    */
+   @Override
+   protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
+      return options.as(EC2TemplateOptions.class).userData("#cloud-config\nrepo_upgrade: none\n".getBytes());
+   }
+   
+   @Override
+   protected Optional<ImageExtension> provideImageExtension(Injector i) {
+      return Optional.of(i.getInstance(ImageExtension.class));
+   }
+
+   @Override
+   protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {
+      return Optional.of(i.getInstance(SecurityGroupExtension.class));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java
new file mode 100644
index 0000000..466deb1
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.compute.AWSEC2ComputeService;
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.aws.ec2.compute.extensions.AWSEC2SecurityGroupExtension;
+import org.jclouds.aws.ec2.compute.functions.AWSEC2SecurityGroupToSecurityGroup;
+import org.jclouds.aws.ec2.compute.loaders.AWSEC2CreateSecurityGroupIfNeeded;
+import org.jclouds.aws.ec2.compute.suppliers.CallForImages;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial;
+import org.jclouds.aws.ec2.functions.CreatePlacementGroupIfNeeded;
+import org.jclouds.aws.ec2.functions.ImportOrReturnExistingKeypair;
+import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable;
+import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule;
+import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.extensions.EC2ImageExtension;
+import org.jclouds.ec2.compute.functions.CreateUniqueKeyPair;
+import org.jclouds.ec2.compute.functions.CredentialsForInstance;
+import org.jclouds.ec2.compute.functions.EC2ImageParser;
+import org.jclouds.ec2.compute.functions.EC2SecurityGroupIdFromName;
+import org.jclouds.ec2.compute.functions.PasswordCredentialsFromWindowsInstance;
+import org.jclouds.ec2.compute.functions.WindowsLoginCredentialsFromEncryptedData;
+import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
+import org.jclouds.ec2.compute.loaders.LoadPublicIpForInstanceOrNull;
+import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.domain.RunningInstance;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Sets;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.name.Names;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDependenciesModule {
+   @Override
+   protected void configure() {
+      bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
+      bind(TemplateOptions.class).to(AWSEC2TemplateOptions.class);
+      bind(ComputeService.class).to(AWSEC2ComputeService.class);
+      bind(new TypeLiteral<CacheLoader<RunningInstance, Optional<LoginCredentials>>>() {
+      }).to(CredentialsForInstance.class);
+      bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
+      }).annotatedWith(Names.named("SECURITY")).to(AWSEC2CreateSecurityGroupIfNeeded.class);
+      bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
+      }).annotatedWith(Names.named("ELASTICIP")).to(LoadPublicIpForInstanceOrNull.class);
+      bind(new TypeLiteral<Function<String, String>>() {
+      }).annotatedWith(Names.named("SECGROUP_NAME_TO_ID")).to(EC2SecurityGroupIdFromName.class);
+      bind(new TypeLiteral<Function<PasswordDataAndPrivateKey, LoginCredentials>>() {
+      }).to(WindowsLoginCredentialsFromEncryptedData.class);
+      bind(new TypeLiteral<Function<RunningInstance, LoginCredentials>>() {
+      }).to(PasswordCredentialsFromWindowsInstance.class);
+      bind(new TypeLiteral<Function<RegionAndName, KeyPair>>() {
+      }).to(CreateUniqueKeyPair.class);
+      bind(new TypeLiteral<Function<RegionNameAndPublicKeyMaterial, KeyPair>>() {
+      }).to(ImportOrReturnExistingKeypair.class);
+      bind(new TypeLiteral<CacheLoader<RegionAndName, Image>>() {
+      }).to(RegionAndIdToImage.class);
+      install(new FactoryModuleBuilder().build(CallForImages.Factory.class));
+      bind(new TypeLiteral<Function<org.jclouds.ec2.domain.Image, Image>>() {
+      }).to(EC2ImageParser.class);
+      bind(new TypeLiteral<Function<org.jclouds.ec2.domain.SecurityGroup, SecurityGroup>>() {
+      }).to(AWSEC2SecurityGroupToSecurityGroup.class);
+      bind(new TypeLiteral<ImageExtension>() {
+      }).to(EC2ImageExtension.class);
+      bind(new TypeLiteral<SecurityGroupExtension>() {
+      }).to(AWSEC2SecurityGroupExtension.class);
+   }
+
+   @Provides
+   @Singleton
+   @ImageQuery
+   protected Map<String, String> imageQuery(ValueOfConfigurationKeyOrNull config) {
+      String amiQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_AMI_QUERY));
+      String owners = config.apply(PROPERTY_EC2_AMI_OWNERS);
+      if ("".equals(owners)) {
+         amiQuery = null;
+      } else if (owners != null) {
+         StringBuilder query = new StringBuilder();
+         if ("*".equals(owners))
+            query.append("state=available;image-type=machine");
+         else
+            query.append("owner-id=").append(owners).append(";state=available;image-type=machine");
+         Logger.getAnonymousLogger().warning(
+               String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS,
+                     PROPERTY_EC2_AMI_QUERY, query.toString()));
+         amiQuery = query.toString();
+      }
+      Builder<String, String> builder = ImmutableMap.<String, String> builder();
+      if (amiQuery != null)
+         builder.put(PROPERTY_EC2_AMI_QUERY, amiQuery);
+      String ccQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_CC_AMI_QUERY));
+      if (ccQuery != null)
+         builder.put(PROPERTY_EC2_CC_AMI_QUERY, ccQuery);
+      return builder.build();
+   }
+
+   @Provides
+   @Singleton
+   @Named("AVAILABLE")
+   protected Predicate<PlacementGroup> placementGroupAvailable(PlacementGroupAvailable available) {
+      return retry(available, 60, 1, SECONDS);
+   }
+
+   @Provides
+   @Singleton
+   @Named("DELETED")
+   protected Predicate<PlacementGroup> placementGroupDeleted(PlacementGroupDeleted deleted) {
+      return retry(deleted, 60, 1, SECONDS);
+   }
+
+   @Provides
+   @Singleton
+   @Named("PLACEMENT")
+   protected LoadingCache<RegionAndName, String> placementGroupMap(CreatePlacementGroupIfNeeded in) {
+      return CacheBuilder.newBuilder().build(in);
+   }
+
+   @Provides
+   @ClusterCompute
+   @Singleton
+   protected Set<String> provideClusterComputeIds() {
+      return Sets.newLinkedHashSet();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java
new file mode 100644
index 0000000..1cfabb1
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a ClusterCompute resource.
+ * 
+ * @author Adrian Cole
+ * 
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface ClusterCompute {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java
new file mode 100644
index 0000000..2bfedf4
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to an Image Query
+ * 
+ * @author Adrian Cole
+ * 
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface ImageQuery {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
new file mode 100644
index 0000000..3b04335
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.extensions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Iterables.transform;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.Constants;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Location;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
+import org.jclouds.ec2.compute.extensions.EC2SecurityGroupExtension;
+import org.jclouds.location.Region;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * An extension to compute service to allow for the manipulation of {@link SecurityGroup}s. Implementation
+ * is optional by providers.
+ * 
+ * @author Andrew Bayer
+ */
+public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
+   protected final AWSEC2Api client;
+   protected final Function<String, String> groupNameToId;
+
+   @Inject
+   public AWSEC2SecurityGroupExtension(AWSEC2Api client,
+                                       @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+                                       @Region Supplier<Set<String>> regions,
+                                       Function<org.jclouds.ec2.domain.SecurityGroup, SecurityGroup> groupConverter,
+                                       @Memoized Supplier<Set<? extends Location>> locations,
+                                       @Named("SECURITY") LoadingCache<RegionAndName, String> groupCreator,
+                                       GroupNamingConvention.Factory namingConvention,
+                                       @Named("SECGROUP_NAME_TO_ID") Function<String, String> groupNameToId) {
+      super(client, userExecutor, regions, groupConverter, locations, groupCreator, namingConvention);
+      this.client = checkNotNull(client, "client");
+      this.groupNameToId = checkNotNull(groupNameToId, "groupNameToId");
+   }
+
+   @Override
+   public SecurityGroup createSecurityGroup(String name, String region) {
+      String markerGroup = namingConvention.create().sharedNameForGroup(name);
+      RegionNameAndIngressRules regionAndName = new RegionNameAndIngressRules(region, markerGroup, new int[] {},
+              false);
+
+      groupCreator.getUnchecked(regionAndName);
+      String groupId = groupNameToId.apply(markerGroup);
+      return getSecurityGroupById(regionAndName.getRegion() + "/" + groupId);
+   }
+
+   @Override
+   public SecurityGroup getSecurityGroupById(String id) {
+      checkNotNull(id, "id");
+      String[] parts = AWSUtils.parseHandle(id);
+      String region = parts[0];
+      String groupId = parts[1];
+
+      Set<? extends org.jclouds.ec2.domain.SecurityGroup> rawGroups =
+              client.getSecurityGroupApi().get().describeSecurityGroupsInRegionById(region, groupId);
+
+      return getOnlyElement(transform(filter(rawGroups, notNull()), groupConverter));
+   }
+
+   @Override
+   public boolean removeSecurityGroup(String id) {
+      checkNotNull(id, "id");
+      String[] parts = AWSUtils.parseHandle(id);
+      String region = parts[0];
+      String groupId = parts[1];
+
+      org.jclouds.ec2.domain.SecurityGroup group = Iterables.getFirst(
+              client.getSecurityGroupApi().get().describeSecurityGroupsInRegionById(region, groupId),
+              null);
+
+      if (group != null) {
+         client.getSecurityGroupApi().get().deleteSecurityGroupInRegionById(region, groupId);
+         // TODO: test this clear happens
+         groupCreator.invalidate(new RegionNameAndIngressRules(region, group.getName(), null, false));
+         return true;
+      }
+
+      return false;
+   }
+
+   @Override
+   public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
+      String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
+      String id = group.getProviderId();
+
+      client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, id, ipPermission);
+
+      return getSecurityGroupById(group.getId());
+   }
+
+   @Override
+   public SecurityGroup addIpPermission(IpProtocol protocol, int startPort, int endPort,
+                                        Multimap<String, String> tenantIdGroupNamePairs,
+                                        Iterable<String> ipRanges,
+                                        Iterable<String> groupIds, SecurityGroup group) {
+      String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
+      String id = group.getProviderId();
+
+      IpPermission.Builder builder = IpPermission.builder();
+
+      builder.ipProtocol(protocol);
+      builder.fromPort(startPort);
+      builder.toPort(endPort);
+      
+      if (Iterables.size(ipRanges) > 0) {
+         for (String cidr : ipRanges) {
+            builder.cidrBlock(cidr);
+         }
+      }
+
+      if (tenantIdGroupNamePairs.size() > 0) {
+         for (String userId : tenantIdGroupNamePairs.keySet()) {
+            for (String groupString : tenantIdGroupNamePairs.get(userId)) {
+               String[] parts = AWSUtils.parseHandle(groupString);
+               String groupId = parts[1];
+               builder.tenantIdGroupNamePair(userId, groupId);
+            }
+         }
+      }
+
+      client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, id, builder.build());
+
+      return getSecurityGroupById(group.getId());
+   }
+      
+   @Override
+   public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
+      String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
+      String id = group.getProviderId();
+
+      client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, id, ipPermission);
+
+      return getSecurityGroupById(group.getId());
+   }
+
+   @Override
+   public SecurityGroup removeIpPermission(IpProtocol protocol, int startPort, int endPort,
+                                           Multimap<String, String> tenantIdGroupNamePairs,
+                                           Iterable<String> ipRanges,
+                                           Iterable<String> groupIds, SecurityGroup group) {
+      String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
+      String id = group.getProviderId();
+
+      IpPermission.Builder builder = IpPermission.builder();
+
+      builder.ipProtocol(protocol);
+      builder.fromPort(startPort);
+      builder.toPort(endPort);
+      
+      if (Iterables.size(ipRanges) > 0) {
+         for (String cidr : ipRanges) {
+            builder.cidrBlock(cidr);
+         }
+      }
+
+      if (tenantIdGroupNamePairs.size() > 0) {
+         for (String userId : tenantIdGroupNamePairs.keySet()) {
+            for (String groupString : tenantIdGroupNamePairs.get(userId)) {
+               String[] parts = AWSUtils.parseHandle(groupString);
+               String groupId = parts[1];
+               builder.tenantIdGroupNamePair(userId, groupId);
+            }
+         }
+      }
+
+      client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, id, builder.build());
+
+      return getSecurityGroupById(group.getId());
+   }
+
+   @Override
+   public boolean supportsTenantIdGroupNamePairs() {
+      return false;
+   }
+
+   @Override
+   public boolean supportsTenantIdGroupIdPairs() {
+      return true;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java
new file mode 100644
index 0000000..b0c3cd3
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.ec2.compute.functions.EC2SecurityGroupToSecurityGroup;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+
+/**
+ * A function for transforming an EC2-specific SecurityGroup into a generic
+ * SecurityGroup object.
+ * 
+ * @author Andrew Bayer
+ */
+@Singleton
+public class AWSEC2SecurityGroupToSecurityGroup extends EC2SecurityGroupToSecurityGroup {
+
+   @Inject
+   public AWSEC2SecurityGroupToSecurityGroup(@Memoized Supplier<Set<? extends Location>> locations) {
+      super(locations);
+   }
+
+   @Override
+   protected String idOrName(org.jclouds.ec2.domain.SecurityGroup group) {
+      return group.getId();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java
new file mode 100644
index 0000000..efbb07b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.RunningInstance;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetadata {
+
+   @Inject
+   protected AWSRunningInstanceToNodeMetadata(Map<InstanceState, Status> instanceToNodeStatus,
+         Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
+         @Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware,
+         GroupNamingConvention.Factory namingConvention) {
+      super(instanceToNodeStatus, credentialStore, imageMap, locations, hardware, namingConvention);
+   }
+
+   @Override
+   protected void addCredentialsForInstance(NodeMetadataBuilder builder, RunningInstance instance) {
+      LoginCredentials creds = LoginCredentials.fromCredentials(credentialStore.get("node#" + instance.getRegion()
+            + "/" + instance.getId()));
+      String spotRequestId = AWSRunningInstance.class.cast(instance).getSpotInstanceRequestId();
+      if (creds == null && spotRequestId != null) {
+         creds = LoginCredentials.fromCredentials(credentialStore.get("node#" + instance.getRegion() + "/"
+               + spotRequestId));
+         if (creds != null)
+            credentialStore.put("node#" + instance.getRegion() + "/" + instance.getId(), creds);
+      }
+      if (creds != null)
+         builder.credentials(creds);
+   }
+   
+   protected Hardware parseHardware(RunningInstance instance) {
+      Hardware in = super.parseHardware(instance);
+      if (in == null)
+         return null;
+      AWSRunningInstance awsInstance = AWSRunningInstance.class.cast(instance);
+      return HardwareBuilder.fromHardware(in).hypervisor(awsInstance.getHypervisor().toString()).build();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
new file mode 100644
index 0000000..f754a57
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.compose;
+import static com.google.common.base.Predicates.containsPattern;
+import static com.google.common.collect.Iterables.any;
+import static com.google.common.collect.Iterables.toArray;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Multimaps.index;
+import static com.google.common.collect.Multimaps.transformValues;
+import static org.jclouds.ec2.compute.domain.RegionAndName.nameFunction;
+import static org.jclouds.ec2.compute.domain.RegionAndName.regionFunction;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.PresentInstances;
+import org.jclouds.ec2.domain.RunningInstance;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import com.google.common.collect.Multimap;
+import com.google.inject.Inject;
+
+/**
+ * returns either the instances present in the list, or spot instances, if they ids start with {@code sir-}. Makes a
+ * single rest call per aggregate on region.
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class PresentSpotRequestsAndInstances extends PresentInstances {
+
+   private final AWSEC2Api client;
+   private final Function<SpotInstanceRequest, AWSRunningInstance> spotConverter;
+
+   @Inject
+   public PresentSpotRequestsAndInstances(AWSEC2Api client, Function<SpotInstanceRequest, AWSRunningInstance> spotConverter) {
+      super(client);
+      this.client = checkNotNull(client, "client");
+      this.spotConverter = checkNotNull(spotConverter, "spotConverter");
+   }
+
+   @Override
+   public Set<RunningInstance> apply(Set<RegionAndName> regionAndIds) {
+      if (checkNotNull(regionAndIds, "regionAndIds").isEmpty())
+         return ImmutableSet.of();
+      if (any(regionAndIds, compose(containsPattern("sir-"), nameFunction())))
+         return getSpots(regionAndIds);
+      return super.apply(regionAndIds);
+   }
+
+   protected Set<RunningInstance> getSpots(Set<RegionAndName> regionAndIds) {
+      Builder<RunningInstance> builder = ImmutableSet.<RunningInstance> builder();
+      Multimap<String, String> regionToSpotIds = transformValues(index(regionAndIds, regionFunction()), nameFunction());
+      for (Map.Entry<String, Collection<String>> entry : regionToSpotIds.asMap().entrySet()) {
+         String region = entry.getKey();
+         Collection<String> spotIds = entry.getValue();
+         logger.trace("looking for spots %s in region %s", spotIds, region);
+         builder.addAll(transform(
+                                  client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(region,
+                     toArray(spotIds, String.class)), spotConverter));
+      }
+      return builder.build();
+   }
+
+   @Override
+   public String toString() {
+      return "presentSpotRequestsAndInstances()";
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java
new file mode 100644
index 0000000..4055cda
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.internal;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.Context;
+import org.jclouds.aws.ec2.compute.AWSEC2ComputeService;
+import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext;
+import org.jclouds.compute.Utils;
+import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl;
+import org.jclouds.location.Provider;
+
+import com.google.common.reflect.TypeToken;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements
+         AWSEC2ComputeServiceContext {
+   @Inject
+   public AWSEC2ComputeServiceContextImpl(@Provider Context backend,
+            @Provider TypeToken<? extends Context> backendType, AWSEC2ComputeService computeService, Utils utils) {
+      super(backend, backendType, computeService, utils);
+   }
+
+   @Override
+   public AWSEC2ComputeService getComputeService() {
+      return AWSEC2ComputeService.class.cast(super.getComputeService());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
new file mode 100644
index 0000000..a9c1391
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.loaders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.compute.util.ComputeServiceUtils.getPortRangesFromList;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.cache.CacheLoader;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * 
+ * @author Adrian Cole
+ * @author Andrew Bayer
+ */
+@Singleton
+public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader<RegionAndName, String> {
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+   protected final AWSSecurityGroupApi securityApi;
+   protected final Predicate<RegionAndName> securityGroupEventualConsistencyDelay;
+   protected final Function<String, String> groupNameToId;
+   @Inject
+   public AWSEC2CreateSecurityGroupIfNeeded(AWSEC2Api ec2Api,
+                                            @Named("SECGROUP_NAME_TO_ID") Function<String, String> groupNameToId,
+                                            @Named("SECURITY") Predicate<RegionAndName> securityGroupEventualConsistencyDelay) {
+      this(checkNotNull(ec2Api, "ec2Api").getSecurityGroupApi().get(), groupNameToId, securityGroupEventualConsistencyDelay);
+   }
+
+   public AWSEC2CreateSecurityGroupIfNeeded(AWSSecurityGroupApi securityApi,
+                                            @Named("SECGROUP_NAME_TO_ID") Function<String, String> groupNameToId,
+                                            @Named("SECURITY") Predicate<RegionAndName> securityGroupEventualConsistencyDelay) {
+      this.securityApi = checkNotNull(securityApi, "securityApi");
+      this.groupNameToId = checkNotNull(groupNameToId, "groupNameToId");
+      this.securityGroupEventualConsistencyDelay = checkNotNull(securityGroupEventualConsistencyDelay,
+            "securityGroupEventualConsistencyDelay");
+   }
+
+   @Override
+   public String load(RegionAndName from) {
+      RegionNameAndIngressRules realFrom = RegionNameAndIngressRules.class.cast(from);
+      createSecurityGroupInRegion(from.getRegion(), from.getName(), realFrom.getPorts());
+      return from.getName();
+   }
+
+   private void createSecurityGroupInRegion(String region, String name, int... ports) {
+      checkNotNull(region, "region");
+      checkNotNull(name, "name");
+      logger.debug(">> creating securityGroup region(%s) name(%s)", region, name);
+
+      try {
+         securityApi.createSecurityGroupInRegion(region, name, name);
+         boolean created = securityGroupEventualConsistencyDelay.apply(new RegionAndName(region, name));
+         if (!created)
+            throw new RuntimeException(String.format("security group %s/%s is not available after creating", region,
+                  name));
+         logger.debug("<< created securityGroup(%s)", name);
+
+         ImmutableSet.Builder<IpPermission> permissions = ImmutableSet.builder();
+         String id;
+         if (name.startsWith("sg-")) {
+            id = name;
+         } else {
+            id = groupNameToId.apply(new RegionAndName(region, name).slashEncode());
+         }
+
+         if (ports.length > 0) {
+            for (Map.Entry<Integer, Integer> range : getPortRangesFromList(ports).entrySet()) {
+               permissions.add(IpPermission.builder()
+                               .fromPort(range.getKey())
+                               .toPort(range.getValue())
+                               .ipProtocol(IpProtocol.TCP)
+                               .cidrBlock("0.0.0.0/0")
+                               .build());
+            }
+
+            String myOwnerId = Iterables.get(securityApi.describeSecurityGroupsInRegion(region, name), 0).getOwnerId();
+            permissions.add(IpPermission.builder()
+                            .fromPort(0)
+                            .toPort(65535)
+                            .ipProtocol(IpProtocol.TCP)
+                            .tenantIdGroupNamePair(myOwnerId, id)
+                            .build());
+            permissions.add(IpPermission.builder()
+                            .fromPort(0)
+                            .toPort(65535)
+                            .ipProtocol(IpProtocol.UDP)
+                            .tenantIdGroupNamePair(myOwnerId, id)
+                            .build());
+         }
+
+         Set<IpPermission> perms = permissions.build();
+
+         if (perms.size() > 0) {
+            logger.debug(">> authorizing securityGroup region(%s) name(%s) IpPermissions(%s)", region, name, perms);
+            securityApi.authorizeSecurityGroupIngressInRegion(region, id, perms);
+            logger.debug("<< authorized securityGroup(%s)", name);
+         }            
+
+      } catch (IllegalStateException e) {
+         logger.debug("<< reused securityGroup(%s)", name);
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
new file mode 100644
index 0000000..5faaba6
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.aws.ec2.compute.functions.PresentSpotRequestsAndInstances;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.util.ComputeUtils;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.logging.Logger;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupThenAddToSet {
+
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   private Logger logger = Logger.NULL;
+
+   @VisibleForTesting
+   private final AWSEC2Api client;
+   private final SpotInstanceRequestToAWSRunningInstance spotConverter;
+
+   @Inject
+   protected AWSEC2CreateNodesInGroupThenAddToSet(
+         AWSEC2Api client,
+         @Named("ELASTICIP") LoadingCache<RegionAndName, String> elasticIpCache,
+         @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
+         @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
+         CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
+         PresentSpotRequestsAndInstances instancePresent,
+         Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
+         LoadingCache<RunningInstance, Optional<LoginCredentials>> instanceToCredentials,
+         Map<String, Credentials> credentialStore, ComputeUtils utils,
+         SpotInstanceRequestToAWSRunningInstance spotConverter) {
+      super(client, elasticIpCache, nodeRunning, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
+            instancePresent, runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils);
+      this.client = checkNotNull(client, "client");
+      this.spotConverter = checkNotNull(spotConverter, "spotConverter");
+   }
+
+   @Override
+   protected Set<RunningInstance> createNodesInRegionAndZone(String region, String zone, String group,
+            int count, Template template, RunInstancesOptions instanceOptions) {
+      Float spotPrice = getSpotPriceOrNull(template.getOptions());
+      if (spotPrice != null) {
+         AWSEC2TemplateOptions awsOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
+         LaunchSpecification spec = AWSRunInstancesOptions.class.cast(instanceOptions).getLaunchSpecificationBuilder()
+               .imageId(template.getImage().getProviderId()).availabilityZone(zone).subnetId(awsOptions.getSubnetId())
+               .iamInstanceProfileArn(awsOptions.getIAMInstanceProfileArn())
+               .iamInstanceProfileName(awsOptions.getIAMInstanceProfileName()).build();
+         RequestSpotInstancesOptions options = awsOptions.getSpotOptions();
+         if (logger.isDebugEnabled())
+            logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region,
+                     spotPrice, spec, options);
+         return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceApi().get()
+               .requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter));
+      }
+      return super.createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions);
+   }
+   
+   private Float getSpotPriceOrNull(TemplateOptions options) {
+      return options instanceof AWSEC2TemplateOptions ? AWSEC2TemplateOptions.class.cast(options).getSpotPrice() : null;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
new file mode 100644
index 0000000..ee7b03b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.getOnlyElement;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
+import org.jclouds.domain.Credentials;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy;
+
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Iterables;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy {
+
+   protected final AWSEC2Api client;
+   protected final Map<String, Credentials> credentialStore;
+
+   @Inject
+   protected AWSEC2DestroyNodeStrategy(AWSEC2Api client, GetNodeMetadataStrategy getNode,
+            @Named("ELASTICIP") LoadingCache<RegionAndName, String> elasticIpCache,
+            Map<String, Credentials> credentialStore) {
+      super(client, getNode, elasticIpCache);
+      this.client = checkNotNull(client, "client");
+      this.credentialStore = checkNotNull(credentialStore, "credentialStore");
+   }
+
+   @Override
+   protected void destroyInstanceInRegion(String id, String region) {
+      String spotId = id;
+      if (id.indexOf("sir-") != 0) {
+         try {
+            spotId = getOnlyElement(
+                                    Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, id)))
+                     .getSpotInstanceRequestId();
+            credentialStore.remove("node#" + region + "/" + spotId);
+         } catch (NoSuchElementException e) {
+         }
+         super.destroyInstanceInRegion(id, region);
+      } else {
+         client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, spotId);
+         credentialStore.remove("node#" + region + "/" + id);
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
new file mode 100644
index 0000000..ffc2e0b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.getOnlyElement;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy;
+import org.jclouds.ec2.domain.RunningInstance;
+
+import com.google.common.base.Function;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy {
+
+   private final AWSEC2Api client;
+   private final SpotInstanceRequestToAWSRunningInstance spotConverter;
+
+   @Inject
+   protected AWSEC2GetNodeMetadataStrategy(AWSEC2Api client,
+            Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
+            SpotInstanceRequestToAWSRunningInstance spotConverter) {
+      super(client, runningInstanceToNodeMetadata);
+      this.client = checkNotNull(client, "client");
+      this.spotConverter = checkNotNull(spotConverter, "spotConverter");
+   }
+
+   @Override
+   public RunningInstance getRunningInstanceInRegion(String region, String id) {
+      if (id.indexOf("sir-") != 0)
+         return super.getRunningInstanceInRegion(region, id);
+      SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
+               region, id));
+      if (spot.getState() == SpotInstanceRequest.State.ACTIVE)
+         return super.getRunningInstanceInRegion(region, spot.getInstanceId());
+      else
+         return spotConverter.apply(spot);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
new file mode 100644
index 0000000..81a7382
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.toArray;
+import static com.google.common.collect.Iterables.transform;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
+
+   protected final AWSEC2Api client;
+   protected final SpotInstanceRequestToAWSRunningInstance spotConverter;
+
+   @Inject
+   protected AWSEC2ListNodesStrategy(AWSEC2Api client, @Region Supplier<Set<String>> regions,
+            Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
+            @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+            SpotInstanceRequestToAWSRunningInstance spotConverter) {
+      super(client, regions, runningInstanceToNodeMetadata, userExecutor);
+      this.client = checkNotNull(client, "client");
+      this.spotConverter = checkNotNull(spotConverter, "spotConverter");
+   }
+
+   @Override
+   protected Iterable<? extends RunningInstance> pollRunningInstances() {
+      Iterable<? extends AWSRunningInstance> spots = filter(transform(concat(transform(regions.get(),
+                                                                                       allSpotInstancesInRegion())),
+                                                                      spotConverter), notNull());
+
+      return concat(super.pollRunningInstances(), spots);
+   }
+
+   @Override
+   protected Iterable<? extends RunningInstance> pollRunningInstancesByRegionsAndIds(final Multimap<String,String> idsByRegions) {
+      Iterable<? extends AWSRunningInstance> spots = filter(transform(concat(transform(idsByRegions.keySet(),
+                                                                                       spotInstancesByIdInRegion(idsByRegions))),
+
+                                                                      spotConverter), notNull());
+      Iterable<? extends RunningInstance> superInsts = super.pollRunningInstancesByRegionsAndIds(idsByRegions);
+      return concat(superInsts, spots);
+   }
+
+   protected Function<String, Set<SpotInstanceRequest>> allSpotInstancesInRegion() {
+      return new Function<String, Set<SpotInstanceRequest>>() {
+
+         @Override
+         public Set<SpotInstanceRequest> apply(String from) {
+            return client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(from);
+         }
+      };
+   }
+
+   protected Function<String, Set<SpotInstanceRequest>> spotInstancesByIdInRegion(final Multimap<String,String> idsByRegions) {
+      return new Function<String, Set<SpotInstanceRequest>>() {
+
+         @Override
+         public Set<SpotInstanceRequest> apply(String from) {
+            return client.getSpotInstanceApi().get()
+               .describeSpotInstanceRequestsInRegion(from, toArray(idsByRegions.get(from), String.class));
+         }
+      };
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java
new file mode 100644
index 0000000..521aa95
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.util.ComputeServiceUtils;
+import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
+import org.jclouds.logging.Logger;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2ReviseParsedImage implements ReviseParsedImage {
+
+   // 137112412989/amzn-ami-0.9.7-beta.i386-ebs
+   // 137112412989/amzn-ami-0.9.7-beta.x86_64-ebs
+   // amzn-ami-us-east-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml
+   // amzn-ami-us-east-1/amzn-ami-0.9.7-beta.i386.manifest.xml
+   public static final Pattern AMZN_PATTERN = Pattern
+            .compile(".*/(amzn-hvm-|amzn-)?ami-(.*)\\.(i386|x86_64)(-ebs|\\.manifest.xml)?");
+
+   // amazon/EC2 CentOS 5.4 HVM AMI
+   public static final Pattern AMAZON_PATTERN = Pattern.compile("amazon/EC2 ([^ ]+) ([^ ]+).*");
+
+   // amazon/Windows_Server-2008-R2_SP1-English-64Bit-Base-2012.03.13
+   //        1111111        22222222222                    3333333333
+   public static final Pattern AMAZON_WINDOWS_PATTERN = Pattern.compile(".*/(Windows)_Server-([^-]*-[^-]*)-.*-([^-]*)(\\.manifest.xml)?");
+
+   public static final Pattern CANONICAL_PATTERN = Pattern.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
+
+   // ex rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml
+   public static final Pattern RIGHTSCALE_PATTERN = Pattern
+            .compile("[^/]*/([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
+
+   // ex 411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha
+   // 411009282317/RightImage_Windows_2008_x64_v5.5.5
+   public static final Pattern RIGHTIMAGE_PATTERN = Pattern
+            .compile("[^/]*/RightImage[_ ]([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
+   private final Map<OsFamily, Map<String, String>> osVersionMap;
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   @Inject
+   public AWSEC2ReviseParsedImage(Map<OsFamily, Map<String, String>> osVersionMap) {
+      this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
+   }
+
+   @Override
+   public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
+            OperatingSystem.Builder osBuilder) {
+      try {
+         Matcher matcher = getMatcherAndFind(from.getImageLocation());
+         if (matcher.pattern() == AMZN_PATTERN) {
+            osBuilder.family(OsFamily.AMZN_LINUX);
+            osBuilder.version(matcher.group(2));
+            builder.version(matcher.group(2));
+         } else if (matcher.pattern() == AMAZON_PATTERN) {
+            family = OsFamily.fromValue(matcher.group(1));
+            osBuilder.family(family);
+            osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2),
+                     osVersionMap));
+         } else {
+            family = OsFamily.fromValue(matcher.group(1));
+            osBuilder.family(family);
+            osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2),
+                     osVersionMap));
+            builder.version(matcher.group(3).replace(".manifest.xml", ""));
+         }
+      } catch (IllegalArgumentException e) {
+         logger.debug("<< didn't match os(%s)", from.getImageLocation());
+      } catch (NoSuchElementException e) {
+         logger.trace("<< didn't match at all(%s)", from.getImageLocation());
+      }
+   }
+
+   /**
+    * 
+    * @throws NoSuchElementException
+    *            if no configured matcher matches the manifest.
+    */
+   private Matcher getMatcherAndFind(String manifest) {
+      for (Pattern pattern : new Pattern[] { AMZN_PATTERN, AMAZON_PATTERN, AMAZON_WINDOWS_PATTERN, CANONICAL_PATTERN,
+              RIGHTIMAGE_PATTERN, RIGHTSCALE_PATTERN }) {
+         Matcher matcher = pattern.matcher(manifest);
+         if (matcher.find())
+            return matcher;
+      }
+      throw new NoSuchElementException(manifest);
+   }
+}


[10/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java
new file mode 100644
index 0000000..27b4565
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java
@@ -0,0 +1,474 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.CaseFormat;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   public static class Builder {
+      private String region;
+      private String availabilityZoneGroup;
+      private String launchedAvailabilityZone;
+      private Date createTime;
+      private String faultCode;
+      private String faultMessage;
+      private String instanceId;
+      private String launchGroup;
+      private LaunchSpecification launchSpecification;
+      private String productDescription;
+      private String id;
+      private float spotPrice;
+      private State state;
+      private String rawState;
+      private Type type;
+      private Date validFrom;
+      private Date validUntil;
+      private Map<String, String> tags = Maps.newLinkedHashMap();
+
+      public Builder clear() {
+         this.region = null;
+         this.availabilityZoneGroup = null;
+         this.launchedAvailabilityZone = null;
+         this.createTime = null;
+         this.faultCode = null;
+         this.faultMessage = null;
+         this.instanceId = null;
+         this.launchGroup = null;
+         this.launchSpecification = null;
+         this.productDescription = null;
+         this.id = null;
+         this.spotPrice = 0;
+         this.state = null;
+         this.rawState = null;
+         this.type = null;
+         this.validFrom = null;
+         this.validUntil = null;
+         tags = Maps.newLinkedHashMap();
+         return this;
+      }
+
+      public Builder region(String region) {
+         this.region = region;
+         return this;
+      }
+
+      public Builder tags(Map<String, String> tags) {
+         this.tags = ImmutableMap.copyOf(checkNotNull(tags, "tags"));
+         return this;
+      }
+
+      public Builder tag(String key, String value) {
+         if (key != null)
+            this.tags.put(key, Strings.nullToEmpty(value));
+         return this;
+      }
+      public Builder availabilityZoneGroup(String availabilityZoneGroup) {
+         this.availabilityZoneGroup = availabilityZoneGroup;
+         return this;
+      }
+
+      public Builder launchedAvailabilityZone(String launchedAvailabilityZone) {
+         this.launchedAvailabilityZone = launchedAvailabilityZone;
+         return this;
+      }
+
+      public Builder createTime(Date createTime) {
+         this.createTime = createTime;
+         return this;
+      }
+
+      public Builder faultCode(String faultCode) {
+         this.faultCode = faultCode;
+         return this;
+      }
+
+      public Builder faultMessage(String faultMessage) {
+         this.faultMessage = faultMessage;
+         return this;
+      }
+
+      public Builder instanceId(String instanceId) {
+         this.instanceId = instanceId;
+         return this;
+      }
+
+      public Builder launchGroup(String launchGroup) {
+         this.launchGroup = launchGroup;
+         return this;
+      }
+
+      public Builder launchSpecification(LaunchSpecification launchSpecification) {
+         this.launchSpecification = launchSpecification;
+         return this;
+      }
+
+      public Builder productDescription(String productDescription) {
+         this.productDescription = productDescription;
+         return this;
+      }
+
+      public Builder id(String id) {
+         this.id = id;
+         return this;
+      }
+
+      public Builder spotPrice(float spotPrice) {
+         this.spotPrice = spotPrice;
+         return this;
+      }
+
+      public Builder state(State state) {
+         this.state = state;
+         return this;
+      }
+      
+      public Builder rawState(String rawState) {
+         this.rawState = rawState;
+         return this;
+      }
+      
+      public Builder type(Type type) {
+         this.type = type;
+         return this;
+      }
+
+      public Builder validFrom(Date validFrom) {
+         this.validFrom = validFrom;
+         return this;
+      }
+
+      public Builder validUntil(Date validUntil) {
+         this.validUntil = validUntil;
+         return this;
+      }
+
+      public SpotInstanceRequest build() {
+         return new SpotInstanceRequest(region, availabilityZoneGroup, launchedAvailabilityZone, createTime, faultCode,
+                  faultMessage, instanceId, launchGroup, launchSpecification, productDescription, id, spotPrice, state,
+                  rawState, type, validFrom, validUntil, tags);
+      }
+   }
+
+   public enum Type {
+      ONE_TIME, PERSISTENT, UNRECOGNIZED;
+
+      public String value() {
+         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
+      }
+
+      @Override
+      public String toString() {
+         return value();
+      }
+
+      public static Type fromValue(String type) {
+         try {
+            return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
+         } catch (IllegalArgumentException e) {
+            return UNRECOGNIZED;
+         }
+      }
+   }
+
+   public enum State {
+      OPEN, ACTIVE, CANCELLED, CLOSED, UNRECOGNIZED;
+
+      public String value() {
+         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
+      }
+
+      @Override
+      public String toString() {
+         return value();
+      }
+
+      public static State fromValue(String state) {
+         try {
+            return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "type")));
+         } catch (IllegalArgumentException e) {
+            return UNRECOGNIZED;
+         }
+      }
+   }
+
+   private final String region;
+   private final String availabilityZoneGroup;
+   private final String launchedAvailabilityZone;
+   private final Date createTime;
+   private final String faultCode;
+   private final String faultMessage;
+   private final String instanceId;
+   private final String launchGroup;
+   private final LaunchSpecification launchSpecification;
+   private final String productDescription;
+   private final String id;
+   private final float spotPrice;
+   private final State state;
+   private final String rawState;
+   private final Type type;
+   private final Date validFrom;
+   private final Date validUntil;
+   private final Map<String, String> tags;
+
+   public SpotInstanceRequest(String region, String availabilityZoneGroup, @Nullable String launchedAvailabilityZone,
+            Date createTime, String faultCode, String faultMessage, String instanceId, String launchGroup,
+            LaunchSpecification launchSpecification, String productDescription, String id, float spotPrice,
+            State state, String rawState, Type type, Date validFrom, Date validUntil, Map<String, String> tags) {
+      this.region = checkNotNull(region, "region");
+      this.availabilityZoneGroup = availabilityZoneGroup;
+      this.launchedAvailabilityZone = launchedAvailabilityZone;
+      this.createTime = createTime;
+      this.faultCode = faultCode;
+      this.faultMessage = faultMessage;
+      this.instanceId = instanceId;
+      this.launchGroup = launchGroup;
+      this.launchSpecification = launchSpecification;
+      this.productDescription = productDescription;
+      this.id = checkNotNull(id, "id");
+      this.spotPrice = spotPrice;
+      this.state = checkNotNull(state, "state");
+      this.rawState = checkNotNull(rawState, "rawState");
+      this.type = checkNotNull(type, "type");
+      this.validFrom = validFrom;
+      this.validUntil = validUntil;
+      this.tags = ImmutableMap.<String, String> copyOf(checkNotNull(tags, "tags"));
+   }
+
+   /**
+    * @return spot instance requests are in a region
+    */
+   public String getRegion() {
+      return region;
+   }
+
+   public String getAvailabilityZoneGroup() {
+      return availabilityZoneGroup;
+   }
+
+   public String getLaunchedAvailabilityZone() {
+      return launchedAvailabilityZone;
+   }
+
+   public Date getCreateTime() {
+      return createTime;
+   }
+
+   public String getFaultCode() {
+      return faultCode;
+   }
+
+   public String getFaultMessage() {
+      return faultMessage;
+   }
+
+   public String getInstanceId() {
+      return instanceId;
+   }
+
+   public String getLaunchGroup() {
+      return launchGroup;
+   }
+
+   public LaunchSpecification getLaunchSpecification() {
+      return launchSpecification;
+   }
+
+   public String getProductDescription() {
+      return productDescription;
+   }
+
+   public String getId() {
+      return id;
+   }
+
+   public float getSpotPrice() {
+      return spotPrice;
+   }
+
+   public State getState() {
+      return state;
+   }
+   
+   public String getRawState() {
+      return rawState;
+   }
+   
+   public Type getType() {
+      return type;
+   }
+
+   public Date getValidFrom() {
+      return validFrom;
+   }
+
+   public Date getValidUntil() {
+      return validUntil;
+   }
+
+   /**
+    * tags that are present in the instance
+    */
+   public Map<String, String> getTags() {
+      return tags;
+   }
+   
+   @Override
+   public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((availabilityZoneGroup == null) ? 0 : availabilityZoneGroup.hashCode());
+      result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
+      result = prime * result + ((faultCode == null) ? 0 : faultCode.hashCode());
+      result = prime * result + ((faultMessage == null) ? 0 : faultMessage.hashCode());
+      result = prime * result + ((id == null) ? 0 : id.hashCode());
+      result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
+      result = prime * result + ((launchGroup == null) ? 0 : launchGroup.hashCode());
+      result = prime * result + ((launchSpecification == null) ? 0 : launchSpecification.hashCode());
+      result = prime * result + ((launchedAvailabilityZone == null) ? 0 : launchedAvailabilityZone.hashCode());
+      result = prime * result + ((productDescription == null) ? 0 : productDescription.hashCode());
+      result = prime * result + ((region == null) ? 0 : region.hashCode());
+      result = prime * result + Float.floatToIntBits(spotPrice);
+      result = prime * result + ((state == null) ? 0 : state.hashCode());
+      result = prime * result + ((type == null) ? 0 : type.hashCode());
+      result = prime * result + ((validFrom == null) ? 0 : validFrom.hashCode());
+      result = prime * result + ((validUntil == null) ? 0 : validUntil.hashCode());
+      result = prime * result + ((tags == null) ? 0 : tags.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      SpotInstanceRequest other = (SpotInstanceRequest) obj;
+      if (availabilityZoneGroup == null) {
+         if (other.availabilityZoneGroup != null)
+            return false;
+      } else if (!availabilityZoneGroup.equals(other.availabilityZoneGroup))
+         return false;
+      if (createTime == null) {
+         if (other.createTime != null)
+            return false;
+      } else if (!createTime.equals(other.createTime))
+         return false;
+      if (faultCode == null) {
+         if (other.faultCode != null)
+            return false;
+      } else if (!faultCode.equals(other.faultCode))
+         return false;
+      if (faultMessage == null) {
+         if (other.faultMessage != null)
+            return false;
+      } else if (!faultMessage.equals(other.faultMessage))
+         return false;
+      if (id == null) {
+         if (other.id != null)
+            return false;
+      } else if (!id.equals(other.id))
+         return false;
+      if (instanceId == null) {
+         if (other.instanceId != null)
+            return false;
+      } else if (!instanceId.equals(other.instanceId))
+         return false;
+      if (launchGroup == null) {
+         if (other.launchGroup != null)
+            return false;
+      } else if (!launchGroup.equals(other.launchGroup))
+         return false;
+      if (launchSpecification == null) {
+         if (other.launchSpecification != null)
+            return false;
+      } else if (!launchSpecification.equals(other.launchSpecification))
+         return false;
+      if (launchedAvailabilityZone == null) {
+         if (other.launchedAvailabilityZone != null)
+            return false;
+      } else if (!launchedAvailabilityZone.equals(other.launchedAvailabilityZone))
+         return false;
+      if (productDescription == null) {
+         if (other.productDescription != null)
+            return false;
+      } else if (!productDescription.equals(other.productDescription))
+         return false;
+      if (region == null) {
+         if (other.region != null)
+            return false;
+      } else if (!region.equals(other.region))
+         return false;
+      if (Float.floatToIntBits(spotPrice) != Float.floatToIntBits(other.spotPrice))
+         return false;
+      if (state != other.state)
+         return false;
+      if (type != other.type)
+         return false;
+      if (validFrom == null) {
+         if (other.validFrom != null)
+            return false;
+      } else if (!validFrom.equals(other.validFrom))
+         return false;
+      if (validUntil == null) {
+         if (other.validUntil != null)
+            return false;
+      } else if (!validUntil.equals(other.validUntil))
+         return false;
+      if (tags == null) {
+         if (other.tags != null)
+            return false;
+      } else if (!tags.equals(other.tags))
+         return false;
+      return true;
+   }
+
+   @Override
+   public String toString() {
+      return "[region=" + region + ", availabilityZoneGroup=" + availabilityZoneGroup + ", launchedAvailabilityZone="
+            + launchedAvailabilityZone + ", createTime=" + createTime + ", faultCode=" + faultCode + ", faultMessage="
+            + faultMessage + ", instanceId=" + instanceId + ", launchGroup=" + launchGroup + ", launchSpecification="
+            + launchSpecification + ", productDescription=" + productDescription + ", id=" + id + ", spotPrice="
+            + spotPrice + ", state=" + rawState + ", type=" + type + ", validFrom=" + validFrom + ", validUntil="
+            + validUntil + ", tags=" + tags + "]";
+   }
+
+   @Override
+   public int compareTo(SpotInstanceRequest arg0) {
+      return createTime.compareTo(arg0.createTime);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
new file mode 100644
index 0000000..92eb3b0
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.aws.ec2.xml.ProductCodesHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindProductCodesToIndexedFormParams;
+import org.jclouds.ec2.features.AMIApi;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * Provides access to AMI Services.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSAMIApi extends AMIApi {
+   // TODO make AWSImage as it has product codes...
+
+   /**
+    * Returns the Product Codes of an image.
+    * 
+    * @param region
+    *           AMIs are tied to the Region where its files are located within Amazon S3.
+    * @param imageId
+    *           The ID of the AMI for which an attribute will be described
+    * @see #describeImages
+    * @see #modifyImageAttribute
+    * @see #resetImageAttribute
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImageAttribute.html"
+    *      />
+    * @see DescribeImagesOptions
+    */
+   @Named("DescribeImageAttribute")
+   @POST
+   @Path("/")
+   @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
+   @XMLResponseParser(ProductCodesHandler.class)
+   Set<String> getProductCodesForImageInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @FormParam("ImageId") String imageId);
+
+   /**
+    * Adds {@code productCode}s to an AMI.
+    * 
+    * @param region
+    *           AMIs are tied to the Region where its files are located within Amazon S3.
+    * @param productCodes
+    *           Product Codes
+    * @param imageId
+    *           The AMI ID.
+    * 
+    * @see #removeProductCodesFromImage
+    * @see #describeImageAttribute
+    * @see #resetImageAttribute
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
+    *      />
+    */
+   @Named("ModifyImageAttribute")
+   @POST
+   @Path("/")
+   @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "add",
+            "productCodes" })
+   void addProductCodesToImageInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
+            @FormParam("ImageId") String imageId);
+
+   /**
+    * Removes {@code productCode}s from an AMI.
+    * 
+    * @param region
+    *           AMIs are tied to the Region where its files are located within Amazon S3.
+    * @param productCodes
+    *           Product Codes
+    * @param imageId
+    *           The AMI ID.
+    * 
+    * @see #addProductCodesToImage
+    * @see #describeImageAttribute
+    * @see #resetImageAttribute
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
+    *      />
+    */
+   @Named("ModifyImageAttribute")
+   @POST
+   @Path("/")
+   @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "remove",
+            "productCodes" })
+   void removeProductCodesFromImageInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
+            @FormParam("ImageId") String imageId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
new file mode 100644
index 0000000..4ccb4a2
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
+import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams;
+import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams;
+import org.jclouds.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+import com.google.common.collect.Multimap;
+
+/**
+ * Provides access to EC2 Instance Services via their REST API.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSInstanceApi extends InstanceApi {
+
+   @Named("DescribeInstances")
+   @Override
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeInstances")
+   @XMLResponseParser(AWSDescribeInstancesResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<? extends Reservation<? extends AWSRunningInstance>> describeInstancesInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
+
+   @Named("DescribeInstances")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeInstances")
+   @XMLResponseParser(AWSDescribeInstancesResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<? extends Reservation<? extends AWSRunningInstance>> describeInstancesInRegionWithFilter(
+           @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+           @BinderParam(BindFiltersToIndexedFormParams.class) Multimap<String, String> filter);
+
+   @Named("RunInstances")
+   @Override
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "RunInstances")
+   @XMLResponseParser(AWSRunInstancesResponseHandler.class)
+   Reservation<? extends AWSRunningInstance> runInstancesInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone,
+            @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount,
+            @FormParam("MaxCount") int maxCount, RunInstancesOptions... options);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
new file mode 100644
index 0000000..5813dce
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64;
+import org.jclouds.ec2.features.KeyPairApi;
+import org.jclouds.ec2.xml.KeyPairResponseHandler;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSKeyPairApi extends KeyPairApi {
+
+   /**
+    * Imports the public key from an RSA key pair that you created with a third-party tool. Compare
+    * this with CreateKeyPair, in which AWS creates the key pair and gives the keys to you (AWS
+    * keeps a copy of the public key). With ImportKeyPair, you create the key pair and give AWS just
+    * the public key. The private key is never transferred between you and AWS.
+    * 
+    * <p/>
+    * You can easily create an RSA key pair on Windows and Linux using the ssh-keygen command line
+    * tool (provided with the standard OpenSSH installation). Standard library support for RSA key
+    * pair creation is also available in Java, Ruby, Python, and many other programming languages.
+    * 
+    * <p/>
+    * <h4>Supported Formats</h4>
+    * <ul>
+    * <li>OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys)</li>
+    * <li>Base64 encoded DER format</li>
+    * <li>SSH public key file format as specified in RFC4716</li>
+    * </ul>
+    * DSA keys are not supported. Make sure your key generator is set up to create RSA keys.
+    * <p/>
+    * Supported lengths: 1024, 2048, and 4096.
+    * <p/>
+    * 
+    * @param region
+    *           region to import the key into
+    * @param keyName
+    *           A unique name for the key pair. Accepts alphanumeric characters, spaces, dashes, and
+    *           underscores.
+    * @param publicKeyMaterial
+    *           The public key
+    * @return imported key including fingerprint
+    */
+   @Named("ImportKeyPair")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "ImportKeyPair")
+   @XMLResponseParser(KeyPairResponseHandler.class)
+   KeyPair importKeyPairInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("KeyName") String keyName,
+         @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java
new file mode 100644
index 0000000..161afba
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.options.CreateSecurityGroupOptions;
+import org.jclouds.aws.ec2.xml.AWSEC2DescribeSecurityGroupsResponseHandler;
+import org.jclouds.aws.ec2.xml.CreateSecurityGroupResponseHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams;
+import org.jclouds.ec2.binders.BindGroupIdsToIndexedFormParams;
+import org.jclouds.ec2.binders.BindGroupNamesToIndexedFormParams;
+import org.jclouds.ec2.binders.BindIpPermissionToIndexedFormParams;
+import org.jclouds.ec2.binders.BindIpPermissionsToIndexedFormParams;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.features.SecurityGroupApi;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.Multimap;
+
+/**
+ * Provides access to EC2 SecurityGroup Services via their REST API.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+@Beta
+public interface AWSSecurityGroupApi extends SecurityGroupApi {
+
+   @Named("CreateSecurityGroup")
+   @POST
+   @Path("/")
+   @XMLResponseParser(CreateSecurityGroupResponseHandler.class)
+   @FormParams(keys = ACTION, values = "CreateSecurityGroup")
+   String createSecurityGroupInRegionAndReturnId(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("GroupName") String name, @FormParam("GroupDescription") String description,
+         CreateSecurityGroupOptions... options);
+
+   @Named("AuthorizeSecurityGroupIngress")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
+   void authorizeSecurityGroupIngressInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm);
+
+   @Named("AuthorizeSecurityGroupIngress")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
+   void authorizeSecurityGroupIngressInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("GroupId") String groupId,
+         @BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable<IpPermission> perms);
+
+   @Named("RevokeSecurityGroupIngress")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
+   void revokeSecurityGroupIngressInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm);
+
+   @Named("RevokeSecurityGroupIngress")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
+   void revokeSecurityGroupIngressInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("GroupId") String groupId,
+         @BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable<IpPermission> perms);
+
+   @Named("DeleteSecurityGroup")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DeleteSecurityGroup")
+   @Fallback(VoidOnNotFoundOr404.class)
+   void deleteSecurityGroupInRegionById(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String name);
+
+   @Named("DescribeSecurityGroups")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSecurityGroups")
+   @XMLResponseParser(AWSEC2DescribeSecurityGroupsResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<SecurityGroup> describeSecurityGroupsInRegionById(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @BinderParam(BindGroupIdsToIndexedFormParams.class) String... securityGroupNames);
+
+   @Named("DescribeSecurityGroups")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSecurityGroups")
+   @XMLResponseParser(AWSEC2DescribeSecurityGroupsResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<SecurityGroup> describeSecurityGroupsInRegion(
+           @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+           @BinderParam(BindGroupNamesToIndexedFormParams.class) String... securityGroupNames);
+
+   @Named("DescribeSecurityGroups")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSecurityGroups")
+   @XMLResponseParser(AWSEC2DescribeSecurityGroupsResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<SecurityGroup> describeSecurityGroupsInRegionWithFilter(
+           @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+           @BinderParam(BindFiltersToIndexedFormParams.class) Multimap<String, String> filter);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java
new file mode 100644
index 0000000..bb1de8a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * Provides access to EC2 Monitoring Services via their REST API.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface MonitoringApi {
+
+   /**
+    * Enables monitoring for a running instance. For more information, refer to the Amazon
+    * CloudWatch Developer Guide.
+    * 
+    * @param region
+    *           Instances are tied to Availability Zones. However, the instance ID is tied to the
+    *           Region.
+    * @see InstanceApi#runInstances
+    * @see #unmonitorInstances
+    * 
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html"
+    *      />
+    */
+   @Named("MonitorInstances")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "MonitorInstances")
+   @XMLResponseParser(MonitoringStateHandler.class)
+   Map<String, MonitoringState> monitorInstancesInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @FormParam("InstanceId.0") String instanceId,
+            @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
+
+   /**
+    * Disables monitoring for a running instance. For more information, refer to the Amazon
+    * CloudWatch Developer Guide.
+    * 
+    * @param region
+    *           Instances are tied to Availability Zones. However, the instance ID is tied to the
+    *           Region.
+    * 
+    * @see InstanceApi#runInstances
+    * @see #monitorInstances
+    * 
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html"
+    *      />
+    */
+   @Named("UnmonitorInstances")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "UnmonitorInstances")
+   @XMLResponseParser(MonitoringStateHandler.class)
+   Map<String, MonitoringState> unmonitorInstancesInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @FormParam("InstanceId.0") String instanceId,
+            @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java
new file mode 100644
index 0000000..ec6f986
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.xml.DescribePlacementGroupsResponseHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams;
+import org.jclouds.ec2.binders.BindGroupNamesToIndexedFormParams;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+import com.google.common.collect.Multimap;
+
+/**
+ * Provides access to EC2 Placement Groups via their REST API.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface PlacementGroupApi {
+
+   /**
+    * Creates a placement group that you launch cluster compute instances into. You must give the
+    * group a name unique within the scope of your account.
+    * 
+    * @param region
+    *           Region to create the placement group in.
+    * @param name
+    *           The name of the placement group..
+    * @param strategy
+    *           The placement group strategy.
+    * @see #describePlacementGroupsInRegion
+    * @see #deletePlacementGroupInRegion
+    * 
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreatePlacementGroup.html"
+    *      />
+    */
+   @Named("CreatePlacementGroup")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "CreatePlacementGroup")
+   void createPlacementGroupInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @FormParam("GroupName") String name, @FormParam("Strategy") String strategy);
+
+   /**
+    * like {@link #createPlacementGroupInRegion(String,String,String) except that the strategy is default: "cluster".
+    */
+   @Named("CreatePlacementGroup")
+   @POST
+   @Path("/")
+   @FormParams(keys = { ACTION, "Strategy" }, values = { "CreatePlacementGroup", "cluster" })
+   void createPlacementGroupInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name);
+
+   /**
+    * Deletes a placement group from your account. You must terminate all instances in the placement group before deleting it.
+    * 
+    * @param region
+    *           Region to delete the placement from from
+    * @param name
+    *           Name of the security group to delete.
+    * 
+    * @see #describePlacementGroupsInRegion
+    * @see #createPlacementGroupInRegion
+    * 
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeletePlacementGroup.html"
+    *      />
+    */
+   @Named("DeletePlacementGroup")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DeletePlacementGroup")
+   @Fallback(VoidOnNotFoundOr404.class)
+   void deletePlacementGroupInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name);
+
+   /**
+    * 
+    * Returns information about one or more placement groups in your account.
+    * 
+    * @param region
+    *           The bundleTask ID is tied to the Region.
+    * @param groupNames
+    *           The name of the placement group. You can specify more than one in the request, or
+    *           omit the parameter if you want information about all your placement groups. By
+    *           default, all placement groups are described
+    * 
+    * @see #deletePlacementGroupInRegion
+    * @see #createPlacementGroupInRegion
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribePlacementGroups.html"
+    *      />
+    */
+   @Named("DescribePlacementGroups")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribePlacementGroups")
+   @XMLResponseParser(DescribePlacementGroupsResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<PlacementGroup> describePlacementGroupsInRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+            @BinderParam(BindGroupNamesToIndexedFormParams.class) String... placementGroupIds);
+
+   /**
+    *
+    * Returns information about one or more placement groups in your account.
+    *
+    * @param region
+    *           The bundleTask ID is tied to the Region.
+    * @param filter
+    *           Multimap of filter key/values
+    *
+    * @see #deletePlacementGroupInRegion
+    * @see #createPlacementGroupInRegion
+    * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribePlacementGroups.html"
+    *      />
+    */
+   @Named("DescribePlacementGroups")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribePlacementGroups")
+   @XMLResponseParser(DescribePlacementGroupsResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<PlacementGroup> describePlacementGroupsInRegionWithFilter(
+           @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+           @BinderParam(BindFiltersToIndexedFormParams.class) Multimap<String, String> filter);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java
new file mode 100644
index 0000000..aee2c9d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.binders.BindLaunchSpecificationToFormParams;
+import org.jclouds.aws.ec2.binders.BindSpotInstanceRequestIdsToIndexedFormParams;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions;
+import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
+import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler;
+import org.jclouds.aws.ec2.xml.SpotInstanceHandler;
+import org.jclouds.aws.ec2.xml.SpotInstancesHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+import com.google.common.collect.Multimap;
+
+/**
+ * Provides access to EC2 Spot Instances via their REST API.
+ * <p/>
+ * 
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface SpotInstanceApi {
+
+   /**
+    * Describes Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your
+    * behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2
+    * periodically sets the Spot Price based on available Spot Instance capacity and current spot
+    * instance requests. For conceptual information about Spot Instances, refer to the Amazon
+    * Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
+    * 
+    * @param region
+    *           Region where the spot instance service is running
+    * @param requestIds
+    *           Specifies the ID of the Spot Instance request.
+    * 
+    * @see #requestSpotInstancesInRegion
+    * @see #cancelSpotInstanceRequestsInRegion
+    * @see #describeSpotPriceHistoryInRegion
+    * @see <a href=
+    *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotInstanceRequests.html"
+    *      />
+    * @return TODO
+    */
+   @Named("DescribeSpotInstanceRequests")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSpotInstanceRequests")
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   @XMLResponseParser(SpotInstancesHandler.class)
+   Set<SpotInstanceRequest> describeSpotInstanceRequestsInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds);
+
+   /**
+    * Describes Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your
+    * behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2
+    * periodically sets the Spot Price based on available Spot Instance capacity and current spot
+    * instance requests. For conceptual information about Spot Instances, refer to the Amazon
+    * Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
+    *
+    * @param region
+    *           Region where the spot instance service is running
+    * @param filter
+    *           Mulitmap of filter key/values.
+    *
+    * @see #requestSpotInstancesInRegion
+    * @see #cancelSpotInstanceRequestsInRegion
+    * @see #describeSpotPriceHistoryInRegion
+    * @see <a href=
+    *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotInstanceRequests.html"
+    *      />
+    * @return TODO
+    */
+   @Named("DescribeSpotInstanceRequests")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSpotInstanceRequests")
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   @XMLResponseParser(SpotInstancesHandler.class)
+   Set<SpotInstanceRequest> describeSpotInstanceRequestsInRegionWithFilter(
+           @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+           @BinderParam(BindFiltersToIndexedFormParams.class) Multimap<String, String> filter);
+
+   /**
+    * request a single spot instance
+    * 
+    * @param region
+    *           Region where the spot instance service is running
+    * @param spotPrice
+    *           Specifies the maximum hourly price for any Spot Instance launched to fulfill the
+    *           request.
+    * @param imageId
+    *           The AMI ID.
+    * @param instanceType
+    *           The instance type (ex. m1.small)
+    * @return spot instance request
+    * @see #requestSpotInstancesInRegion
+    */
+   @Named("RequestSpotInstances")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "RequestSpotInstances")
+   @XMLResponseParser(SpotInstanceHandler.class)
+   SpotInstanceRequest requestSpotInstanceInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("SpotPrice") float spotPrice, @FormParam("LaunchSpecification.ImageId") String imageId,
+         @FormParam("LaunchSpecification.InstanceType") String instanceType);
+
+   /**
+    * Creates a Spot Instance request. Spot Instances are instances that Amazon EC2 starts on your
+    * behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2
+    * periodically sets the Spot Price based on available Spot Instance capacity and current spot
+    * instance requests. For conceptual information about Spot Instances, refer to the Amazon
+    * Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
+    * 
+    * @param region
+    *           Region where the spot instance service is running
+    * @param spotPrice
+    *           Specifies the maximum hourly price for any Spot Instance launched to fulfill the
+    *           request.
+    * @param instanceCount
+    *           number of instances to request
+    * @param launchSpec
+    *           includes at least The AMI ID and instance type (ex. m1.small)
+    * @param options
+    *           options including expiration time or grouping
+    * 
+    * @see #describeSpotInstanceRequestsInRegion
+    * @see #cancelSpotInstanceRequestsInRegion
+    * @see #describeSpotPriceHistoryInRegion
+    * @see <a href=
+    *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RequestSpotInstances.html"
+    *      />
+    * @return set of spot instance requests
+    */
+   @Named("RequestSpotInstances")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "RequestSpotInstances")
+   @XMLResponseParser(SpotInstancesHandler.class)
+   Set<SpotInstanceRequest> requestSpotInstancesInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @FormParam("SpotPrice") float spotPrice, @FormParam("InstanceCount") int instanceCount,
+         @BinderParam(BindLaunchSpecificationToFormParams.class) LaunchSpecification launchSpec,
+         RequestSpotInstancesOptions... options);
+
+   /**
+    * 
+    * Describes Spot Price history. Spot Instances are instances that Amazon EC2 starts on your
+    * behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2
+    * periodically sets the Spot Price based on available Spot Instance capacity and current spot
+    * instance requests. For conceptual information about Spot Instances, refer to the Amazon
+    * Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
+    * 
+    * @param region
+    *           Region where the spot instance service is running
+    * @param options
+    *           options to control the list
+    * 
+    * @see #describeSpotInstanceRequestsInRegion
+    * @see #requestSpotInstancesInRegion
+    * @see #cancelSpotInstanceRequestsInRegion
+    * @see <a href=
+    *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotInstanceRequests.html"
+    *      />
+    * @return TODO
+    */
+   @Named("DescribeSpotPriceHistory")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "DescribeSpotPriceHistory")
+   @XMLResponseParser(DescribeSpotPriceHistoryResponseHandler.class)
+   @Fallback(EmptySetOnNotFoundOr404.class)
+   Set<Spot> describeSpotPriceHistoryInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         DescribeSpotPriceHistoryOptions... options);
+
+   /**
+    * Cancels one or more Spot Instance requests. Spot Instances are instances that Amazon EC2
+    * starts on your behalf when the maximum price that you specify exceeds the current Spot Price.
+    * Amazon EC2 periodically sets the Spot Price based on available Spot Instance capacity and
+    * current spot instance requests. For conceptual information about Spot Instances, refer to the
+    * Amazon Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
+    * 
+    * @param region
+    *           Region where the spot instance service is running
+    * @param requestIds
+    *           Specifies the ID of the Spot Instance request.
+    * 
+    * @see #describeSpotInstanceRequestsInRegion
+    * @see #requestSpotInstancesInRegion
+    * @see #describeSpotPriceHistoryInRegion
+    * @see <a href=
+    *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CancelSpotInstanceRequests.html"
+    *      />
+    * @return TODO
+    */
+   @Named("CancelSpotInstanceRequests")
+   @POST
+   @Path("/")
+   @FormParams(keys = ACTION, values = "CancelSpotInstanceRequests")
+   @Fallback(VoidOnNotFoundOr404.class)
+   void cancelSpotInstanceRequestsInRegion(
+         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+         @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java
new file mode 100644
index 0000000..0143aae
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.PlacementGroup.State;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Predicate;
+import com.google.common.cache.CacheLoader;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class CreatePlacementGroupIfNeeded extends CacheLoader<RegionAndName, String> {
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+   protected final AWSEC2Api ec2Api;
+   protected final Predicate<PlacementGroup> placementGroupAvailable;
+
+   @Inject
+   public CreatePlacementGroupIfNeeded(AWSEC2Api ec2Api,
+            @Named("AVAILABLE") Predicate<PlacementGroup> placementGroupAvailable) {
+      this.ec2Api = ec2Api;
+      this.placementGroupAvailable = placementGroupAvailable;
+   }
+
+   @Override
+   public String load(RegionAndName from) {
+      createPlacementGroupInRegion(from.getRegion(), from.getName());
+      return from.getName();
+   }
+
+   private void createPlacementGroupInRegion(String region, String name) {
+      checkNotNull(region, "region");
+      checkNotNull(name, "name");
+      logger.debug(">> creating placementGroup region(%s) name(%s)", region, name);
+      try {
+         ec2Api.getPlacementGroupApi().get().createPlacementGroupInRegion(region, name);
+         logger.debug("<< created placementGroup(%s)", name);
+         checkState(placementGroupAvailable.apply(new PlacementGroup(region, name, "cluster", State.PENDING)), String
+                  .format("placementGroup region(%s) name(%s) failed to become available", region, name));
+      } catch (AWSResponseException e) {
+         if (e.getError().getCode().equals("InvalidPlacementGroup.Duplicate")) {
+            logger.debug("<< reused placementGroup(%s)", name);
+         } else {
+            throw e;
+         }
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java
new file mode 100644
index 0000000..52bef6c
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.ssh.SshKeys.fingerprintPublicKey;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.logging.Logger;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class ImportOrReturnExistingKeypair implements Function<RegionNameAndPublicKeyMaterial, KeyPair> {
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+   protected final AWSEC2Api ec2Api;
+
+   @Inject
+   public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) {
+      this.ec2Api = ec2Api;
+   }
+
+   @Override
+   public KeyPair apply(RegionNameAndPublicKeyMaterial from) {
+      return importOrReturnExistingKeypair(from.getRegion(), from.getName(), from.getPublicKeyMaterial());
+   }
+
+   @VisibleForTesting
+   KeyPair importOrReturnExistingKeypair(String region, String group, String publicKeyMaterial) {
+      checkNotNull(region, "region");
+      checkNotNull(group, "group");
+      checkNotNull(publicKeyMaterial, "publicKeyMaterial");
+      logger.debug(">> importing keyPair region(%s) group(%s)", region, group);
+      KeyPair keyPair = null;
+      // loop for eventual consistency or race condition.
+      // as this command is idempotent, it should be ok
+      while (keyPair == null)
+         try {
+            keyPair = ec2Api.getKeyPairApi().get().importKeyPairInRegion(region, "jclouds#" + group,
+                     publicKeyMaterial);
+            keyPair = addFingerprintToKeyPair(publicKeyMaterial, keyPair);
+            logger.debug("<< imported keyPair(%s)", keyPair);
+         } catch (IllegalStateException e) {
+            keyPair = Iterables.getFirst(ec2Api.getKeyPairApi().get().describeKeyPairsInRegion(region,
+                     "jclouds#" + group), null);
+            if (keyPair != null) {
+               keyPair = addFingerprintToKeyPair(publicKeyMaterial, keyPair);
+               logger.debug("<< retrieved existing keyPair(%s)", keyPair);
+            }
+         }
+      return keyPair;
+   }
+
+   public KeyPair addFingerprintToKeyPair(String publicKeyMaterial, KeyPair keyPair) {
+      // add in the fingerprint as it makes correlating keys in ssh logs possible
+      keyPair = keyPair.toBuilder().fingerprint(fingerprintPublicKey(publicKeyMaterial)).build();
+      return keyPair;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java
new file mode 100644
index 0000000..887e610
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.functions;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+
+import com.google.common.base.Function;
+
+/**
+ * @author Adrian Cole
+ */
+public class SpotInstanceRequestToAWSRunningInstance implements Function<SpotInstanceRequest, AWSRunningInstance> {
+
+   @Override
+   public AWSRunningInstance apply(SpotInstanceRequest request) {
+      if (request == null)
+         return null;
+      if (request.getState() != SpotInstanceRequest.State.OPEN)
+         return null;
+      AWSRunningInstance.Builder builder = AWSRunningInstance.builder();
+      builder.spotInstanceRequestId(request.getId());
+      builder.instanceId(request.getId());
+      builder.instanceState(InstanceState.PENDING);
+      builder.rawState(request.getRawState());
+      builder.region(request.getRegion());
+      builder.tags(request.getTags());
+      LaunchSpecification spec = request.getLaunchSpecification();
+      builder.availabilityZone(spec.getAvailabilityZone());
+      // TODO convert
+      // builder.devices(spec.getBlockDeviceMappings());
+      builder.groupNames(spec.getSecurityGroupNames());
+      builder.imageId(spec.getImageId());
+      builder.instanceType(spec.getInstanceType());
+      builder.kernelId(spec.getKernelId());
+      builder.keyName(spec.getKeyName());
+      builder.ramdiskId(spec.getRamdiskId());
+      builder.monitoringState(Boolean.TRUE.equals(spec.isMonitoringEnabled()) ? MonitoringState.PENDING
+               : MonitoringState.DISABLED);
+      //TODO: determine the exact hypervisor
+      builder.hypervisor(Hypervisor.XEN);
+      return builder.build();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java
new file mode 100644
index 0000000..a0b59b2
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jclouds.ec2.options.DescribeImagesOptions;
+
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+
+/**
+ * Extra options only available in Amazon's implementation
+ * 
+ * @see DescribeImagesOptions
+ * @author Adrian Cole
+ */
+public class AWSDescribeImagesOptions extends DescribeImagesOptions {
+   public static final AWSDescribeImagesOptions NONE = new AWSDescribeImagesOptions();
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSDescribeImagesOptions executableBy(String identityId) {
+      super.executableBy(identityId);
+      return this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSDescribeImagesOptions imageIds(String... imageIds) {
+      super.imageIds(imageIds);
+      return this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSDescribeImagesOptions imageIds(Iterable<String> imageIds) {
+      super.imageIds(imageIds);
+      return this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSDescribeImagesOptions ownedBy(String... owners) {
+      super.ownedBy(owners);
+      return this;
+   }
+
+   /**
+    * You can filter the results to return information only about images that match criteria you
+    * specify. For example, you could get information only about images that use a certain kernel.
+    * You can specify multiple values for a filter (e.g., the image uses either kernel aki-1a2b3c4d
+    * or kernel aki-9b8c7d6f). An image must match at least one of the specified values for it to be
+    * included in the results.
+    * <p/>
+    * You can specify multiple filters (e.g., the image uses a certain kernel, and uses an Amazon
+    * EBS volume as the root device). The result includes information for a particular image only if
+    * it matches all your filters. If there's no match, no special message is returned; the response
+    * is simply empty.
+    * <p/>
+    * You can use wildcards with the filter values: * matches zero or more characters, and ? matches
+    * exactly one character. You can escape special characters using a backslash before the
+    * character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\.
+    * 
+    */
+   public AWSDescribeImagesOptions filters(Multimap<String, String> filters) {
+      int i = 0;
+      for (Entry<String, Collection<String>> filter : checkNotNull(filters, "filters").asMap().entrySet()) {
+         String filterPrefix = String.format("Filter.%s.", ++i);
+         formParameters.put(filterPrefix + "Name", filter.getKey());
+         indexFormValuesWithPrefix(filterPrefix + "Value", filter.getValue());
+      }
+      return this;
+   }
+
+   /**
+    * @see #filters(Multimap)
+    */
+   public AWSDescribeImagesOptions filters(Map<String, String> filters) {
+      return filters(Multimaps.forMap(checkNotNull(filters, "filters")));
+   }
+
+   public static class Builder extends DescribeImagesOptions.Builder {
+
+      /**
+       * @see AWSDescribeImagesOptions#executableBy
+       */
+      public static AWSDescribeImagesOptions executableBy(String identityId) {
+         AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+         return options.executableBy(identityId);
+      }
+
+      /**
+       * @see AWSDescribeImagesOptions#imageIds
+       */
+      public static AWSDescribeImagesOptions imageIds(String... imageIds) {
+         AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+         return options.imageIds(imageIds);
+      }
+
+      /**
+       * @see AWSDescribeImagesOptions#filters(Multimap)
+       */
+      public static AWSDescribeImagesOptions filters(Multimap<String, String> filters) {
+         AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+         return options.filters(filters);
+      }
+
+      /**
+       * @see AWSDescribeImagesOptions#filters(Map)
+       */
+      public static AWSDescribeImagesOptions filters(Map<String, String> filters) {
+         AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+         return options.filters(filters);
+      }
+
+      /**
+       * @see AWSDescribeImagesOptions#ownedBy
+       */
+      public static AWSDescribeImagesOptions ownedBy(String... owners) {
+         AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+         return options.ownedBy(owners);
+      }
+
+   }
+}


[05/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java
new file mode 100644
index 0000000..8f8a856
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy;
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.aws.ec2.xml.ProductCodesHandler;
+import org.jclouds.ec2.options.CreateImageOptions;
+import org.jclouds.ec2.options.DescribeImagesOptions;
+import org.jclouds.ec2.options.RegisterImageBackedByEbsOptions;
+import org.jclouds.ec2.options.RegisterImageOptions;
+import org.jclouds.ec2.xml.BlockDeviceMappingHandler;
+import org.jclouds.ec2.xml.DescribeImagesResponseHandler;
+import org.jclouds.ec2.xml.ImageIdHandler;
+import org.jclouds.ec2.xml.PermissionHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code AWSAMIApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "AWSAMIApiTest")
+public class AWSAMIApiTest extends BaseAWSEC2ApiTest<AWSAMIApi> {
+   public AWSAMIApiTest() {
+      provider = "aws-ec2";
+   }
+
+   HttpRequest createImage = HttpRequest.builder().method("POST")
+                                        .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                        .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                        .addFormParam("Action", "CreateImage")
+                                        .addFormParam("InstanceId", "instanceId")
+                                        .addFormParam("Name", "name").build();
+
+   public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "createImageInRegion", String.class, String.class, String.class,
+               CreateImageOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(createImage).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest createImageOptions = HttpRequest.builder().method("POST")
+                                               .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                               .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                               .addFormParam("Action", "CreateImage")
+                                               .addFormParam("Description", "description")
+                                               .addFormParam("InstanceId", "instanceId")
+                                               .addFormParam("Name", "name")
+                                               .addFormParam("NoReboot", "true").build();
+
+   public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "createImageInRegion", String.class, String.class, String.class,
+               CreateImageOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId", new CreateImageOptions()
+               .withDescription("description").noReboot()));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(createImageOptions).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest describeImages = HttpRequest.builder().method("POST")
+                                           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                           .addFormParam("Action", "DescribeImages").build();
+
+   public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "describeImagesInRegion", String.class,
+               DescribeImagesOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(describeImages).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeImagesResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest describeImagesOptions = HttpRequest.builder().method("POST")
+                                                  .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                  .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                  .addFormParam("Action", "DescribeImages")
+                                                  .addFormParam("ExecutableBy", "me")
+                                                  .addFormParam("ImageId.1", "1")
+                                                  .addFormParam("ImageId.2", "2")
+                                                  .addFormParam("Owner.1", "fred")
+                                                  .addFormParam("Owner.2", "nancy").build();
+
+   public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "describeImagesInRegion", String.class,
+               DescribeImagesOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds(
+               "1", "2")));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(describeImagesOptions).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeImagesResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest deregisterImage = HttpRequest.builder().method("POST")
+                                            .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                            .addFormParam("Action", "DeregisterImage")
+                                            .addFormParam("ImageId", "imageId").build();
+
+   public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "deregisterImageInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(deregisterImage).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest registerImageFromManifest = HttpRequest.builder().method("POST")
+                                                      .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                      .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                      .addFormParam("Action", "RegisterImage")
+                                                      .addFormParam("ImageLocation", "pathToManifest")
+                                                      .addFormParam("Name", "name").build();
+
+   public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "registerImageFromManifestInRegion", String.class, String.class,
+               String.class, RegisterImageOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(registerImageFromManifest).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest registerImageFromManifestOptions = HttpRequest.builder().method("POST")
+                                                             .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                             .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                             .addFormParam("Action", "RegisterImage")
+                                                             .addFormParam("Description", "description")
+                                                             .addFormParam("ImageLocation", "pathToManifest")
+                                                             .addFormParam("Name", "name").build();
+
+   public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "registerImageFromManifestInRegion", String.class, String.class,
+               String.class, RegisterImageOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest", new RegisterImageOptions()
+               .withDescription("description")));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(registerImageFromManifestOptions).getPayload().getRawContent()
+            .toString(), "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest registerImageBackedByEBS = HttpRequest.builder().method("POST")
+                                                     .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                     .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                     .addFormParam("Action", "RegisterImage")
+                                                     .addFormParam("BlockDeviceMapping.0.DeviceName", "/dev/sda1")
+                                                     .addFormParam("BlockDeviceMapping.0.Ebs.SnapshotId", "snapshotId")
+                                                     .addFormParam("Name", "imageName")
+                                                     .addFormParam("RootDeviceName", "/dev/sda1").build();
+
+   public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class,
+               String.class, String.class, RegisterImageBackedByEbsOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(registerImageBackedByEBS).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest registerImageBackedByEBSOptions = HttpRequest.builder().method("POST")
+                                                            .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                            .addFormParam("Action", "RegisterImage")
+                                                            .addFormParam("BlockDeviceMapping.0.DeviceName", "/dev/sda1")
+                                                            .addFormParam("BlockDeviceMapping.0.Ebs.SnapshotId", "snapshotId")
+                                                            .addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/device")
+                                                            .addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false")
+                                                            .addFormParam("BlockDeviceMapping.1.Ebs.SnapshotId", "snapshot")
+                                                            .addFormParam("BlockDeviceMapping.2.DeviceName", "/dev/newdevice")
+                                                            .addFormParam("BlockDeviceMapping.2.Ebs.DeleteOnTermination", "false")
+                                                            .addFormParam("BlockDeviceMapping.2.Ebs.VolumeSize", "100")
+                                                            .addFormParam("BlockDeviceMapping.2.VirtualName", "newblock")
+                                                            .addFormParam("Description", "description")
+                                                            .addFormParam("Name", "imageName")
+                                                            .addFormParam("RootDeviceName", "/dev/sda1").build();
+
+   public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class,
+               String.class, String.class, RegisterImageBackedByEbsOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId",
+               new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot(
+                        "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100)));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(registerImageBackedByEBSOptions).getPayload().getRawContent()
+            .toString(), "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest getBlockDeviceMappingsForImage = HttpRequest.builder().method("POST")
+                                                           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                           .addFormParam("Action", "DescribeImageAttribute")
+                                                           .addFormParam("Attribute", "blockDeviceMapping")
+                                                           .addFormParam("ImageId", "imageId").build();
+
+   public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "getBlockDeviceMappingsForImageInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(getBlockDeviceMappingsForImage).getPayload().getRawContent()
+            .toString(), "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, BlockDeviceMappingHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest getLaunchPermissionForImage = HttpRequest.builder().method("POST")
+                                                        .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                        .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                        .addFormParam("Action", "DescribeImageAttribute")
+                                                        .addFormParam("Attribute", "launchPermission")
+                                                        .addFormParam("ImageId", "imageId").build();
+
+   public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "getLaunchPermissionForImageInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(getLaunchPermissionForImage).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, PermissionHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest addLaunchPermission = HttpRequest.builder().method("POST")
+                                                          .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                          .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                          .addFormParam("Action", "ModifyImageAttribute")
+                                                          .addFormParam("Attribute", "launchPermission")
+                                                          .addFormParam("ImageId", "imageId")
+                                                          .addFormParam("OperationType", "add")
+                                                          .addFormParam("UserGroup.1", "all")
+                                                          .addFormParam("UserId.1", "bob")
+                                                          .addFormParam("UserId.2", "sue").build();
+
+   public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "addLaunchPermissionsToImageInRegion", String.class,
+               Iterable.class, Iterable.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
+               .of("all"), "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(addLaunchPermission).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest removeLaunchPermission = HttpRequest.builder().method("POST")
+                                                   .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                   .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                   .addFormParam("Action", "ModifyImageAttribute")
+                                                   .addFormParam("Attribute", "launchPermission")
+                                                   .addFormParam("ImageId", "imageId")
+                                                   .addFormParam("OperationType", "remove")
+                                                   .addFormParam("UserGroup.1", "all")
+                                                   .addFormParam("UserId.1", "bob")
+                                                   .addFormParam("UserId.2", "sue").build();
+
+   public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "removeLaunchPermissionsFromImageInRegion", String.class,
+               Iterable.class, Iterable.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
+               .of("all"), "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(removeLaunchPermission).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest resetLaunchPermissionsOnImage = HttpRequest.builder().method("POST")
+                                                          .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                          .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                          .addFormParam("Action", "ResetImageAttribute")
+                                                          .addFormParam("Attribute", "launchPermission")
+                                                          .addFormParam("ImageId", "imageId").build();
+
+   public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "resetLaunchPermissionsOnImageInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            filter.filter(resetLaunchPermissionsOnImage).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetProductCodesForImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "getProductCodesForImageInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, ProductCodesHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testAddProductCodesToImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "addProductCodesToImageInRegion", String.class, Iterable.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("code1", "code2"), "imageId"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRemoveProductCodesFromImage() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSAMIApi.class, "removeProductCodesFromImageInRegion", String.class,
+            Iterable.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("code1", "code2"), "imageId"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java
new file mode 100644
index 0000000..c617439
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code AWSEC2Api}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class AWSInstanceApiLiveTest extends BaseComputeServiceContextLiveTest {
+   public AWSInstanceApiLiveTest() {
+      provider = "aws-ec2";
+   }
+   
+   public static final String PREFIX = System.getProperty("user.name") + "-ec2";
+
+   private AWSInstanceApi client;
+   
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get();
+   }
+
+   @Test
+   void testDescribeInstances() {
+      for (String region : view.unwrapApi(AWSEC2Api.class).getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) {
+         Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
+         assertNotNull(allResults);
+         assert allResults.size() >= 0 : allResults.size();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java
new file mode 100644
index 0000000..c59037d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java
@@ -0,0 +1,539 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
+import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.ec2.xml.BlockDeviceMappingHandler;
+import org.jclouds.ec2.xml.BooleanValueHandler;
+import org.jclouds.ec2.xml.InstanceInitiatedShutdownBehaviorHandler;
+import org.jclouds.ec2.xml.InstanceStateChangeHandler;
+import org.jclouds.ec2.xml.InstanceTypeHandler;
+import org.jclouds.ec2.xml.StringValueHandler;
+import org.jclouds.ec2.xml.UnencodeStringValueHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code AWSInstanceApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "AWSInstanceApiTest")
+public class AWSInstanceApiTest extends BaseAWSEC2ApiTest<AWSInstanceApi> {
+   public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "describeInstancesInRegion", String.class, String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeInstances", "application/x-www-form-urlencoded",
+            false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSDescribeInstancesResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeInstancesArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "describeInstancesInRegion", String.class, String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeInstances&InstanceId.1=1&InstanceId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSDescribeInstancesResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testTerminateInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "terminateInstancesInRegion", String.class, String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=TerminateInstances&InstanceId.1=1&InstanceId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, InstanceStateChangeHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "runInstancesInRegion", String.class, String.class,
+            String.class, int.class, int.class, RunInstancesOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null, "ami-voo", 1, 1));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1",
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSRunInstancesResponseHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "runInstancesInRegion", String.class, String.class,
+            String.class, int.class, int.class, RunInstancesOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(
+            method,
+            Lists.<Object> newArrayList("us-east-1",
+            "us-east-1a",
+            "ami-voo",
+            1,
+            5,
+            new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring()
+                  .withSecurityGroups("group1", "group2")));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
+            "application/x-www-form-urlencoded", false);
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSRunInstancesResponseHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testStopInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "stopInstancesInRegion", String.class, boolean.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, true, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=StopInstances&Force=true&InstanceId.1=1&InstanceId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, InstanceStateChangeHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRebootInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "rebootInstancesInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=RebootInstances&InstanceId.1=1&InstanceId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testStartInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "startInstancesInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=StartInstances&InstanceId.1=1&InstanceId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, InstanceStateChangeHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getUserDataForInstanceInRegion", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=userData&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, UnencodeStringValueHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetRootDeviceNameForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getRootDeviceNameForInstanceInRegion", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=rootDeviceName&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, StringValueHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getRamdiskForInstanceInRegion", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=ramdisk&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, StringValueHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetDisableApiTerminationForInstanceInRegion() throws SecurityException, NoSuchMethodException,
+         IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "isApiTerminationDisabledForInstanceInRegion",
+            String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=disableApiTermination&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, BooleanValueHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getKernelForInstanceInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeInstanceAttribute&Attribute=kernel&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, StringValueHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getInstanceTypeForInstanceInRegion", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=instanceType&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, InstanceTypeHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetInstanceInitiatedShutdownBehaviorForInstanceInRegion() throws SecurityException,
+         NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion",
+            String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=DescribeInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, InstanceInitiatedShutdownBehaviorHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testGetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
+         IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "getBlockDeviceMappingForInstanceInRegion", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=DescribeInstanceAttribute&Attribute=blockDeviceMapping&InstanceId=1",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, BlockDeviceMappingHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setUserDataForInstance = HttpRequest.builder().method("POST")
+                                                   .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                   .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                   .addFormParam("Action", "ModifyInstanceAttribute")
+                                                   .addFormParam("Attribute", "userData")
+                                                   .addFormParam("InstanceId", "1")
+                                                   .addFormParam("Value", "dGVzdA%3D%3D").build();
+
+   public void testSetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setUserDataForInstanceInRegion", String.class, String.class,
+               byte[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test".getBytes()));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setUserDataForInstance).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setRamdiskForInstance = HttpRequest.builder().method("POST")
+                                                  .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                  .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                  .addFormParam("Action", "ModifyInstanceAttribute")
+                                                  .addFormParam("Attribute", "ramdisk")
+                                                  .addFormParam("InstanceId", "1")
+                                                  .addFormParam("Value", "test").build();
+
+   public void testSetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setRamdiskForInstanceInRegion", String.class, String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setRamdiskForInstance).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setKernelForInstance = HttpRequest.builder().method("POST")
+                                                 .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                 .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                 .addFormParam("Action", "ModifyInstanceAttribute")
+                                                 .addFormParam("Attribute", "kernel")
+                                                 .addFormParam("InstanceId", "1")
+                                                 .addFormParam("Value", "test").build();
+
+   public void testSetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setKernelForInstanceInRegion", String.class, String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setKernelForInstance).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setApiTerminationDisabled = HttpRequest.builder().method("POST")
+                                                      .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                      .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                      .addFormParam("Action", "ModifyInstanceAttribute")
+                                                      .addFormParam("Attribute", "disableApiTermination")
+                                                      .addFormParam("InstanceId", "1")
+                                                      .addFormParam("Value", "true").build();
+
+   public void testSetApiTerminationDisabledForInstanceInRegion() throws SecurityException, NoSuchMethodException,
+            IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setApiTerminationDisabledForInstanceInRegion", String.class,
+               String.class, boolean.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", true));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setApiTerminationDisabled).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest instanceTypeForInstance = HttpRequest.builder().method("POST")
+                                                    .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                    .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                    .addFormParam("Action", "ModifyInstanceAttribute")
+                                                    .addFormParam("Attribute", "instanceType")
+                                                    .addFormParam("InstanceId", "1")
+                                                    .addFormParam("Value", "c1.medium").build();
+
+   public void testSetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setInstanceTypeForInstanceInRegion", String.class,
+               String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceType.C1_MEDIUM));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(instanceTypeForInstance).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setInstanceInitiatedShutdownBehavior = HttpRequest.builder().method("POST")
+                                                                 .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                                 .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                                 .addFormParam("Action", "ModifyInstanceAttribute")
+                                                                 .addFormParam("Attribute", "instanceInitiatedShutdownBehavior")
+                                                                 .addFormParam("InstanceId", "1")
+                                                                 .addFormParam("Value", "terminate").build();
+
+   public void testSetInstanceInitiatedShutdownBehaviorForInstanceInRegion() throws SecurityException,
+            NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion",
+               String.class, String.class, InstanceInitiatedShutdownBehavior.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setInstanceInitiatedShutdownBehavior).getPayload().getRawContent()
+            .toString(), "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest setBlockDeviceMapping = HttpRequest.builder().method("POST")
+                                                           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                           .addFormParam("Action", "ModifyInstanceAttribute")
+                                                           .addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/sda1")
+                                                           .addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true")
+                                                           .addFormParam("BlockDeviceMapping.1.Ebs.VolumeId", "vol-test1")
+                                                           .addFormParam("InstanceId", "1").build();
+
+   public void testSetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
+         IOException {
+      Invokable<?, ?> method = method(AWSInstanceApi.class, "setBlockDeviceMappingForInstanceInRegion", String.class,
+            String.class, Map.class);
+
+      Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
+      mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(setBlockDeviceMapping).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java
new file mode 100644
index 0000000..c2ddc8a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.get;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Sets.newTreeSet;
+import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
+import static org.jclouds.compute.predicates.NodePredicates.inGroup;
+import static org.jclouds.compute.predicates.NodePredicates.runningInGroup;
+import static org.jclouds.scriptbuilder.domain.Statements.exec;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.ComputeTestUtils;
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Tests behavior of {@code AWSKeyPairApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class AWSKeyPairApiLiveTest extends BaseComputeServiceContextLiveTest {
+   public AWSKeyPairApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private AWSKeyPairApi client;
+   
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class).getKeyPairApi().get();
+   }
+
+   public void testNoSsh() throws Exception {
+
+      Map<String, String> keyPair = ComputeTestUtils.setupKeyPair();
+
+      AWSInstanceApi instanceApi = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get();
+
+      String group = PREFIX + "unssh";
+      view.getComputeService().destroyNodesMatching(inGroup(group));
+
+      TemplateOptions options = view.getComputeService().templateOptions();
+
+      options.authorizePublicKey(keyPair.get("public")).as(AWSEC2TemplateOptions.class);
+
+      ComputeServiceContext noSshContext = null;
+      try {
+         noSshContext = createView(setupProperties(), ImmutableSet.<Module> of(new Log4JLoggingModule()));
+
+         Set<? extends NodeMetadata> nodes = noSshContext.getComputeService().createNodesInGroup(group, 1, options);
+
+         NodeMetadata first = get(nodes, 0);
+         assert first.getCredentials() != null : first;
+         assert first.getCredentials().identity != null : first;
+         // credentials should not be present as the import public key call doesn't have access to
+         // the related private key
+         assert first.getCredentials().credential == null : first;
+
+         AWSRunningInstance instance = getInstance(instanceApi, first.getProviderId());
+
+         assertEquals(instance.getKeyName(), "jclouds#" + group);
+
+         Map<? extends NodeMetadata, ExecResponse> responses = view.getComputeService()
+               .runScriptOnNodesMatching(
+                     runningInGroup(group),
+                     exec("echo hello"),
+                     overrideLoginCredentials(
+                           LoginCredentials.builder().user(first.getCredentials().identity)
+                                 .privateKey(keyPair.get("private")).build()).wrapInInitScript(false).runAsRoot(false));
+
+         ExecResponse hello = getOnlyElement(responses.values());
+         assertEquals(hello.getOutput().trim(), "hello");
+
+      } finally {
+         noSshContext.close();
+         view.getComputeService().destroyNodesMatching(inGroup(group));
+      }
+   }
+
+   @Test
+   void testDescribeAWSKeyPairs() {
+      for (String region : Region.DEFAULT_REGIONS) {
+
+         SortedSet<KeyPair> allResults = newTreeSet(client.describeKeyPairsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            KeyPair pair = allResults.last();
+            SortedSet<KeyPair> result = newTreeSet(client.describeKeyPairsInRegion(region, pair.getKeyName()));
+            assertNotNull(result);
+            KeyPair compare = result.last();
+            assertEquals(compare, pair);
+         }
+      }
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + "-ec2";
+
+   @Test
+   void testCreateKeyPair() {
+      String keyName = PREFIX + "1";
+      cleanupKeyPair(keyName);
+      try {
+         KeyPair keyPair = client.createKeyPairInRegion(null, keyName);
+         checkKeyPair(keyName, keyPair);
+         assertNotNull(keyPair.getKeyMaterial());
+      } finally {
+         cleanupKeyPair(keyName);
+      }
+   }
+
+   protected void cleanupKeyPair(String keyName) {
+      try {
+         client.deleteKeyPairInRegion(null, keyName);
+      } catch (Exception e) {
+
+      }
+      client.deleteKeyPairInRegion(null, keyName);
+   }
+
+   @Test
+   void testImportKeyPair() throws FileNotFoundException, IOException {
+      String keyName = PREFIX + "2";
+      cleanupKeyPair(keyName);
+      Map<String, String> myKey = ComputeTestUtils.setupKeyPair();
+      try {
+         KeyPair keyPair = client.importKeyPairInRegion(null, keyName, myKey.get("public"));
+         checkKeyPair(keyName, keyPair);
+         // TODO generate correct fingerprint and check
+         // assertEquals(keyPair.getKeyFingerprint(),
+         // CryptoStreams.hex(CryptoStreams.md5(myKey.get("public").getBytes())));
+
+         // try again to see if there's an error
+         try {
+            client.importKeyPairInRegion(null, keyName, myKey.get("public"));
+            fail("Expected IllegalStateException");
+         } catch (IllegalStateException e) {
+
+         }
+      } finally {
+         cleanupKeyPair(keyName);
+      }
+   }
+
+   protected void checkKeyPair(String keyName, KeyPair keyPair) {
+      assertNotNull(keyPair);
+      assertNotNull(keyPair.getSha1OfPrivateKey());
+      assertEquals(keyPair.getKeyName(), keyName);
+
+      Set<KeyPair> twoResults = client.describeKeyPairsInRegion(null, keyName);
+      assertNotNull(twoResults);
+      assertEquals(twoResults.size(), 1);
+      KeyPair listPair = twoResults.iterator().next();
+      assertEquals(listPair.getKeyName(), keyPair.getKeyName());
+      assertEquals(listPair.getSha1OfPrivateKey(), keyPair.getSha1OfPrivateKey());
+   }
+
+   protected AWSRunningInstance getInstance(AWSInstanceApi instanceApi, String id) {
+      return getOnlyElement(getOnlyElement(instanceApi.describeInstancesInRegion(null, id)));
+   }
+   
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java
new file mode 100644
index 0000000..d97ee6e
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler;
+import org.jclouds.ec2.xml.KeyPairResponseHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code AWSKeyPairApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "AWSKeyPairApiTest")
+public class AWSKeyPairApiTest extends BaseAWSEC2ApiTest<AWSKeyPairApi> {
+
+   public void testCreateKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSKeyPairApi.class, "createKeyPairInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "mykey"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=CreateKeyPair&KeyName=mykey",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, KeyPairResponseHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest importKeyPair = HttpRequest.builder().method("POST")
+                                          .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                          .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                          .addFormParam("Action", "ImportKeyPair")
+                                          .addFormParam("KeyName", "mykey")
+                                          .addFormParam("PublicKeyMaterial", "c3NoLXJzYSBBQQ%3D%3D").build();
+
+   public void testImportKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSKeyPairApi.class, "importKeyPairInRegion", String.class, String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "mykey", "ssh-rsa AA"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(importKeyPair).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, KeyPairResponseHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSKeyPairApi.class, "deleteKeyPairInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "mykey"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DeleteKeyPair&KeyName=mykey",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSKeyPairApi.class, "describeKeyPairsInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeKeyPairs", "application/x-www-form-urlencoded",
+            false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeKeyPairsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeKeyPairsArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSKeyPairApi.class, "describeKeyPairsInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeKeyPairsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}


[03/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java
new file mode 100644
index 0000000..d3f6188
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest.State;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest.Type;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code SpotInstanceRequestToAWSRunningInstance}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "SpotInstanceRequestToAWSRunningInstanceTest")
+public class SpotInstanceRequestToAWSRunningInstanceTest {
+
+   public void testConvert() {
+
+      SpotInstanceRequest input = SpotInstanceRequest
+            .builder()
+            .region("us-east-1")
+            .id("sir-228e6406")
+            .spotPrice(0.001f)
+            .type(Type.ONE_TIME)
+            .state(State.OPEN)
+            .rawState("open")
+            .launchSpecification(
+                  LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupName("default")
+                        .instanceType("m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true)
+                        .mapEBSSnapshotToDevice("/dev/sda2", "snap-1ea27576", 1, true)
+                        .mapEphemeralDeviceToDevice("/dev/sda3", "vre1").monitoringEnabled(false).build())
+            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-03-08T03:30:36.000Z"))
+            .productDescription("Linux/UNIX")
+            .tag("foo", "bar")
+            .tag("empty", "")
+            .build();
+
+      assertEquals(
+            new SpotInstanceRequestToAWSRunningInstance().apply(input).toString(),
+            AWSRunningInstance.builder().region("us-east-1").instanceId("sir-228e6406")
+                  .spotInstanceRequestId("sir-228e6406").instanceState(InstanceState.PENDING)
+                  .rawState("open").imageId("ami-595a0a1c")
+                  .groupName("default").instanceType("m1.large")
+                  .tag("foo", "bar")
+                  .tag("empty", "")
+                  .hypervisor(Hypervisor.XEN)
+                  .monitoringState(MonitoringState.DISABLED).build().toString());
+   }
+
+   public void testConvertWhenNotOpenReturnsNull() {
+
+      assertEquals(
+            new SpotInstanceRequestToAWSRunningInstance().apply(SpotInstanceRequest.builder().region("us-east-1")
+                  .id("sir-228e6406").type(Type.ONE_TIME).state(State.ACTIVE).rawState("active")
+                  .build()), null);
+
+      assertEquals(
+            new SpotInstanceRequestToAWSRunningInstance().apply(SpotInstanceRequest.builder().region("us-east-1")
+                  .id("sir-228e6406").type(Type.ONE_TIME).rawState("one-time")
+                  .state(State.CANCELLED).build()), null);
+
+      assertEquals(
+            new SpotInstanceRequestToAWSRunningInstance().apply(SpotInstanceRequest.builder().region("us-east-1")
+                  .id("sir-228e6406").type(Type.ONE_TIME).rawState("one-time")
+                  .state(State.UNRECOGNIZED).build()), null);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java
new file mode 100644
index 0000000..ba2e8fa
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.executableBy;
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters;
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.imageIds;
+import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.ownedBy;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.http.options.HttpRequestOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+
+/**
+ * Tests possible uses of AWSDescribeImagesOptions and AWSDescribeImagesOptions.Builder.*
+ * 
+ * @author Adrian Cole
+ */
+public class AWSDescribeImagesOptionsTest {
+
+   @Test
+   public void testAssignability() {
+      assert HttpRequestOptions.class.isAssignableFrom(AWSDescribeImagesOptions.class);
+      assert !String.class.isAssignableFrom(AWSDescribeImagesOptions.class);
+   }
+
+   @Test
+   public void testExecutableBy() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.executableBy("test");
+      assertEquals(options.buildFormParameters().get("ExecutableBy"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullExecutableBy() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      assertEquals(options.buildFormParameters().get("ExecutableBy"), ImmutableList.of());
+   }
+
+   @Test
+   public void testExecutableByStatic() {
+      AWSDescribeImagesOptions options = executableBy("test");
+      assertEquals(options.buildFormParameters().get("ExecutableBy"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testExecutableByNPE() {
+      executableBy(null);
+   }
+
+   @Test
+   public void testOwners() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.ownedBy("test");
+      assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testMultipleOwners() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.ownedBy("test", "trouble");
+      assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test"));
+      assertEquals(options.buildFormParameters().get("Owner.2"), ImmutableList.of("trouble"));
+   }
+
+   @Test
+   public void testNullOwners() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of());
+   }
+
+   @Test
+   public void testOwnersStatic() {
+      AWSDescribeImagesOptions options = ownedBy("test");
+      assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test"));
+   }
+
+   public void testNoOwners() {
+      ownedBy();
+   }
+
+   @Test
+   public void testImageIds() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.imageIds("test");
+      assertEquals(options.buildFormParameters().get("ImageId.1"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testMultipleImageIds() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.imageIds("test", "trouble");
+      assertEquals(options.buildFormParameters().get("ImageId.1"), ImmutableList.of("test"));
+      assertEquals(options.buildFormParameters().get("ImageId.2"), ImmutableList.of("trouble"));
+   }
+
+   @Test
+   public void testNullImageIds() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      assertEquals(options.buildFormParameters().get("ImageId.1"), ImmutableList.of());
+   }
+
+   @Test
+   public void testImageIdsStatic() {
+      AWSDescribeImagesOptions options = imageIds("test");
+      assertEquals(options.buildFormParameters().get("ImageId.1"), ImmutableList.of("test"));
+   }
+
+   public void testNoImageIds() {
+      imageIds();
+   }
+
+   @Test
+   public void testMapFilters() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.filters(ImmutableMap.of("is-public", "true", "architecture", "x86_64", "platform", "windows"));
+      testMapFilters(options);
+   }
+
+   private void testMapFilters(AWSDescribeImagesOptions options) {
+      assertEquals(options.buildFormParameters().get("Filter.1.Name"), ImmutableList.of("is-public"));
+      assertEquals(options.buildFormParameters().get("Filter.1.Value.1"), ImmutableList.of("true"));
+      assertEquals(options.buildFormParameters().get("Filter.2.Name"), ImmutableList.of("architecture"));
+      assertEquals(options.buildFormParameters().get("Filter.2.Value.1"), ImmutableList.of("x86_64"));
+      assertEquals(options.buildFormParameters().get("Filter.3.Name"), ImmutableList.of("platform"));
+      assertEquals(options.buildFormParameters().get("Filter.3.Value.1"), ImmutableList.of("windows"));
+   }
+
+   @Test
+   public void testMapFiltersStatic() {
+      AWSDescribeImagesOptions options = filters(ImmutableMap.of("is-public", "true", "architecture", "x86_64",
+               "platform", "windows"));
+      testMapFilters(options);
+   }
+   
+
+   @Test
+   public void testMultimapFilters() {
+      AWSDescribeImagesOptions options = new AWSDescribeImagesOptions();
+      options.filters(ImmutableMultimap.of("is-public", "true", "architecture", "x86_64", "platform", "windows"));
+      testMultimapFilters(options);
+   }
+
+   private void testMultimapFilters(AWSDescribeImagesOptions options) {
+      assertEquals(options.buildFormParameters().get("Filter.1.Name"), ImmutableList.of("is-public"));
+      assertEquals(options.buildFormParameters().get("Filter.1.Value.1"), ImmutableList.of("true"));
+      assertEquals(options.buildFormParameters().get("Filter.2.Name"), ImmutableList.of("architecture"));
+      assertEquals(options.buildFormParameters().get("Filter.2.Value.1"), ImmutableList.of("x86_64"));
+      assertEquals(options.buildFormParameters().get("Filter.3.Name"), ImmutableList.of("platform"));
+      assertEquals(options.buildFormParameters().get("Filter.3.Value.1"), ImmutableList.of("windows"));
+   }
+
+   @Test
+   public void testMultimapFiltersStatic() {
+      AWSDescribeImagesOptions options = filters(ImmutableMultimap.of("is-public", "true", "architecture", "x86_64",
+               "platform", "windows"));
+      testMultimapFilters(options);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java
new file mode 100644
index 0000000..ef75922
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.asType;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.enableMonitoring;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withBlockDeviceMappings;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withIAMInstanceProfileArn;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withIAMInstanceProfileName;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKernelId;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKeyName;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withRamdisk;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroup;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroupId;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSubnetId;
+import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withUserData;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.http.options.HttpRequestOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests possible uses of AWSRunInstancesOptions and AWSRunInstancesOptions.Builder.*
+ * 
+ * @author Adrian Cole
+ */
+public class AWSRunInstancesOptionsTest {
+
+   @Test
+   public void testAssignability() {
+      assert HttpRequestOptions.class.isAssignableFrom(AWSRunInstancesOptions.class);
+      assert !String.class.isAssignableFrom(AWSRunInstancesOptions.class);
+   }
+
+   @Test
+   public void testWithKeyName() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withKeyName("test");
+      assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithKeyName() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithKeyNameStatic() {
+      AWSRunInstancesOptions options = withKeyName("test");
+      assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithKeyNameNPE() {
+      withKeyName(null);
+   }
+
+   @Test
+   public void testWithSecurityGroup() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withSecurityGroup("test");
+      assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithSecurityGroup() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("SecurityGroup"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithSecurityGroupStatic() {
+      AWSRunInstancesOptions options = withSecurityGroup("test");
+      assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithSecurityGroupNPE() {
+      withSecurityGroup(null);
+   }
+   
+
+   @Test
+   public void testWithSecurityGroupId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withSecurityGroupId("test");
+      assertEquals(options.buildFormParameters().get("SecurityGroupId.1"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithSecurityGroupId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("SecurityGroupId"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithSecurityGroupIdStatic() {
+      AWSRunInstancesOptions options = withSecurityGroupId("test");
+      assertEquals(options.buildFormParameters().get("SecurityGroupId.1"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithSecurityGroupIdNPE() {
+      withSecurityGroupId(null);
+   }
+
+   @Test
+   public void testNullWithAdditionalInfo() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("AdditionalInfo"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithUserData() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withUserData("test".getBytes());
+      assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA=="));
+   }
+
+   @Test
+   public void testNullWithUserData() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithUserDataStatic() {
+      AWSRunInstancesOptions options = withUserData("test".getBytes());
+      assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA=="));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithUserDataNPE() {
+      withUserData(null);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testWithUserDataEmpty() {
+      withUserData("".getBytes());
+   }
+
+   @Test
+   public void testWithInstanceType() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.asType(InstanceType.C1_XLARGE);
+      assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge"));
+   }
+
+   @Test
+   public void testNullWithInstanceType() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithInstanceTypeStatic() {
+      AWSRunInstancesOptions options = asType(InstanceType.C1_XLARGE);
+      assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithInstanceTypeNPE() {
+      asType(null);
+   }
+
+   @Test
+   public void testWithKernelId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withKernelId("test");
+      assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithKernelId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithKernelIdStatic() {
+      AWSRunInstancesOptions options = withKernelId("test");
+      assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithKernelIdNPE() {
+      withKernelId(null);
+   }
+
+   @Test
+   public void testWithMonitoringEnabled() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.enableMonitoring();
+      assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), ImmutableList.of("true"));
+   }
+
+   @Test
+   public void testNullWithMonitoringEnabled() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithMonitoringEnabledStatic() {
+      AWSRunInstancesOptions options = enableMonitoring();
+      assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), ImmutableList.of("true"));
+   }
+
+   @Test
+   public void testWithSubnetId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withSubnetId("test");
+      assertEquals(options.buildFormParameters().get("SubnetId"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithSubnetId() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("SubnetId"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithSubnetIdStatic() {
+      AWSRunInstancesOptions options = withSubnetId("test");
+      assertEquals(options.buildFormParameters().get("SubnetId"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithSubnetIdNPE() {
+      withSubnetId(null);
+   }
+
+   @Test
+   public void testWithIAMInstanceProfileArn() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options
+            .withIAMInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Arn"),
+            ImmutableList.of("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver"));
+   }
+
+   @Test
+   public void testNullWithIAMInstanceProfileArn() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Arn"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithIAMInstanceProfileArnStatic() {
+      AWSRunInstancesOptions options = withIAMInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Arn"),
+            ImmutableList.of("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithIAMInstanceProfileArnNPE() {
+      withIAMInstanceProfileArn(null);
+   }
+
+   @Test
+   public void testWithIAMInstanceProfileName() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withIAMInstanceProfileName("Webserver");
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Name"), ImmutableList.of("Webserver"));
+   }
+
+   @Test
+   public void testNullWithIAMInstanceProfileName() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Name"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithIAMInstanceProfileNameStatic() {
+      AWSRunInstancesOptions options = withIAMInstanceProfileName("Webserver");
+      assertEquals(options.buildFormParameters().get("IamInstanceProfile.Name"), ImmutableList.of("Webserver"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithIAMInstanceProfileNameNPE() {
+      withIAMInstanceProfileName(null);
+   }
+
+   @Test
+   public void testWithRamdisk() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      options.withRamdisk("test");
+      assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testNullWithRamdisk() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithRamdiskStatic() {
+      AWSRunInstancesOptions options = withRamdisk("test");
+      assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithRamdiskNPE() {
+      withRamdisk(null);
+   }
+
+   @Test
+   public void testNullWithVirtualName() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithBlockDeviceMapping() {
+      BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true);
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions().withBlockDeviceMappings(ImmutableSet
+               .<BlockDeviceMapping> of(mapping));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"),
+               ImmutableList.of("/dev/sda1"));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"),
+               ImmutableList.of("120"));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"),
+               ImmutableList.of("true"));
+   }
+
+   @Test
+   public void testNullWithBlockDeviceMapping() {
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping"), ImmutableList.of());
+   }
+
+   @Test
+   public void testWithBlockDeviceMappingStatic() {
+      BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true);
+      AWSRunInstancesOptions options = withBlockDeviceMappings(ImmutableSet.<BlockDeviceMapping> of(mapping));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"),
+               ImmutableList.of("/dev/sda1"));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"),
+               ImmutableList.of("120"));
+      assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"),
+               ImmutableList.of("true"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testWithBlockDeviceMappingNPE() {
+      withBlockDeviceMappings(null);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java
new file mode 100644
index 0000000..54e4578
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.from;
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.instanceType;
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.productDescription;
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.to;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Date;
+
+import com.google.common.collect.ImmutableList;
+import org.jclouds.http.options.HttpRequestOptions;
+import org.testng.annotations.Test;
+
+/**
+ * Tests possible uses of DescribeSpotPriceHistoryOptions and
+ * DescribeSpotPriceHistoryOptions.Builder.*
+ * 
+ * @author Adrian Cole
+ */
+public class DescribeSpotPriceHistoryOptionsTest {
+
+   @Test
+   public void testAssignability() {
+      assert HttpRequestOptions.class.isAssignableFrom(DescribeSpotPriceHistoryOptions.class);
+      assert !String.class.isAssignableFrom(DescribeSpotPriceHistoryOptions.class);
+   }
+
+   @Test
+   public void testDescription() {
+      DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+      options.productDescription("test");
+      assertEquals(options.buildFormParameters().get("ProductDescription"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testDescriptionStatic() {
+      DescribeSpotPriceHistoryOptions options = productDescription("test");
+      assertEquals(options.buildFormParameters().get("ProductDescription"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testDescriptionNPE() {
+      productDescription(null);
+   }
+
+   @Test
+   public void testInstanceType() {
+      DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+      options.instanceType("test");
+      assertEquals(options.buildFormParameters().get("InstanceType.1"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testInstanceTypeStatic() {
+      DescribeSpotPriceHistoryOptions options = instanceType("test");
+      assertEquals(options.buildFormParameters().get("InstanceType.1"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testInstanceTypeNPE() {
+      instanceType(null);
+   }
+
+   @Test
+   public void testFrom() {
+      DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+      options.from(test);
+      assertEquals(options.buildFormParameters().get("StartTime"), ImmutableList.of("1970-05-23T21:21:18.910Z"));
+   }
+
+   Date test = new Date(12345678910l);
+
+   @Test
+   public void testFromStatic() {
+      DescribeSpotPriceHistoryOptions options = from(test);
+      assertEquals(options.buildFormParameters().get("StartTime"), ImmutableList.of("1970-05-23T21:21:18.910Z"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testFromNPE() {
+      from(null);
+   }
+
+   @Test
+   public void testTo() {
+      DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+      options.to(test);
+      assertEquals(options.buildFormParameters().get("EndTime"), ImmutableList.of("1970-05-23T21:21:18.910Z"));
+   }
+
+   @Test
+   public void testToStatic() {
+      DescribeSpotPriceHistoryOptions options = to(test);
+      assertEquals(options.buildFormParameters().get("EndTime"), ImmutableList.of("1970-05-23T21:21:18.910Z"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testToNPE() {
+      to(null);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java
new file mode 100644
index 0000000..93b3406
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.availabilityZoneGroup;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.launchGroup;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.type;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.validFrom;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.validUntil;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Date;
+
+import com.google.common.collect.ImmutableList;
+
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.http.options.HttpRequestOptions;
+import org.testng.annotations.Test;
+
+/**
+ * Tests possible uses of RequestSpotInstancesOptions and RequestSpotInstancesOptions.Builder.*
+ * 
+ * @author Adrian Cole
+ */
+public class RequestSpotInstancesOptionsTest {
+
+   @Test
+   public void testAssignability() {
+      assert HttpRequestOptions.class.isAssignableFrom(RequestSpotInstancesOptions.class);
+      assert !String.class.isAssignableFrom(RequestSpotInstancesOptions.class);
+   }
+
+   @Test
+   public void testAvailabilityZoneGroup() {
+      RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+      options.availabilityZoneGroup("test");
+      assertEquals(options.buildFormParameters().get("AvailabilityZoneGroup"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testAvailabilityZoneGroupStatic() {
+      RequestSpotInstancesOptions options = availabilityZoneGroup("test");
+      assertEquals(options.buildFormParameters().get("AvailabilityZoneGroup"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testAvailabilityZoneGroupNPE() {
+      availabilityZoneGroup(null);
+   }
+
+   @Test
+   public void testLaunchGroup() {
+      RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+      options.launchGroup("test");
+      assertEquals(options.buildFormParameters().get("LaunchGroup"), ImmutableList.of("test"));
+   }
+
+   @Test
+   public void testLaunchGroupStatic() {
+      RequestSpotInstancesOptions options = launchGroup("test");
+      assertEquals(options.buildFormParameters().get("LaunchGroup"), ImmutableList.of("test"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testLaunchGroupNPE() {
+      launchGroup(null);
+   }
+
+   @Test
+   public void testInstanceType() {
+      RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+      options.type(SpotInstanceRequest.Type.PERSISTENT);
+      assertEquals(options.buildFormParameters().get("Type"), ImmutableList.of("persistent"));
+   }
+
+   @Test
+   public void testInstanceTypeStatic() {
+      RequestSpotInstancesOptions options = type(SpotInstanceRequest.Type.PERSISTENT);
+      assertEquals(options.buildFormParameters().get("Type"), ImmutableList.of("persistent"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testInstanceTypeNPE() {
+      type(null);
+   }
+
+   @Test
+   public void testFrom() {
+      RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+      options.validFrom(test);
+      assertEquals(options.buildFormParameters().get("ValidFrom"),
+            ImmutableList.of("1970-05-23T21:21:18Z"));
+   }
+
+   Date test = new Date(12345678910l);
+
+   @Test
+   public void testFromStatic() {
+      RequestSpotInstancesOptions options = validFrom(test);
+      assertEquals(options.buildFormParameters().get("ValidFrom"),
+            ImmutableList.of("1970-05-23T21:21:18Z"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testFromNPE() {
+      validFrom(null);
+   }
+
+   @Test
+   public void testTo() {
+      RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+      options.validUntil(test);
+      assertEquals(options.buildFormParameters().get("ValidUntil"),
+            ImmutableList.of("1970-05-23T21:21:18Z"));
+   }
+
+   @Test
+   public void testToStatic() {
+      RequestSpotInstancesOptions options = validUntil(test);
+      assertEquals(options.buildFormParameters().get("ValidUntil"),
+            ImmutableList.of("1970-05-23T21:21:18Z"));
+   }
+
+   @Test(expectedExceptions = NullPointerException.class)
+   public void testToNPE() {
+      validUntil(null);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java
new file mode 100644
index 0000000..cc1e953
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.parse;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.domain.Attachment;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code AWSDescribeInstancesResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "AWSDescribeInstancesResponseHandlerTest")
+public class DescribeInstancesResponseTest extends BaseEC2HandlerTest {
+
+   private DateService dateService;
+
+   @BeforeTest
+   @Override
+   protected void setUpInjector() {
+      super.setUpInjector();
+      dateService = injector.getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/describe_instances_pending.xml");
+
+      Set<Reservation<AWSRunningInstance>> expected = expected();
+
+      AWSDescribeInstancesResponseHandler handler = injector.getInstance(AWSDescribeInstancesResponseHandler.class);
+      Set<Reservation<? extends RunningInstance>> result = factory.create(handler).parse(is);
+
+      assertEquals(result.toString(), expected.toString());
+
+   }
+
+   public Set<Reservation<AWSRunningInstance>> expected() {
+      return ImmutableSet.of(Reservation.<AWSRunningInstance>builder()
+                         .region(defaultRegion)
+                         .reservationId("r-3f056a58")
+                         .ownerId("095072994936")
+//                                             <groupId>sg-f788299f</groupId>
+                         .groupName("launchpad_sec_group")
+//                                             <groupId>sg-7e512116</groupId>
+                         .groupName("jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae")
+                         .instance(AWSRunningInstance.builder()
+                                  .region(defaultRegion)
+                                  .instanceId("i-32451248")
+                                  .imageId("ami-bf8131d6")
+                                  .rawState("pending")
+                                  .instanceState(InstanceState.PENDING)
+                                  .privateDnsName("ip-10-194-149-220.ec2.internal")
+                                  .dnsName("ec2-23-20-17-42.compute-1.amazonaws.com")
+                                  .keyName("jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae#105")
+                                  .amiLaunchIndex("0")
+                                  .instanceType("c1.medium")
+                                  .launchTime(dateService.iso8601DateParse("2012-09-14T20:01:34.000Z"))
+                                  .availabilityZone("us-east-1d")
+//                                  .tenancy("default")
+                                  .kernelId("aki-825ea7eb")
+                                  .monitoringState(MonitoringState.DISABLED)
+                                  .privateIpAddress("10.194.149.220")
+                                  .ipAddress("23.20.17.42")
+                                  .securityGroupIdToName("sg-f788299f", "launchpad_sec_group")
+                                  .securityGroupIdToName("sg-7e512116", "jclouds#4c858090-f66c-4225-aa57-6fcaa42198ae")
+//                                  .architecture("x86_64")
+                                  .rootDeviceType(RootDeviceType.EBS)
+                                  .rootDeviceName("/dev/sda1")
+                                  .device("/dev/sda1", new BlockDevice("vol-b2beb3c9", Attachment.Status.ATTACHING, dateService.iso8601DateParse("2012-09-14T20:01:37.000Z"), true))
+                                  .virtualizationType("paravirtual")
+                                  .tag("Name", "4c858090-f66c-4225-aa57-6fcaa42198ae-32451248")
+                                  .hypervisor(Hypervisor.XEN)
+                                  .build()).build());
+   }
+   
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java
new file mode 100644
index 0000000..d3d4148
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.parse;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "DescribeSecurityGroupsResponseTest")
+public class DescribeSecurityGroupsResponseTest extends BaseEC2HandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/describe_security_groups_vpc.xml");
+
+      Set<SecurityGroup> expected = expected();
+
+      DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
+      addDefaultRegionToHandler(handler);
+      Set<SecurityGroup> result = factory.create(handler).parse(is);
+
+      assertEquals(result.toString(), expected.toString());
+   }
+
+   public Set<SecurityGroup> expected() {
+      return ImmutableSet.of(SecurityGroup.builder()
+                                          .region(defaultRegion)
+                                          .ownerId("123123123123")
+                                          .id("sg-11111111")
+                                          .name("default")
+                                          .description("default VPC security group")
+//                                          .vpcId("vpc-99999999")
+                                          .ipPermission(IpPermission.builder()
+                                                                    .ipProtocol(IpProtocol.ALL)
+                                                                    .tenantIdGroupNamePair("123123123123","sg-11111111").build())
+//                                          .ipPermissionEgress(IpPermission.builder()
+//                                                                    .ipProtocol(IpProtocol.ALL)
+//                                                                    .ipRange("0.0.0.0/0").build())
+                                          .build());
+
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java
new file mode 100644
index 0000000..bea5606
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.UnknownHostException;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.domain.Attachment;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.location.Region;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code AWSDescribeInstancesResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "AWSDescribeInstancesResponseHandlerTest")
+public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
+
+   private DateService dateService;
+
+   @BeforeTest
+   @Override
+   protected void setUpInjector() {
+      super.setUpInjector();
+      dateService = injector.getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+
+   public void testWhenRunningLatest() throws UnknownHostException {
+      Set<Reservation<AWSRunningInstance>> contents = ImmutableSet.of(Reservation.<AWSRunningInstance>builder()
+               .region(defaultRegion)
+               .reservationId("r-0f4c2160")
+               .groupName("jclouds#zkclustertest#us-east-1")
+               .instance(AWSRunningInstance.builder()
+                        .region(defaultRegion)
+                        .instanceId("i-911444f0")
+                        .imageId("ami-63be790a")
+                        .instanceState(InstanceState.RUNNING)
+                        .rawState("running")
+                        .privateDnsName("ip-10-212-81-7.ec2.internal")
+                        .dnsName("ec2-174-129-173-155.compute-1.amazonaws.com")
+                        .keyName("jclouds#zkclustertest#us-east-1#23")
+                        .amiLaunchIndex("0")
+                        .instanceType("t1.micro")
+                        .launchTime(dateService.iso8601DateParse("2011-08-16T13:40:50.000Z"))
+                        .availabilityZone("us-east-1c")
+                        .kernelId("aki-427d952b")
+                        .monitoringState(MonitoringState.DISABLED)
+                        .privateIpAddress("10.212.81.7")
+                        .ipAddress("174.129.173.155")
+                        .securityGroupIdToName("sg-ef052b86", "jclouds#zkclustertest#us-east-1")
+                        .tag("Name", "ec2-o")
+                        .tag("Empty", "")
+                        .rootDeviceType(RootDeviceType.EBS)
+                        .rootDeviceName("/dev/sda1")
+                        .device(
+                              "/dev/sda1",
+                              new BlockDevice("vol-5829fc32", Attachment.Status.ATTACHED, dateService
+                                    .iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
+                        .hypervisor(Hypervisor.XEN)
+                        .virtualizationType("paravirtual").build())
+               .instance(AWSRunningInstance.builder()
+                        .region(defaultRegion)
+                        .instanceId("i-931444f2")
+                        .imageId("ami-63be790a")
+                        .instanceState(InstanceState.RUNNING)
+                        .rawState("running")
+                        .privateDnsName("ip-10-212-185-8.ec2.internal")
+                        .dnsName("ec2-50-19-207-248.compute-1.amazonaws.com")
+                        .keyName("jclouds#zkclustertest#us-east-1#23")
+                        .amiLaunchIndex("0")
+                        .instanceType("t1.micro")
+                        .launchTime(dateService.iso8601DateParse("2011-08-16T13:40:50.000Z"))
+                        .availabilityZone("us-east-1c")
+                        .kernelId("aki-427d952b")
+                        .monitoringState(MonitoringState.DISABLED)
+                        .privateIpAddress("10.212.185.8")
+                        .ipAddress("50.19.207.248")
+                        .securityGroupIdToNames(
+                              ImmutableMap.<String, String> of("sg-ef052b86", "jclouds#zkclustertest#us-east-1"))
+                        .rootDeviceType(RootDeviceType.EBS)
+                        .rootDeviceName("/dev/sda1")
+                        .device(
+                              "/dev/sda1",
+                              new BlockDevice("vol-5029fc3a", Attachment.Status.ATTACHED, dateService
+                                    .iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
+                        .hypervisor(Hypervisor.XEN)
+                        .virtualizationType("paravirtual")
+                        .iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver")
+                        .iamInstanceProfileId("AIPAD5ARO2C5EXAMPLE3G")
+                        .build()).build());
+
+      Set<Reservation<? extends RunningInstance>> result = parseAWSRunningInstances("/describe_instances_latest.xml");
+
+      assertEquals(result.toString(), contents.toString());
+   }
+
+   public void testParseNoNPE() {
+      parseAWSRunningInstances("/describe_instances_1.xml");
+      parseAWSRunningInstances("/describe_instances_2.xml");
+      parseAWSRunningInstances("/describe_instances_3.xml");
+   }
+
+   static ParseSax<Set<Reservation<? extends RunningInstance>>> createParser() {
+      Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            bind(new TypeLiteral<Supplier<String>>(){}).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1"));
+            bind(RunningInstance.Builder.class).to(AWSRunningInstance.Builder.class);
+         }
+
+      });
+      ParseSax<Set<Reservation<? extends RunningInstance>>> parser = injector
+            .getInstance(ParseSax.Factory.class)
+            .create(injector.getInstance(AWSDescribeInstancesResponseHandler.class));
+      return parser;
+   }
+
+   public static Set<Reservation<? extends RunningInstance>> parseAWSRunningInstances(String resource) {
+      InputStream is = AWSDescribeInstancesResponseHandlerTest.class.getResourceAsStream(resource);
+      return createParser().parse(is);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java
new file mode 100644
index 0000000..5d15a59
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.location.Region;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code RunInstancesResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "RunInstancesResponseHandlerTest")
+public class AWSRunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
+
+   private DateService dateService;
+
+   @BeforeTest
+   @Override
+   protected void setUpInjector() {
+      injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            bind(new TypeLiteral<Supplier<String>>(){}).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1"));
+            bind(RunningInstance.Builder.class).to(AWSRunningInstance.Builder.class);
+         }
+
+      });
+      factory = injector.getInstance(ParseSax.Factory.class);
+      dateService = injector.getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+   public void testApplyInputStream() {
+
+      InputStream is = getClass().getResourceAsStream("/run_instances.xml");
+
+      Reservation<? extends AWSRunningInstance> expected = Reservation.<AWSRunningInstance>builder()
+               .region(defaultRegion)
+               .instance(AWSRunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("0").imageId(
+                        "ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).rawState(
+                        "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
+                        dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).hypervisor(Hypervisor.XEN)
+                        .monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
+               .instance(AWSRunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("1").imageId(
+                        "ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).rawState(
+                        "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
+                        dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).hypervisor(Hypervisor.XEN)
+                        .monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
+               .instance(AWSRunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("2").imageId(
+                        "ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).rawState(
+                        "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
+                        dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).hypervisor(Hypervisor.XEN)
+                        .monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
+               .ownerId("AIDADH4IGTRXXKCD")
+               .reservationId("r-47a5402e").build();
+
+      AWSRunInstancesResponseHandler handler = injector.getInstance(AWSRunInstancesResponseHandler.class);
+      addDefaultRegionToHandler(handler);
+      Reservation<? extends RunningInstance> result = factory.create(handler).parse(is);
+      assertEquals(result.toString(), expected.toString());
+   }
+
+   public void testApplyInputStreamDoesntNPE() {
+
+      InputStream is = getClass().getResourceAsStream("/run_instances_1.xml");
+      AWSRunInstancesResponseHandler handler = injector.getInstance(AWSRunInstancesResponseHandler.class);
+      addDefaultRegionToHandler(handler);
+      factory.create(handler).parse(is);
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java
new file mode 100644
index 0000000..e0659b1
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code DescribePlacementGroupsResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "DescribePlacementGroupsResponseHandlerTest")
+public class DescribePlacementGroupsResponseHandlerTest extends BaseEC2HandlerTest {
+   public void testApplyInputStream() {
+      InputStream is = getClass().getResourceAsStream("/describe_placement_groups.xml");
+
+      PlacementGroup expected = new PlacementGroup(defaultRegion, "XYZ-cluster", "cluster",
+               PlacementGroup.State.AVAILABLE);
+      DescribePlacementGroupsResponseHandler handler = injector
+               .getInstance(DescribePlacementGroupsResponseHandler.class);
+      addDefaultRegionToHandler(handler);
+      PlacementGroup result = getOnlyElement(factory.create(handler).parse(is));
+
+      assertEquals(result, expected);
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java
new file mode 100644
index 0000000..194f0ca
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.ec2.domain.ReservedInstancesOffering;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of {@code DescribeReservedInstancesOfferingResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "DescribeReservedInstancesOfferingResponseHandlerTest")
+public class DescribeReservedInstancesOfferingResponseHandlerTest extends BaseEC2HandlerTest {
+   public void testApplyInputStream() {
+      InputStream is = getClass().getResourceAsStream("/describe_reserved_instances_offerings.xml");
+
+      ReservedInstancesOffering expected = new ReservedInstancesOffering("us-east-1", "us-east-1a", 12, 0.0f, "m1.small",
+            "m1.small offering in us-east-1a", "4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8", 0.0f);
+
+      DescribeReservedInstancesOfferingResponseHandler handler = injector
+            .getInstance(DescribeReservedInstancesOfferingResponseHandler.class);
+      addDefaultRegionToHandler(handler);
+      ReservedInstancesOffering result = Iterables.getOnlyElement(factory.create(handler).parse(is));
+
+      assertEquals(result, expected);
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
new file mode 100644
index 0000000..ee4f08d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.location.Region;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code DescribeSpotPriceHistoryResponseHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "DescribeSpotPriceHistoryResponseHandlerTest")
+public class DescribeSpotPriceHistoryResponseHandlerTest extends BaseHandlerTest {
+   public void testApplyInputStream() {
+
+      InputStream is = getClass().getResourceAsStream("/describe_spot_price_history.xml");
+
+      Set<Spot> expected = ImmutableSet.of(
+              Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f)
+                      .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z"))
+                      .availabilityZone("us-west-1a").build(),
+              Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f)
+                      .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z"))
+                      .availabilityZone("us-west-1b").build(),
+              Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f)
+                      .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z"))
+                      .availabilityZone("us-west-1c").build()
+
+      );
+
+      Set<Spot> result = factory.create(injector.createChildInjector(new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            bind(new TypeLiteral<Supplier<String>>(){}).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-west-1"));
+         }
+         
+      }).getInstance(DescribeSpotPriceHistoryResponseHandler.class)).parse(is);
+
+      assertEquals(result, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java
new file mode 100644
index 0000000..dd07a06
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests behavior of {@code MonitoringStateHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "MonitoringStateHandlerTest")
+public class MonitoringStateHandlerTest extends BaseHandlerTest {
+   public void testApplyInputStream() {
+
+      InputStream is = getClass().getResourceAsStream("/monitoring.xml");
+
+      Map<String, MonitoringState> expected = ImmutableMap.<String, MonitoringState> of(
+               "i-43a4412a", MonitoringState.PENDING, "i-23a3397d", MonitoringState.PENDING);
+
+      Map<String, MonitoringState> result = factory.create(
+               injector.getInstance(MonitoringStateHandler.class)).parse(is);
+
+      assertEquals(result, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java
new file mode 100644
index 0000000..a93ebb4
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code ProductCodesHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "ProductCodesHandlerTest")
+public class ProductCodesHandlerTest extends BaseHandlerTest {
+   public void testApplyInputStream() {
+
+      InputStream is = getClass().getResourceAsStream(
+               "/describe_image_attribute_productCodes.xml");
+
+      Set<String> expected = ImmutableSet.of("774F4FF8");
+
+      Set<String> result = factory.create(injector.getInstance(ProductCodesHandler.class))
+               .parse(is);
+
+      assertEquals(result, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java
new file mode 100644
index 0000000..dfe18fe
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest.State;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest.Type;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.ec2.xml.BaseEC2HandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.location.Region;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code SpotInstanceHandler}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "SpotInstanceHandlerTest")
+public class SpotInstanceHandlerTest extends BaseEC2HandlerTest {
+
+   private DateService dateService;
+
+   @BeforeTest
+   @Override
+   protected void setUpInjector() {
+      injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            bind(new TypeLiteral<Supplier<String>>(){}).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1"));
+         }
+
+      });
+      factory = injector.getInstance(ParseSax.Factory.class);
+      dateService = injector.getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+   public void testApplyInputStream() {
+
+      InputStream is = getClass().getResourceAsStream("/request_spot_instances-ebs.xml");
+
+      SpotInstanceRequest expected = SpotInstanceRequest
+            .builder()
+            .region("us-east-1")
+            .id("sir-228e6406")
+            .spotPrice(0.001f)
+            .type(Type.ONE_TIME)
+            .state(State.OPEN)
+            .rawState("open")
+            .launchSpecification(
+                  LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupIdToName("sg-83e1c4ea", "default")
+                        .instanceType("m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true)
+                        .mapEBSSnapshotToDevice("/dev/sda2", "snap-1ea27576", 1, true)
+                        .mapEphemeralDeviceToDevice("/dev/sda3", "vre1").monitoringEnabled(false)
+                        .iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver")
+                        .iamInstanceProfileName("Webserver").build())
+            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-03-08T03:30:36.000Z"))
+            .productDescription("Linux/UNIX").build();
+      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
+      addDefaultRegionToHandler(handler);
+      SpotInstanceRequest result = factory.create(handler).parse(is);
+      assertEquals(result.toString(), expected.toString());
+      assertEquals(result.getState(), State.OPEN);
+      assertEquals(result.getRawState(), "open");
+      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getArn().get(),
+            "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
+      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getName().get(), "Webserver");
+   }
+
+   public void testApplyInputStream1() {
+
+      InputStream is = getClass().getResourceAsStream("/describe_spot_instance.xml");
+
+      SpotInstanceRequest expected = SpotInstanceRequest
+            .builder()
+            .region("us-east-1")
+            .id("sir-1ede0012")
+            .instanceId("i-ef308e8e")
+            .spotPrice(0.300000f)
+            .type(Type.ONE_TIME)
+            .state(State.ACTIVE)
+            .rawState("active")
+            .launchedAvailabilityZone("us-east-1b")
+            .launchSpecification(
+                  LaunchSpecification.builder().imageId("ami-8e1fece7")
+                        .securityGroupIdToName("sg-83e1c4eb", "jclouds#adriancole-ec2unssh#us-east-1")
+                        .instanceType("t1.micro").monitoringEnabled(false).keyName("jclouds#adriancole-ec2unssh")
+                        .build())
+            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-07-29T05:27:39.000Z"))
+            .productDescription("Linux/UNIX")
+            .tag("Name", "ec2-o")
+            .tag("Spot", "spot-value")
+            .tag("Empty", "")
+            .build();
+      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
+      addDefaultRegionToHandler(handler);
+      SpotInstanceRequest result = factory.create(handler).parse(is);
+      assertEquals(result.toString(), expected.toString());
+      assertEquals(result.getState(), State.ACTIVE);
+      assertEquals(result.getRawState(), "active");
+   }
+
+   private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
+      handler.setContext(request);
+   }
+}


[07/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java
new file mode 100644
index 0000000..3cbad70
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getInvokerOfRequestAtIndex;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.reference.AWSEC2Constants;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.compute.EC2TemplateBuilderLiveTest;
+import org.jclouds.ec2.compute.predicates.EC2ImagePredicates;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi;
+import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
+import org.jclouds.ec2.options.DescribeRegionsOptions;
+import org.jclouds.ec2.reference.EC2Constants;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService;
+import org.jclouds.location.reference.LocationConstants;
+import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.inject.Module;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "AWSEC2TemplateBuilderLiveTest")
+public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
+
+   public AWSEC2TemplateBuilderLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Override
+   protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
+      return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
+         @Override
+         public boolean apply(OsFamilyVersion64Bit input) {
+            switch (input.family) {
+            case UBUNTU:
+               return true;
+            case DEBIAN:
+               return true;
+            case RHEL:
+                  return input.version.equals("5.6") || input.version.equals("")
+                           || (input.version.matches("[56].0") && input.is64Bit);
+            case CENTOS:
+               return input.version.matches("5.[0246]") || (input.version.equals("6.0") && input.is64Bit)
+                     || input.version.equals("");
+            case WINDOWS:
+               return input.version.matches("200[38]") || (input.version.equals("7") && !input.is64Bit)
+                     || input.version.equals("");
+            default:
+               return false;
+            }
+         }
+
+      });
+   }
+
+   @Test
+   public void testTemplateBuilderM1MEDIUMWithNegativeLookaroundDoesntMatchTestImages() {
+
+      Template template = view.getComputeService().templateBuilder().hardwareId(InstanceType.M1_MEDIUM)
+      // need to select versions with double-digits so that lexicographic
+      // doesn't end up prefering 9.x vs 11.x
+            .osVersionMatches("1[012].[10][04]")
+            // negative lookahead for daily and testing, but ensure match
+            // ubuntu-images
+            // http://www.regular-expressions.info/lookaround.html
+            .imageDescriptionMatches("^(?!.*(daily|testing)).*ubuntu-images.*$").osFamily(OsFamily.UBUNTU).build();
+
+      assert template.getImage().getProviderId().startsWith("ami-") : template;
+      assert template.getImage().getDescription().indexOf("test") == -1 : template;
+      assert template.getImage().getDescription().indexOf("daily") == -1 : template;
+      assertEquals(template.getImage().getVersion(), "20100224");
+      assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.04");
+      assertEquals(template.getImage().getOperatingSystem().is64Bit(), false);
+      assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+      assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+      assertEquals(template.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(template.getHardware()), 1.0d);
+      assertEquals(template.getHardware().getId(), InstanceType.M1_MEDIUM);
+      assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testUbuntuInstanceStoreGoesM1SmallNegativeLookaroundDoesntMatchTestImages() {
+
+      Template template = view.getComputeService().templateBuilder()
+            .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE))
+            // need to select versions with double-digits so that lexicographic
+            // doesn't end up prefering 9.x vs 11.x
+            .osVersionMatches("1[012].[10][04]")
+            // negative lookahead for daily and testing, but ensure match
+            // ubuntu-images
+            // http://www.regular-expressions.info/lookaround.html
+            .imageDescriptionMatches("^(?!.*(daily|testing)).*ubuntu-images.*$").osFamily(OsFamily.UBUNTU).build();
+
+      assert template.getImage().getProviderId().startsWith("ami-") : template;
+      assert template.getImage().getDescription().indexOf("test") == -1 : template;
+      assert template.getImage().getDescription().indexOf("daily") == -1 : template;
+      assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.04");
+      assertEquals(template.getImage().getOperatingSystem().is64Bit(), false);
+      assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+      assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+      assertEquals(template.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(template.getHardware()), 1.0d);
+      assertEquals(template.getHardware().getId(), InstanceType.M1_SMALL);
+      assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testTemplateBuilderCanUseImageIdAndhardwareIdAndAZ() {
+
+      Template template = view.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5")
+            .hardwareId(InstanceType.M2_2XLARGE).locationId("us-east-1a").build();
+
+      assert template.getImage().getProviderId().startsWith("ami-") : template;
+      assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
+      assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
+      assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
+      assertEquals(template.getImage().getVersion(), "4.4.10");
+      assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+      assertEquals(template.getLocation().getId(), "us-east-1a");
+      assertEquals(template.getImage().getLocation().getId(), "us-east-1");
+      assertEquals(getCores(template.getHardware()), 4.0d);
+      assertEquals(template.getHardware().getId(), InstanceType.M2_2XLARGE);
+      assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testDefaultTemplateBuilder() throws IOException {
+      Template defaultTemplate = view.getComputeService().templateBuilder().build();
+      assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate;
+      assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().contains("pv-201"),
+              "Default template version should include 'pv-201' but is "
+                      + defaultTemplate.getImage().getOperatingSystem().getVersion());
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
+      assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
+      assertEquals(defaultTemplate.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testAmazonLinuxInstanceStore() throws IOException {
+
+      Template defaultTemplate = view.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX)
+            .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
+      assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate;
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2013.09.rc-1");
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
+      assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+      assertEquals(defaultTemplate.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
+      assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testFastestTemplateBuilder() throws IOException {
+      Template fastestTemplate = view.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX)
+            .build();
+      assert fastestTemplate.getImage().getProviderId().startsWith("ami-") : fastestTemplate;
+      assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC2_8XLARGE);
+      assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.2");
+      assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
+      assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
+      assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
+      assertEquals(fastestTemplate.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(fastestTemplate.getHardware()), 16.0d);
+      assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm");
+   }
+
+   @Test
+   public void testTemplateBuilderMicro() throws IOException {
+
+      Template microTemplate = view.getComputeService().templateBuilder().hardwareId(InstanceType.T1_MICRO)
+            .osFamily(OsFamily.UBUNTU).osVersionMatches("10.10").os64Bit(true).build();
+
+      assert microTemplate.getImage().getProviderId().startsWith("ami-") : microTemplate;
+      assertEquals(microTemplate.getImage().getOperatingSystem().getVersion(), "10.10");
+      assertEquals(microTemplate.getImage().getOperatingSystem().is64Bit(), true);
+      assertEquals(microTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+      assertEquals(microTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
+      assertEquals(microTemplate.getLocation().getId(), "us-east-1");
+      assertEquals(getCores(microTemplate.getHardware()), 1.0d);
+      assertEquals(microTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
+   }
+
+   @Test
+   public void testTemplateBuilderWithNoOwnersParsesImageOnDemand() throws IOException {
+      ComputeServiceContext context = null;
+      try {
+         Properties overrides = setupProperties();
+         // set owners to nothing
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "");
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
+
+         context = createView(overrides, setupModules());
+
+         assertEquals(context.getComputeService().listImages().size(), 0);
+
+         Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").build();
+         assert template.getImage().getProviderId().startsWith("ami-") : template;
+         assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
+         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
+         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
+         assertEquals(template.getImage().getVersion(), "4.4.10");
+         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+         assertEquals(template.getLocation().getId(), "us-east-1");
+         assertEquals(getCores(template.getHardware()), 1.0d);
+         assertEquals(template.getHardware().getId(), "m1.small");
+
+         // ensure we cache the new image for next time
+         assertEquals(context.getComputeService().listImages().size(), 1);
+
+      } finally {
+         if (context != null)
+            context.close();
+      }
+   }
+
+   @Test
+   public void testTemplateBuilderWithNoOwnersParsesImageOnDemandDeprecated() throws IOException {
+      ComputeServiceContext context = null;
+      try {
+         Properties overrides = setupProperties();
+         // set owners to nothing
+         overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
+
+         context = createView(overrides, setupModules());
+
+         assertEquals(context.getComputeService().listImages().size(), 0);
+
+         Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").build();
+         assert template.getImage().getProviderId().startsWith("ami-") : template;
+         assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
+         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
+         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
+         assertEquals(template.getImage().getVersion(), "4.4.10");
+         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+         assertEquals(template.getLocation().getId(), "us-east-1");
+         assertEquals(getCores(template.getHardware()), 1.0d);
+         assertEquals(template.getHardware().getId(), "m1.small");
+
+         // ensure we cache the new image for next time
+         assertEquals(context.getComputeService().listImages().size(), 1);
+
+      } finally {
+         if (context != null)
+            context.close();
+      }
+   }
+
+   @Test
+   public void testTemplateBuilderWithLessRegions() throws IOException, SecurityException, NoSuchMethodException {
+      ComputeServiceContext context = null;
+      try {
+         Properties overrides = setupProperties();
+         // set regions to only 1
+         overrides.setProperty(LocationConstants.PROPERTY_REGIONS, Region.EU_WEST_1);
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_REGIONS, "");
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "");
+         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
+
+         final List<HttpCommand> commandsInvoked = Lists.newArrayList();
+         
+         context = createView(
+               overrides,
+               ImmutableSet.<Module> of(new Log4JLoggingModule(),
+                     TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));
+
+         assert context.getComputeService().listAssignableLocations().size() < this.view.getComputeService()
+               .listAssignableLocations().size();
+
+         assertOnlyOneRegionQueriedForAvailabilityZone(commandsInvoked);
+
+         assert context.getComputeService().listImages().size() < this.view.getComputeService().listImages().size();
+
+         Template template = context.getComputeService().templateBuilder().imageId("eu-west-1/ami-a33b06d7").build();
+         assert template.getImage().getProviderId().startsWith("ami-") : template;
+         assertEquals(template.getImage().getOperatingSystem().getVersion(), "2011.09.2");
+         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
+         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
+         assertEquals(template.getImage().getVersion(), "2011.09.2");
+         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
+         assertEquals(template.getLocation().getId(), "eu-west-1");
+         assertEquals(getCores(template.getHardware()), 1.0d);
+         assertEquals(template.getHardware().getId(), "m1.small");
+
+      } finally {
+         if (context != null)
+            context.close();
+      }
+   }
+
+   private static void assertOnlyOneRegionQueriedForAvailabilityZone(List<HttpCommand> commandsInvoked)
+         throws NoSuchMethodException {
+      assert commandsInvoked.size() == 2 : commandsInvoked;
+      assertEquals(getInvokerOfRequestAtIndex(commandsInvoked, 0),
+            AvailabilityZoneAndRegionApi.class.getMethod("describeRegions", DescribeRegionsOptions[].class));
+      assertEquals(getInvokerOfRequestAtIndex(commandsInvoked, 1),
+            AvailabilityZoneAndRegionApi.class.getMethod("describeAvailabilityZonesInRegion", String.class,
+                  DescribeAvailabilityZonesOptions[].class));
+   }
+
+   @Test
+   public void testTemplateBuilderCanUseImageIdFromNonDefaultOwner() {
+      // This is the id of a public image, not owned by one of the four default
+      // owners
+      String imageId = "us-east-1/ami-44d02f2d";
+      Template defaultTemplate = view.getComputeService().templateBuilder().imageId(imageId)
+            .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
+      assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate;
+      assertEquals(defaultTemplate.getImage().getId(), imageId);
+   }
+   
+   @Test
+   public void testAssignability() {
+      view.unwrapApi(EC2Api.class);
+      view.unwrapApi(AWSEC2Api.class);
+   }
+
+   @Override
+   protected Set<String> getIso3166Codes() {
+      return ImmutableSet.<String> of("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "AU-NSW", "JP-13");
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java
new file mode 100644
index 0000000..27e3e57
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.config;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.testng.Assert.fail;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheLoader;
+
+/**
+ * @author Aled Sage
+ */
+@Test(groups = "unit")
+public class AWSEC2ComputeServiceContextModuleTest {
+   
+   @Test
+   public void testCacheLoaderDoesNotReloadAfterAuthorizationException() throws Exception {
+      AWSEC2ComputeServiceContextModule module = new AWSEC2ComputeServiceContextModule() {
+         public Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(RegionAndIdToImage delegate) {
+            return super.provideRegionAndNameToImageSupplierCacheLoader(delegate);
+         }
+      };
+      
+      RegionAndName regionAndName = new RegionAndName("myregion", "myname");
+      AuthorizationException authException = new AuthorizationException();
+      
+      RegionAndIdToImage mockRegionAndIdToImage = createMock(RegionAndIdToImage.class);
+      expect(mockRegionAndIdToImage.load(regionAndName)).andThrow(authException).once();
+      replay(mockRegionAndIdToImage);
+      
+      CacheLoader<RegionAndName, Image> cacheLoader = module.provideRegionAndNameToImageSupplierCacheLoader(mockRegionAndIdToImage).get();
+
+      for (int i = 0; i < 2; i++) {
+         try {
+            Image image = cacheLoader.load(regionAndName);
+            fail("Expected Authorization exception, but got " + image);
+         } catch (AuthorizationException e) {
+            // success
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java
new file mode 100644
index 0000000..4ae398b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.extensions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
+import org.jclouds.ec2.compute.functions.EC2ImageParser;
+import org.jclouds.ec2.options.DescribeImagesOptions;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+/**
+ * Live test for aws-ec2 {@link ImageExtension} implementation
+ * 
+ * @author David Alves
+ * 
+ */
+@Test(groups = "live", singleThreaded = true, testName = "AWSEC2ImageExtensionLiveTest")
+public class AWSEC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest {
+
+   public AWSEC2ImageExtensionLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Override
+   protected Iterable<? extends Image> listImages() {
+      AWSEC2Api client = view.unwrapApi(AWSEC2Api.class);
+      String[] parts = AWSUtils.parseHandle(imageId);
+      String region = parts[0];
+      String imageId = parts[1];
+      EC2ImageParser parser = view.utils().injector().getInstance(EC2ImageParser.class);
+      return transform(
+                       client.getAMIApi().get().describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)),
+            parser);
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java
new file mode 100644
index 0000000..f13737a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.SecurityGroupBuilder;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+
+/**
+ * 
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "AWSEC2SecurityGroupExtensionExpectTest")
+public class AWSEC2SecurityGroupExtensionExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   public void testAddIpPermissionCidrFromIpPermission() {
+      HttpRequest describeSecurityGroupsSingleRequest = 
+         formSigner.filter(HttpRequest.builder()
+                           .method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "DescribeSecurityGroups")
+                           .addFormParam("GroupId.1", "sg-3c6ef654").build());
+      
+      HttpResponse describeSecurityGroupsSingleResponse = 
+         HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResourceWithContentType(
+                                                     "/describe_securitygroups_extension_cidr.xml", MediaType.APPLICATION_XML)).build();
+      
+
+      HttpRequest authorizeSecurityGroupIngressRequestRange = 
+               formSigner.filter(HttpRequest.builder()
+                                 .method("POST")
+                                 .endpoint("https://ec2." + region + ".amazonaws.com/")
+                                 .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                                 .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                                 .addFormParam("GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.FromPort", "22")
+                                 .addFormParam("IpPermissions.0.IpProtocol", "tcp")
+                                 .addFormParam("IpPermissions.0.IpRanges.0.CidrIp", "0.0.0.0/0")
+                                 .addFormParam("IpPermissions.0.ToPort", "40")
+                                 .build());
+                                 
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeSecurityGroupsSingleRequest, describeSecurityGroupsSingleResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestRange, authorizeSecurityGroupIngressResponse);
+
+      IpPermission.Builder builder = IpPermission.builder();
+
+      builder.ipProtocol(IpProtocol.TCP);
+      builder.fromPort(22);
+      builder.toPort(40);
+      builder.cidrBlock("0.0.0.0/0");
+
+      IpPermission perm = builder.build();
+
+      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
+      groupBuilder.id("us-east-1/sg-3c6ef654");
+      groupBuilder.providerId("sg-3c6ef654");
+      groupBuilder.name("jclouds#some-group");
+      groupBuilder.location(new LocationBuilder()
+                            .scope(LocationScope.REGION)
+                            .id(region)
+                            .description("region")
+                            .build());
+      
+      SecurityGroup origGroup = groupBuilder.build();
+
+      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
+
+      assertEquals(1, newGroup.getIpPermissions().size());
+
+      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
+
+      assertNotNull(newPerm);
+      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
+      assertEquals(22, newPerm.getFromPort());
+      assertEquals(40, newPerm.getToPort());
+      assertEquals(1, newPerm.getCidrBlocks().size());
+      assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
+   }
+
+   public void testAddIpPermissionCidrFromParams() {
+      HttpRequest describeSecurityGroupsSingleRequest = 
+         formSigner.filter(HttpRequest.builder()
+                           .method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "DescribeSecurityGroups")
+                           .addFormParam("GroupId.1", "sg-3c6ef654").build());
+      
+      HttpResponse describeSecurityGroupsSingleResponse = 
+         HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResourceWithContentType(
+                                                     "/describe_securitygroups_extension_cidr.xml", MediaType.APPLICATION_XML)).build();
+      
+
+      HttpRequest authorizeSecurityGroupIngressRequestRange = 
+               formSigner.filter(HttpRequest.builder()
+                                 .method("POST")
+                                 .endpoint("https://ec2." + region + ".amazonaws.com/")
+                                 .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                                 .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                                 .addFormParam("GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.FromPort", "22")
+                                 .addFormParam("IpPermissions.0.IpProtocol", "tcp")
+                                 .addFormParam("IpPermissions.0.IpRanges.0.CidrIp", "0.0.0.0/0")
+                                 .addFormParam("IpPermissions.0.ToPort", "40")
+                                 .build());
+      
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeSecurityGroupsSingleRequest, describeSecurityGroupsSingleResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestRange, authorizeSecurityGroupIngressResponse);
+
+      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
+      groupBuilder.id("us-east-1/sg-3c6ef654");
+      groupBuilder.providerId("sg-3c6ef654");
+      groupBuilder.name("jclouds#some-group");
+      groupBuilder.location(new LocationBuilder()
+                            .scope(LocationScope.REGION)
+                            .id(region)
+                            .description("region")
+                            .build());
+      
+      SecurityGroup origGroup = groupBuilder.build();
+
+      SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
+                                                         22,
+                                                         40,
+                                                         emptyMultimap(),
+                                                         ImmutableSet.of("0.0.0.0/0"),
+                                                         emptyStringSet(),
+                                                         origGroup);
+
+      assertEquals(1, newGroup.getIpPermissions().size());
+
+      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
+
+      assertNotNull(newPerm);
+      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
+      assertEquals(22, newPerm.getFromPort());
+      assertEquals(40, newPerm.getToPort());
+      assertEquals(1, newPerm.getCidrBlocks().size());
+      assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
+   }
+
+   public void testAddIpPermissionGroupFromIpPermission() {
+      HttpRequest describeSecurityGroupsSingleRequest = 
+         formSigner.filter(HttpRequest.builder()
+                           .method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "DescribeSecurityGroups")
+                           .addFormParam("GroupId.1", "sg-3c6ef654").build());
+      
+      HttpResponse describeSecurityGroupsSingleResponse = 
+         HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResourceWithContentType(
+                                                     "/describe_securitygroups_extension_group.xml", MediaType.APPLICATION_XML)).build();
+      
+
+      HttpRequest authorizeSecurityGroupIngressRequestGroupTenant = 
+               formSigner.filter(HttpRequest.builder()
+                                 .method("POST")
+                                 .endpoint("https://ec2." + region + ".amazonaws.com/")
+                                 .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                                 .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                                 .addFormParam("GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.FromPort", "22")
+                                 .addFormParam("IpPermissions.0.Groups.0.GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.Groups.0.UserId", "993194456877")
+                                 .addFormParam("IpPermissions.0.IpProtocol", "tcp")
+                                 .addFormParam("IpPermissions.0.ToPort", "40")
+                                 .build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeSecurityGroupsSingleRequest, describeSecurityGroupsSingleResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroupTenant, authorizeSecurityGroupIngressResponse);
+
+      IpPermission.Builder builder = IpPermission.builder();
+
+      builder.ipProtocol(IpProtocol.TCP);
+      builder.fromPort(22);
+      builder.toPort(40);
+      builder.tenantIdGroupNamePair("993194456877", "sg-3c6ef654");
+
+      IpPermission perm = builder.build();
+
+      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
+      groupBuilder.id("us-east-1/sg-3c6ef654");
+      groupBuilder.providerId("sg-3c6ef654");
+      groupBuilder.name("jclouds#some-group");
+      groupBuilder.location(new LocationBuilder()
+                            .scope(LocationScope.REGION)
+                            .id(region)
+                            .description("region")
+                            .build());
+      groupBuilder.ownerId("993194456877");
+      
+      SecurityGroup origGroup = groupBuilder.build();
+
+      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
+
+      assertEquals(1, newGroup.getIpPermissions().size());
+
+      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
+
+      assertNotNull(newPerm);
+      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
+      assertEquals(22, newPerm.getFromPort());
+      assertEquals(40, newPerm.getToPort());
+      assertEquals(0, newPerm.getCidrBlocks().size());
+      assertEquals(1, newPerm.getTenantIdGroupNamePairs().size());
+      assertTrue(newPerm.getTenantIdGroupNamePairs().keySet().contains(origGroup.getOwnerId()));
+      assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getProviderId()));
+   }
+
+
+   public void testAddIpPermissionGroupFromParams() {
+      HttpRequest describeSecurityGroupsSingleRequest = 
+         formSigner.filter(HttpRequest.builder()
+                           .method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "DescribeSecurityGroups")
+                           .addFormParam("GroupId.1", "sg-3c6ef654").build());
+      
+      HttpResponse describeSecurityGroupsSingleResponse = 
+         HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResourceWithContentType(
+                                                     "/describe_securitygroups_extension_group.xml", MediaType.APPLICATION_XML)).build();
+
+
+      HttpRequest authorizeSecurityGroupIngressRequestGroupTenant = 
+               formSigner.filter(HttpRequest.builder()
+                                 .method("POST")
+                                 .endpoint("https://ec2." + region + ".amazonaws.com/")
+                                 .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                                 .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                                 .addFormParam("GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.FromPort", "22")
+                                 .addFormParam("IpPermissions.0.Groups.0.GroupId", "sg-3c6ef654")
+                                 .addFormParam("IpPermissions.0.Groups.0.UserId", "993194456877")
+                                 .addFormParam("IpPermissions.0.IpProtocol", "tcp")
+                                 .addFormParam("IpPermissions.0.ToPort", "40")
+                                 .build());
+
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+      requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+      requestResponseMap.put(describeSecurityGroupsSingleRequest, describeSecurityGroupsSingleResponse);
+      requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+      requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+
+      requestResponseMap.put(authorizeSecurityGroupIngressRequestGroupTenant, authorizeSecurityGroupIngressResponse);
+
+      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
+      groupBuilder.id("us-east-1/sg-3c6ef654");
+      groupBuilder.providerId("sg-3c6ef654");
+      groupBuilder.name("jclouds#some-group");
+      groupBuilder.ownerId("993194456877");
+      groupBuilder.location(new LocationBuilder()
+                            .scope(LocationScope.REGION)
+                            .id(region)
+                            .description("region")
+                            .build());
+      
+      SecurityGroup origGroup = groupBuilder.build();
+
+      ImmutableMultimap.Builder<String, String> permBuilder = ImmutableMultimap.builder();
+      permBuilder.put(origGroup.getOwnerId(), origGroup.getId());
+      
+      SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
+                                                         22,
+                                                         40,
+                                                         permBuilder.build(),
+                                                         emptyStringSet(),
+                                                         emptyStringSet(),
+                                                         origGroup);
+
+      assertEquals(1, newGroup.getIpPermissions().size());
+
+      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
+
+      assertNotNull(newPerm);
+      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
+      assertEquals(22, newPerm.getFromPort());
+      assertEquals(40, newPerm.getToPort());
+      assertEquals(0, newPerm.getCidrBlocks().size());
+      assertEquals(1, newPerm.getTenantIdGroupNamePairs().size());
+      assertTrue(newPerm.getTenantIdGroupNamePairs().keySet().contains(origGroup.getOwnerId()));
+      assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getProviderId()));
+   }
+
+   private Multimap<String, String> emptyMultimap() {
+      return LinkedHashMultimap.create();
+   }
+
+   private Set<String> emptyStringSet() {
+      return Sets.newLinkedHashSet();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java
new file mode 100644
index 0000000..c3d77eb
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.extensions;
+
+
+import org.jclouds.compute.extensions.internal.BaseSecurityGroupExtensionLiveTest;
+import org.testng.annotations.Test;
+
+
+/**
+ * Live test for aws-ec2 {@link SecurityGroupExtension} implementation
+ * 
+ * @author Andrew Bayer
+ * 
+ */
+@Test(groups = "live", singleThreaded = true, testName = "AWSEC2SecurityGroupExtensionLiveTest")
+public class AWSEC2SecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest {
+
+   public AWSEC2SecurityGroupExtensionLiveTest() {
+      provider = "aws-ec2";
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java
new file mode 100644
index 0000000..8c0bc44
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.ec2.util.IpPermissions;
+import org.jclouds.net.domain.IpPermission;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "AWSEC2SecurityGroupToSecurityGroupTest")
+public class AWSEC2SecurityGroupToSecurityGroupTest {
+
+   static Location provider = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1")
+         .description("us-east-1").build();
+
+   @Test
+   public void testApply() {
+      IpPermissions authorization = IpPermissions.permitAnyProtocol();
+
+      org.jclouds.ec2.domain.SecurityGroup origGroup = org.jclouds.ec2.domain.SecurityGroup.builder()
+         .region("us-east-1")
+         .id("some-id")
+         .name("some-group")
+         .ownerId("some-owner")
+         .description("some-description")
+         .ipPermission(authorization)
+         .build();
+
+      AWSEC2SecurityGroupToSecurityGroup parser = createGroupParser(ImmutableSet.of(provider));
+
+      SecurityGroup group = parser.apply(origGroup);
+      
+      assertEquals(group.getLocation(), provider);
+      assertEquals(group.getId(), provider.getId() + "/" + origGroup.getId());
+      assertEquals(group.getProviderId(), origGroup.getId());
+      assertEquals(group.getName(), origGroup.getName());
+      assertEquals(group.getIpPermissions(), (Set<IpPermission>)origGroup);
+      assertEquals(group.getOwnerId(), origGroup.getOwnerId());
+   }
+
+   private AWSEC2SecurityGroupToSecurityGroup createGroupParser(final ImmutableSet<Location> locations) {
+      Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
+
+         @Override
+         public Set<? extends Location> get() {
+            return locations;
+         }
+
+      };
+
+      AWSEC2SecurityGroupToSecurityGroup parser = new AWSEC2SecurityGroupToSecurityGroup(locationSupplier);
+
+      return parser;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java
new file mode 100644
index 0000000..f231882
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.AWSEC2ApiMetadata;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.date.DateService;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap;
+import org.jclouds.ec2.domain.Attachment;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.name.Names;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class AWSRunningInstanceToNodeMetadataTest {
+
+   private static final String defaultRegion = "us-east-1";
+   static Location provider = new LocationBuilder().scope(LocationScope.REGION).id(defaultRegion).description(
+            defaultRegion).build();
+
+   private DateService dateService;
+
+   @BeforeTest
+   protected void setUpInjector() {
+      dateService = Guice.createInjector().getInstance(DateService.class);
+      assert dateService != null;
+   }
+
+   @Test
+   public void test2Nodes() {
+
+      AWSRunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
+               .<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
+
+      ImmutableSet<AWSRunningInstance> contents = ImmutableSet.of(new AWSRunningInstance.Builder()
+               .region(defaultRegion)
+               .instanceId("i-911444f0")
+               .imageId("ami-63be790a")
+               .instanceState(InstanceState.RUNNING)
+               .rawState("running")
+               .privateDnsName("ip-10-212-81-7.ec2.internal")
+               .dnsName("ec2-174-129-173-155.compute-1.amazonaws.com")
+               .keyName("jclouds#zkclustertest#23")
+               .amiLaunchIndex("0")
+               .instanceType("t1.micro")
+               .launchTime(dateService.iso8601DateParse("2011-08-16T13:40:50.000Z"))
+               .availabilityZone("us-east-1c")
+               .kernelId("aki-427d952b")
+               .monitoringState(MonitoringState.DISABLED)
+               .privateIpAddress("10.212.81.7")
+               .ipAddress("174.129.173.155")
+               .securityGroupIdToNames(ImmutableMap.<String, String> of("sg-ef052b86", "jclouds#zkclustertest"))
+               .rootDeviceType(RootDeviceType.EBS)
+               .rootDeviceName("/dev/sda1")
+               .device("/dev/sda1", new BlockDevice("vol-5829fc32", Attachment.Status.ATTACHED, dateService.iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
+               .virtualizationType("paravirtual")
+               .tag("Name", "foo")
+               .tag("Empty", "")
+               .hypervisor(Hypervisor.XEN)
+               .build(),//
+               new AWSRunningInstance.Builder()
+                        .region(defaultRegion)
+                        .instanceId("i-931444f2")
+                        .imageId("ami-63be790a")
+                        .instanceState(InstanceState.RUNNING)
+                        .rawState("running")
+                        .privateDnsName("ip-10-212-185-8.ec2.internal")
+                        .dnsName("ec2-50-19-207-248.compute-1.amazonaws.com")
+                        .keyName("jclouds#zkclustertest#23")
+                        .amiLaunchIndex("0")
+                        .instanceType("t1.micro")
+                        .launchTime(dateService.iso8601DateParse("2011-08-16T13:40:50.000Z"))
+                        .availabilityZone("us-east-1c")
+                        .kernelId("aki-427d952b")
+                        .monitoringState(MonitoringState.DISABLED)
+                        .privateIpAddress("10.212.185.8")
+                        .ipAddress("50.19.207.248")
+                        .securityGroupIdToNames(ImmutableMap.<String, String>of("sg-ef052b86", "jclouds#zkclustertest"))
+                        .rootDeviceType(RootDeviceType.EBS)
+                        .rootDeviceName("/dev/sda1")
+                        .device("/dev/sda1", new BlockDevice("vol-5029fc3a", Attachment.Status.ATTACHED, dateService.iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
+                        .virtualizationType("paravirtual")
+                        .hypervisor(Hypervisor.XEN)
+                        .build());
+
+      assertEquals(
+            parser.apply(Iterables.get(contents, 0)).toString(),
+            new NodeMetadataBuilder()
+                  .status(Status.RUNNING)
+                  .backendStatus("running")
+                  .group("zkclustertest")
+                  .name("foo")
+                  .hostname("ip-10-212-81-7")
+                  .privateAddresses(ImmutableSet.of("10.212.81.7"))
+                  .publicAddresses(ImmutableSet.of("174.129.173.155"))
+                  .imageId("us-east-1/ami-63be790a")
+                  .id("us-east-1/i-911444f0")
+                  .providerId("i-911444f0")
+                  .tags(ImmutableSet.of("Empty"))
+                  .userMetadata(ImmutableMap.of("Name", "foo")).build().toString());
+      assertEquals(
+              parser.apply(Iterables.get(contents, 1)).toString(), 
+              new NodeMetadataBuilder()
+                  .status(Status.RUNNING)
+                  .backendStatus("running")
+                  .group("zkclustertest")
+                  .hostname("ip-10-212-185-8")
+                  .privateAddresses(ImmutableSet.of("10.212.185.8"))
+                  .publicAddresses(ImmutableSet.of("50.19.207.248"))
+                  .imageId("us-east-1/ami-63be790a")
+                  .id("us-east-1/i-931444f2")
+                  .providerId("i-931444f2")
+                  .build().toString());
+   }
+
+   protected AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
+            final ImmutableSet<Location> locations, Set<org.jclouds.compute.domain.Image> images,
+            Map<String, Credentials> credentialStore) {
+      Map<InstanceState, Status> instanceToNodeStatus = EC2ComputeServiceDependenciesModule.toPortableNodeStatus;
+
+      final Map<RegionAndName, ? extends Image> backing = ImagesToRegionAndIdMap.imagesToMap(images);
+
+      LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
+    
+         @Override
+         public Image load(RegionAndName key) throws Exception {
+            return backing.get(key);
+         }
+         
+      });
+            
+          
+      return createNodeParser(hardware, locations, credentialStore, instanceToNodeStatus, instanceToImage);
+   }
+
+   private AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
+            final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
+            Map<InstanceState, Status> instanceToNodeStatus, LoadingCache<RegionAndName, ? extends Image> instanceToImage) {
+      Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
+
+         @Override
+         public Set<? extends Location> get() {
+            return locations;
+         }
+
+      };
+      Supplier<Set<? extends Hardware>> hardwareSupplier = new Supplier<Set<? extends Hardware>>() {
+
+         @Override
+         public Set<? extends Hardware> get() {
+            return hardware;
+         }
+
+      };
+      
+      GroupNamingConvention.Factory namingConvention = Guice.createInjector(new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            Names.bindProperties(binder(),new AWSEC2ApiMetadata().getDefaultProperties());
+         }
+
+      }).getInstance(GroupNamingConvention.Factory.class);
+
+      AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeStatus,
+            credentialStore, Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage),
+            locationSupplier, hardwareSupplier, namingConvention);
+      return parser;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java
new file mode 100644
index 0000000..babe978
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.features.AWSInstanceApi;
+import org.jclouds.aws.ec2.features.SpotInstanceApi;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.domain.Reservation;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class PresentSpotRequestsAndInstancesTest {
+   AWSRunningInstance instance1 = createMock(AWSRunningInstance.class);
+   AWSRunningInstance instance2 = createMock(AWSRunningInstance.class);
+
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testWhenInstancesPresentSingleCall() {
+
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSInstanceApi instanceApi = createMock(AWSInstanceApi.class);
+      Function<SpotInstanceRequest, AWSRunningInstance> converter = createMock(Function.class);
+
+      expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceApi));
+      
+      // avoid imatcher fail.  if you change this, be sure to check multiple jres
+      expect(instanceApi.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn(
+            Set.class.cast(ImmutableSet.of(Reservation.<AWSRunningInstance> builder().region("us-east-1")
+                  .instances(ImmutableSet.of(instance1, instance2)).build())));
+
+      replay(client, instanceApi, converter);
+
+      PresentSpotRequestsAndInstances fn = new PresentSpotRequestsAndInstances(client, converter);
+
+      assertEquals(fn.apply(ImmutableSet.of(new RegionAndName("us-east-1", "i-aaaa"), new RegionAndName("us-east-1",
+            "i-bbbb"))), ImmutableSet.of(instance1, instance2));
+
+      verify(client, instanceApi, converter);
+   }
+
+   SpotInstanceRequest spot1 = createMock(SpotInstanceRequest.class);
+   SpotInstanceRequest spot2 = createMock(SpotInstanceRequest.class);
+
+   @Test
+   public void testWhenSpotsPresentSingleCall() {
+
+      Function<SpotInstanceRequest, AWSRunningInstance> converter = Functions.forMap(ImmutableMap.of(spot1, instance1,
+            spot2, instance2));
+
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      SpotInstanceApi spotApi = createMock(SpotInstanceApi.class);
+
+      expect(client.getSpotInstanceApi()).andReturn((Optional) Optional.of(spotApi));
+      expect(spotApi.describeSpotInstanceRequestsInRegion("us-east-1", "sir-aaaa", "sir-bbbb")).andReturn(
+            ImmutableSet.of(spot1, spot2));
+
+      replay(client, spotApi);
+
+      PresentSpotRequestsAndInstances fn = new PresentSpotRequestsAndInstances(client, converter);
+
+      assertEquals(fn.apply(ImmutableSet.of(new RegionAndName("us-east-1", "sir-aaaa"), new RegionAndName("us-east-1",
+            "sir-bbbb"))), ImmutableSet.of(instance1, instance2));
+
+      verify(client, spotApi);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java
new file mode 100644
index 0000000..c5f9838
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.internal;
+
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.testng.annotations.BeforeClass;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests the compute service abstraction of the EC2 api.
+ * 
+ * @author Adrian Cole
+ */
+public abstract class BaseAWSEC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest {
+
+   protected HttpRequest describeSecurityGroupByIdRequest;
+
+   public BaseAWSEC2ComputeServiceExpectTest() {
+      provider = "aws-ec2";
+   }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties properties = super.setupProperties();
+      // zero out cluster image query for now
+      properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
+      properties.setProperty(PROPERTY_EC2_GENERATE_INSTANCE_NAMES, "false");
+      return properties;
+   }
+
+   @BeforeClass
+   @Override
+   protected void setupDefaultRequests() {
+      super.setupDefaultRequests();
+
+      describeSecurityGroupByIdRequest =
+              formSigner.filter(HttpRequest.builder()
+                      .method("POST")
+                      .endpoint("https://ec2." + region + ".amazonaws.com/")
+                      .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                      .addFormParam("Action", "DescribeSecurityGroups")
+                      .addFormParam("GroupId.1", "sg-3c6ef654").build());
+
+      authorizeSecurityGroupIngressRequestGroup =
+              formSigner.filter(HttpRequest.builder()
+                      .method("POST")
+                      .endpoint("https://ec2." + region + ".amazonaws.com/")
+                      .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                      .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                      .addFormParam("SourceSecurityGroupId", "sg-3c6ef654")
+                      .addFormParam("SourceSecurityGroupOwnerId", "993194456877")
+                      .addFormParam("GroupName", "jclouds#test").build());
+
+      authorizeSecurityGroupIngressRequest22 = 
+         formSigner.filter(HttpRequest.builder()
+                           .method("POST")
+                           .endpoint("https://ec2." + region + ".amazonaws.com/")
+                           .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                           .addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                           .addFormParam("GroupId", "sg-3c6ef654")
+                           .addFormParam("IpPermissions.0.FromPort", "22")
+                           .addFormParam("IpPermissions.0.ToPort", "22")
+                           .addFormParam("IpPermissions.0.IpRanges.0.CidrIp", "0.0.0.0/0")
+                           .addFormParam("IpPermissions.0.IpProtocol", "tcp")
+                           .addFormParam("IpPermissions.1.FromPort", "0")
+                           .addFormParam("IpPermissions.1.ToPort", "65535")
+                           .addFormParam("IpPermissions.1.Groups.0.GroupId", "sg-3c6ef654")
+                           .addFormParam("IpPermissions.1.Groups.0.UserId", "993194456877")
+                           .addFormParam("IpPermissions.1.IpProtocol", "tcp")
+                           .addFormParam("IpPermissions.2.FromPort", "0")
+                           .addFormParam("IpPermissions.2.ToPort", "65535")
+                           .addFormParam("IpPermissions.2.Groups.0.GroupId", "sg-3c6ef654")
+                           .addFormParam("IpPermissions.2.Groups.0.UserId", "993194456877")
+                           .addFormParam("IpPermissions.2.IpProtocol", "udp")
+                           .build());
+
+      describeImagesRequest = 
+               formSigner.filter(HttpRequest.builder()
+                          .method("POST")
+                          .endpoint("https://ec2." + region + ".amazonaws.com/")
+                          .addHeader("Host", "ec2." + region + ".amazonaws.com")
+                          .addFormParam("Action", "DescribeImages")
+                          .addFormParam("Filter.1.Name", "owner-id")
+                          .addFormParam("Filter.1.Value.1", "137112412989")
+                          .addFormParam("Filter.1.Value.2", "801119661308")
+                          .addFormParam("Filter.1.Value.3", "063491364108")
+                          .addFormParam("Filter.1.Value.4", "099720109477")
+                          .addFormParam("Filter.1.Value.5", "411009282317")
+                          .addFormParam("Filter.2.Name", "state")
+                          .addFormParam("Filter.2.Value.1", "available")
+                          .addFormParam("Filter.3.Name", "image-type")
+                          .addFormParam("Filter.3.Value.1", "machine").build());
+   }
+
+   @ConfiguresHttpApi
+   protected static class TestAWSEC2HttpApiModule extends AWSEC2HttpApiModule {
+
+      @Override
+      protected void configure() {
+         super.configure();
+         // predicatable node names
+         final AtomicInteger suffix = new AtomicInteger();
+         bind(new TypeLiteral<Supplier<String>>() {
+         }).toInstance(new Supplier<String>() {
+
+            @Override
+            public String get() {
+               return suffix.getAndIncrement() + "";
+            }
+
+         });
+      }
+
+      @Override
+      @Provides
+      protected String provideTimeStamp(DateService dateService) {
+         return CONSTANT_DATE;
+      }
+   }
+
+   @Override
+   protected Module createModule() {
+      return new TestAWSEC2HttpApiModule();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java
new file mode 100644
index 0000000..60f86f5
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute.loaders;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
+import org.jclouds.ec2.compute.functions.EC2SecurityGroupIdFromName;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", singleThreaded = true, testName = "AWSEC2CreateSecurityGroupIfNeeded")
+public class AWSEC2CreateSecurityGroupIfNeededTest {
+
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testWhenPort22AndToItselfAuthorizesIngressOnce() throws ExecutionException {
+
+      AWSSecurityGroupApi client = createMock(AWSSecurityGroupApi.class);
+      Predicate<RegionAndName> tester = Predicates.alwaysTrue();
+
+      SecurityGroup group = createNiceMock(SecurityGroup.class);
+      Set<SecurityGroup> groups = ImmutableSet.<SecurityGroup> of(group);
+
+      EC2SecurityGroupIdFromName groupIdFromName = createMock(EC2SecurityGroupIdFromName.class);
+
+      ImmutableSet.Builder<IpPermission> permissions = ImmutableSet.builder();
+
+      permissions.add(IpPermission.builder()
+                      .fromPort(22)
+                      .toPort(22)
+                      .ipProtocol(IpProtocol.TCP)
+                      .cidrBlock("0.0.0.0/0")
+                      .build());
+
+      permissions.add(IpPermission.builder()
+                      .fromPort(0)
+                      .toPort(65535)
+                      .ipProtocol(IpProtocol.TCP)
+                      .tenantIdGroupNamePair("ownerId", "sg-123456")
+                      .build());
+      permissions.add(IpPermission.builder()
+                      .fromPort(0)
+                      .toPort(65535)
+                      .ipProtocol(IpProtocol.UDP)
+                      .tenantIdGroupNamePair("ownerId", "sg-123456")
+                      .build());
+      
+      client.createSecurityGroupInRegion("region", "group", "group");
+      expect(group.getOwnerId()).andReturn("ownerId");
+      expect(groupIdFromName.apply("region/group")).andReturn("sg-123456");
+      client.authorizeSecurityGroupIngressInRegion("region", "sg-123456", permissions.build());
+      expect(client.describeSecurityGroupsInRegion("region", "group")).andReturn(Set.class.cast(groups));
+
+
+      replay(client);
+      replay(group);
+      replay(groupIdFromName);
+
+      AWSEC2CreateSecurityGroupIfNeeded function = new AWSEC2CreateSecurityGroupIfNeeded(client, groupIdFromName, tester);
+
+      assertEquals("group", function.load(new RegionNameAndIngressRules("region", "group", new int[] { 22 }, true)));
+
+      verify(client);
+      verify(group);
+      verify(groupIdFromName);
+
+   }
+}


[09/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java
new file mode 100644
index 0000000..a11ac54
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.rest.annotations.SinceApiVersion;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Contains options supported in the Form API for the RunInstances operation. <h2>
+ * Usage</h2> The recommended way to instantiate a RunInstancesOptions object is to statically
+ * import RunInstancesOptions.Builder.* and invoke a static creation method followed by an instance
+ * mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.*
+ * <p/>
+ * EC2Api connection = // get connection
+ * Future<ReservationInfo> instances = connection.runInstances(executableBy("123125").imageIds(1000, 1004));
+ * <code>
+ * 
+ * @author Adrian Cole
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RunInstances.html"
+ *      />
+ */
+public class AWSRunInstancesOptions extends RunInstancesOptions {
+   private LaunchSpecification.Builder launchSpecificationBuilder = LaunchSpecification.builder();
+   public static final AWSRunInstancesOptions NONE = new AWSRunInstancesOptions();
+
+   /**
+    * Specifies the name of an existing placement group you want to launch the instance into (for
+    * cluster compute instances).
+    * 
+    * @param placementGroup
+    *           name of an existing placement group
+    */
+   public AWSRunInstancesOptions inPlacementGroup(String placementGroup) {
+      formParameters.put("Placement.GroupName", checkNotNull(placementGroup, "placementGroup"));
+      return this;
+   }
+
+   /**
+    * Enables monitoring for the instance.
+    */
+   public AWSRunInstancesOptions enableMonitoring() {
+      formParameters.put("Monitoring.Enabled", "true");
+      launchSpecificationBuilder.monitoringEnabled(true);
+      return this;
+   }
+
+   /**
+    * Specifies the subnet ID within which to launch the instance(s) for Amazon Virtual Private
+    * Cloud.
+    */
+   public AWSRunInstancesOptions withSubnetId(String subnetId) {
+      formParameters.put("SubnetId", checkNotNull(subnetId, "subnetId"));
+      return this;
+   }
+
+   public AWSRunInstancesOptions withSecurityGroupId(String securityGroup) {
+      return withSecurityGroupIds(securityGroup);
+   }
+
+   public AWSRunInstancesOptions withSecurityGroupIds(Iterable<String> securityGroupIds) {
+      launchSpecificationBuilder.securityGroupIds(securityGroupIds);
+      indexFormValuesWithPrefix("SecurityGroupId", securityGroupIds);
+      return this;
+   }
+
+   public AWSRunInstancesOptions withSecurityGroupIds(String... securityGroupIds) {
+      return withSecurityGroupIds(ImmutableSet.copyOf(securityGroupIds));
+   }
+
+   /**
+    * Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instances.
+    * 
+    * @see org.jclouds.aws.ec2.domain.AWSRunningInstance#getIAMInstanceProfile()
+    */
+   @SinceApiVersion("2012-06-01")
+   public AWSRunInstancesOptions withIAMInstanceProfileArn(String arn) {
+      formParameters.put("IamInstanceProfile.Arn", checkNotNull(arn, "arn"));
+      return this;
+   }
+
+   /**
+    * The name of the IAM Instance Profile (IIP) to associate with the instances.
+    * 
+    * @see org.jclouds.aws.ec2.domain.AWSRunningInstance#getIAMInstanceProfile()
+    */
+   @SinceApiVersion("2012-06-01")
+   public AWSRunInstancesOptions withIAMInstanceProfileName(String name) {
+      formParameters.put("IamInstanceProfile.Name", checkNotNull(name, "name"));
+      return this;
+   }
+
+   public static class Builder extends RunInstancesOptions.Builder {
+
+      /**
+       * @see AWSRunInstancesOptions#withSecurityGroupId(String)
+       */
+      public static AWSRunInstancesOptions withSecurityGroupId(String securityGroup) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withSecurityGroupId(securityGroup);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#inPlacementGroup(String)
+       */
+      public static AWSRunInstancesOptions inPlacementGroup(String placementGroup) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.inPlacementGroup(placementGroup);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#enableMonitoring()
+       */
+      public static AWSRunInstancesOptions enableMonitoring() {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.enableMonitoring();
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withSubnetId(String)
+       */
+      public static AWSRunInstancesOptions withSubnetId(String subnetId) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withSubnetId(subnetId);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withIAMInstanceProfileArn(String)
+       */
+      public static AWSRunInstancesOptions withIAMInstanceProfileArn(String arn) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withIAMInstanceProfileArn(arn);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withIAMInstanceProfileName(String)
+       */
+      public static AWSRunInstancesOptions withIAMInstanceProfileName(String id) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withIAMInstanceProfileName(id);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withKeyName(String)
+       */
+      public static AWSRunInstancesOptions withKeyName(String keyName) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withKeyName(keyName);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withSecurityGroup(String)
+       */
+      public static AWSRunInstancesOptions withSecurityGroup(String securityGroup) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withSecurityGroup(securityGroup);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withUserData(byte [])
+       */
+      public static AWSRunInstancesOptions withUserData(byte[] unencodedData) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withUserData(unencodedData);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#asType(InstanceType)
+       */
+      public static AWSRunInstancesOptions asType(String instanceType) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.asType(instanceType);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withKernelId(String)
+       */
+      public static AWSRunInstancesOptions withKernelId(String kernelId) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withKernelId(kernelId);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withRamdisk(String)
+       */
+      public static AWSRunInstancesOptions withRamdisk(String ramdiskId) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withRamdisk(ramdiskId);
+      }
+
+      /**
+       * @see AWSRunInstancesOptions#withBlockDeviceMappings(Set<BlockDeviceMapping> mappings)
+       */
+      public static AWSRunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) {
+         AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+         return options.withBlockDeviceMappings(mappings);
+      }
+
+   }
+
+   @Override
+   public AWSRunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) {
+      launchSpecificationBuilder.blockDeviceMappings(mappings);
+      return AWSRunInstancesOptions.class.cast(super.withBlockDeviceMappings(mappings));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withKernelId(String kernelId) {
+      launchSpecificationBuilder.kernelId(kernelId);
+      return AWSRunInstancesOptions.class.cast(super.withKernelId(kernelId));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withKeyName(String keyName) {
+      launchSpecificationBuilder.keyName(keyName);
+      return AWSRunInstancesOptions.class.cast(super.withKeyName(keyName));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withRamdisk(String ramDiskId) {
+      launchSpecificationBuilder.ramdiskId(ramDiskId);
+      return AWSRunInstancesOptions.class.cast(super.withRamdisk(ramDiskId));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withSecurityGroup(String securityGroup) {
+      launchSpecificationBuilder.securityGroupName(securityGroup);
+      return AWSRunInstancesOptions.class.cast(super.withSecurityGroup(securityGroup));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withSecurityGroups(Iterable<String> securityGroups) {
+      launchSpecificationBuilder.securityGroupNames(securityGroups);
+      return AWSRunInstancesOptions.class.cast(super.withSecurityGroups(securityGroups));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withSecurityGroups(String... securityGroups) {
+      launchSpecificationBuilder.securityGroupNames(ImmutableSet.copyOf(securityGroups));
+      return AWSRunInstancesOptions.class.cast(super.withSecurityGroups(securityGroups));
+   }
+
+   @Override
+   public AWSRunInstancesOptions withUserData(byte[] unencodedData) {
+      launchSpecificationBuilder.userData(unencodedData);
+      return AWSRunInstancesOptions.class.cast(super.withUserData(unencodedData));
+   }
+
+   @Override
+   public AWSRunInstancesOptions asType(String type) {
+      launchSpecificationBuilder.instanceType(type);
+      return AWSRunInstancesOptions.class.cast(super.asType(type));
+   }
+
+   public synchronized LaunchSpecification.Builder getLaunchSpecificationBuilder() {
+      try {
+         return launchSpecificationBuilder.imageId("fake").build().toBuilder().imageId(null);
+      } finally {
+         launchSpecificationBuilder.imageId(null);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java
new file mode 100644
index 0000000..3a929bf
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
+
+/**
+ * Contains options supported in the Form API for the CreateSecurityGroup
+ * operation. <h2>
+ * Usage</h2> The recommended way to instantiate a CreateSecurityGroupOptions
+ * object is to statically import CreateSecurityGroupOptions.Builder.* and
+ * invoke a static creation method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.options.CreateSecurityGroupOptions.Builder.*
+ * <p/>
+ * AWSEC2Api connection = // get connection
+ * group = connection.getAMIServices().createSecurityGroup(vpcId("123125").noReboot());
+ * <code>
+ * 
+ * @author Adrian Cole
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-CreateSecurityGroup.html"
+ *      />
+ */
+public class CreateSecurityGroupOptions extends BaseEC2RequestOptions {
+
+   /**
+    * ID of the VPC.
+    */
+   public CreateSecurityGroupOptions vpcId(String vpcId) {
+      formParameters.put("VpcId", checkNotNull(vpcId, "vpcId"));
+      return this;
+   }
+
+   public static class Builder {
+
+      /**
+       * @see CreateSecurityGroupOptions#vpcId(String )
+       */
+      public static CreateSecurityGroupOptions vpcId(String vpcId) {
+         CreateSecurityGroupOptions options = new CreateSecurityGroupOptions();
+         return options.vpcId(vpcId);
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java
new file mode 100644
index 0000000..228f681
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
+
+/**
+ * Contains options supported in the Form API for the DescribeSpotPriceHistory operation. <h2>
+ * Usage</h2> The recommended way to instantiate a DescribeSpotPriceHistoryOptions object is to
+ * statically import DescribeSpotPriceHistoryOptions.Builder.* and invoke a static creation method
+ * followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.*
+ * <p/>
+ * AWSEC2Api client = // get connection
+ * history = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(from(yesterday).instanceType("m1.small"));
+ * <code>
+ * 
+ * @author Adrian Cole
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeSpotPriceHistory.html"
+ *      />
+ */
+public class DescribeSpotPriceHistoryOptions extends BaseEC2RequestOptions {
+   public static final DescribeSpotPriceHistoryOptions NONE = new DescribeSpotPriceHistoryOptions();
+   private static final DateService service = new SimpleDateFormatDateService();
+
+   /**
+    * Start date and time of the Spot Instance price history data.
+    */
+   public DescribeSpotPriceHistoryOptions from(Date start) {
+      formParameters.put("StartTime", service.iso8601DateFormat(checkNotNull(start, "start")));
+      return this;
+   }
+
+   /**
+    * End date and time of the Spot Instance price history data.
+    */
+   public DescribeSpotPriceHistoryOptions to(Date end) {
+      formParameters.put("EndTime", service.iso8601DateFormat(checkNotNull(end, "end")));
+      return this;
+   }
+
+   /**
+    * Specifies the instance type to return.
+    */
+   public DescribeSpotPriceHistoryOptions instanceType(String type) {
+      formParameters.put("InstanceType.1", checkNotNull(type, "type"));
+      return this;
+   }
+
+   /**
+    * The description of the AMI.
+    */
+   public DescribeSpotPriceHistoryOptions productDescription(String description) {
+      formParameters.put("ProductDescription", checkNotNull(description, "description"));
+      return this;
+   }
+
+   public static class Builder {
+      /**
+       * @see DescribeSpotPriceHistoryOptions#from
+       */
+      public static DescribeSpotPriceHistoryOptions from(Date start) {
+         DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+         return options.from(start);
+      }
+
+      /**
+       * @see DescribeSpotPriceHistoryOptions#to
+       */
+      public static DescribeSpotPriceHistoryOptions to(Date end) {
+         DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+         return options.to(end);
+      }
+
+      /**
+       * @see DescribeSpotPriceHistoryOptions#instanceType(InstanceType)
+       */
+      public static DescribeSpotPriceHistoryOptions instanceType(String instanceType) {
+         DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+         return options.instanceType(instanceType);
+      }
+
+      /**
+       * @see DescribeSpotPriceHistoryOptions#productDescription(String)
+       */
+      public static DescribeSpotPriceHistoryOptions productDescription(String description) {
+         DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
+         return options.productDescription(description);
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java
new file mode 100644
index 0000000..7f90269
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
+
+/**
+ * Contains options supported in the Form API for the RequestSpotInstances operation. <h2>
+ * Usage</h2> The recommended way validUntil instantiate a RequestSpotInstancesOptions object is
+ * validUntil statically import RequestSpotInstancesOptions.Builder.* and invoke a static creation
+ * method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.*
+ * <p/>
+ * AWSEC2Api client = // get connection
+ * history = client.getSpotInstanceServices().requestSpotInstancesInRegion("us-east-1",validFrom(yesterday).type("m1.small"));
+ * <code>
+ * 
+ * @author Adrian Cole
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RequestSpotInstances.html"
+ *      />
+ */
+public class RequestSpotInstancesOptions extends BaseEC2RequestOptions {
+   public static final RequestSpotInstancesOptions NONE = new RequestSpotInstancesOptions();
+   private static final DateService service = new SimpleDateFormatDateService();
+
+   /**
+    * Start date of the request. If this is a one-time request, the request becomes active at this
+    * date and time and remains active until all instances launch, the request expires, or the
+    * request is canceled. If the request is persistent, the request becomes active at this date and
+    * time and remains active until it expires or is canceled.
+    */
+   public RequestSpotInstancesOptions validFrom(Date start) {
+      formParameters.put("ValidFrom", service.iso8601SecondsDateFormat(checkNotNull(start, "start")));
+      return this;
+   }
+
+   /**
+    * End date of the request. If this is a one-time request, the request remains active until all
+    * instances launch, the request is canceled, or this date is reached. If the request is
+    * persistent, it remains active until it is canceled or this date and time is reached.
+    */
+   public RequestSpotInstancesOptions validUntil(Date end) {
+      formParameters.put("ValidUntil", service.iso8601SecondsDateFormat(checkNotNull(end, "end")));
+      return this;
+   }
+
+   /**
+    * Specifies the Spot Instance type.
+    */
+   public RequestSpotInstancesOptions type(SpotInstanceRequest.Type type) {
+      formParameters.put("Type", checkNotNull(type, "type").toString());
+      return this;
+   }
+
+   /**
+    * Specifies the instance launch group. Launch groups are Spot Instances that launch together and
+    * terminate together.
+    */
+   public RequestSpotInstancesOptions launchGroup(String launchGroup) {
+      formParameters.put("LaunchGroup", checkNotNull(launchGroup, "launchGroup"));
+      return this;
+   }
+
+   /**
+    * Specifies the Availability Zone group. If you specify the same Availability Zone group for all
+    * Spot Instance requests, all Spot Instances are launched in the same Availability Zone.
+    */
+   public RequestSpotInstancesOptions availabilityZoneGroup(String availabilityZoneGroup) {
+      formParameters.put("AvailabilityZoneGroup", checkNotNull(availabilityZoneGroup, "availabilityZoneGroup"));
+      return this;
+   }
+
+   public static class Builder {
+      /**
+       * @see RequestSpotInstancesOptions#validFrom
+       */
+      public static RequestSpotInstancesOptions validFrom(Date start) {
+         RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+         return options.validFrom(start);
+      }
+
+      /**
+       * @see RequestSpotInstancesOptions#validUntil
+       */
+      public static RequestSpotInstancesOptions validUntil(Date end) {
+         RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+         return options.validUntil(end);
+      }
+
+      /**
+       * @see RequestSpotInstancesOptions#type
+       */
+      public static RequestSpotInstancesOptions type(SpotInstanceRequest.Type type) {
+         RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+         return options.type(type);
+      }
+
+      /**
+       * @see RequestSpotInstancesOptions#launchGroup(String)
+       */
+      public static RequestSpotInstancesOptions launchGroup(String launchGroup) {
+         RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+         return options.launchGroup(launchGroup);
+      }
+
+      /**
+       * @see RequestSpotInstancesOptions#availabilityZoneGroup
+       */
+      public static RequestSpotInstancesOptions availabilityZoneGroup(String availabilityZoneGroup) {
+         RequestSpotInstancesOptions options = new RequestSpotInstancesOptions();
+         return options.availabilityZoneGroup(availabilityZoneGroup);
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java
new file mode 100644
index 0000000..c04b8d5
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.predicates;
+
+import java.util.NoSuchElementException;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * 
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class PlacementGroupAvailable implements Predicate<PlacementGroup> {
+
+   private final AWSEC2Api client;
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   @Inject
+   public PlacementGroupAvailable(AWSEC2Api client) {
+      this.client = client;
+   }
+
+   public boolean apply(PlacementGroup group) {
+      logger.trace("looking for state on group %s", group);
+      try {
+         group = refresh(group);
+         logger.trace("%s: looking for group state %s: currently: %s", group.getName(), PlacementGroup.State.AVAILABLE,
+                  group.getState());
+         return group.getState() == PlacementGroup.State.AVAILABLE;
+      } catch (ResourceNotFoundException e) {
+         return false;
+      } catch (NoSuchElementException e) {
+         return false;
+      }
+   }
+
+   private PlacementGroup refresh(PlacementGroup group) {
+      return Iterables.getOnlyElement(client.getPlacementGroupApi().get().describePlacementGroupsInRegion(
+               group.getRegion(), group.getName()));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java
new file mode 100644
index 0000000..b8257eb
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.predicates;
+
+import java.util.NoSuchElementException;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * 
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class PlacementGroupDeleted implements Predicate<PlacementGroup> {
+
+   private final AWSEC2Api client;
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   @Inject
+   public PlacementGroupDeleted(AWSEC2Api client) {
+      this.client = client;
+   }
+
+   public boolean apply(PlacementGroup group) {
+      logger.trace("looking for state on group %s", group);
+      try {
+         group = refresh(group);
+      } catch (NoSuchElementException e) {
+         return true;
+      }
+      logger.trace("%s: looking for group state %s: currently: %s", group.getName(), PlacementGroup.State.DELETED,
+               group.getState());
+      return group.getState() == PlacementGroup.State.DELETED;
+   }
+
+   private PlacementGroup refresh(PlacementGroup group) {
+      return Iterables.getOnlyElement(client.getPlacementGroupApi().get().describePlacementGroupsInRegion(
+               group.getRegion(), group.getName()));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java
new file mode 100644
index 0000000..8395161
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.predicates;
+
+import java.util.NoSuchElementException;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * 
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class SpotInstanceRequestActive implements Predicate<SpotInstanceRequest> {
+
+   private final AWSEC2Api client;
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   @Inject
+   public SpotInstanceRequestActive(AWSEC2Api client) {
+      this.client = client;
+   }
+
+   public boolean apply(SpotInstanceRequest spot) {
+      logger.trace("looking for state on spot %s", spot);
+      try {
+         spot = refresh(spot);
+         logger.trace("%s: looking for spot state %s: currently: %s", spot.getId(), SpotInstanceRequest.State.ACTIVE,
+                  spot.getState());
+         if (spot.getState() == SpotInstanceRequest.State.CANCELLED
+                  || spot.getState() == SpotInstanceRequest.State.CLOSED)
+            throw new IllegalStateException(String.format("spot request %s %s", spot.getId(), spot.getState()));
+         if (spot.getFaultCode() != null)
+            throw new IllegalStateException(String.format("spot request %s fault code(%s) message(%s)", spot.getId(),
+                     spot.getFaultCode(), spot.getFaultMessage()));
+         return spot.getState() == SpotInstanceRequest.State.ACTIVE;
+      } catch (ResourceNotFoundException e) {
+         return false;
+      } catch (NoSuchElementException e) {
+         return false;
+      }
+   }
+
+   private SpotInstanceRequest refresh(SpotInstanceRequest spot) {
+      return Iterables.getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
+               spot.getRegion(), spot.getId()));
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java
new file mode 100644
index 0000000..d2cc3c7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.reference;
+
+import org.jclouds.ec2.reference.EC2Constants;
+
+/**
+ * Configuration properties and constants used in EC2 connections.
+ * 
+ * @author Adrian Cole
+ */
+public interface AWSEC2Constants extends EC2Constants {
+   /**
+    * expression to find amis that work on the cluster instance type <br/>
+    * ex. {@code
+    * virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;
+    * state=available;image-type=machine;root-device-type=ebs}
+    * 
+    * @see InstanceType.CC1_4XLARGE
+    */
+   public static final String PROPERTY_EC2_CC_AMI_QUERY = "jclouds.ec2.cc-ami-query";
+   public static final String PROPERTY_EC2_CC_REGIONS = "jclouds.ec2.cc-regions";
+   public static final String PROPERTY_EC2_AMI_QUERY = "jclouds.ec2.ami-query";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java
new file mode 100644
index 0000000..4ae3e97
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.xml.TagSetHandler;
+import org.jclouds.location.Region;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * Parses the following XML document:
+ * <p/>
+ * DescribeImagesResponse xmlns="http:
+ * 
+ * @author Adrian Cole
+ * @see <a href="http: />
+ */
+public class AWSDescribeInstancesResponseHandler extends
+      BaseAWSReservationHandler<Set<Reservation<? extends RunningInstance>>> {
+   private final TagSetHandler tagSetHandler;
+   private Builder<Reservation<? extends RunningInstance>> reservations = ImmutableSet.<Reservation<? extends RunningInstance>>builder();
+   private boolean inTagSet;
+
+   @Inject
+   AWSDescribeInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
+         TagSetHandler tagSetHandler) {
+      super(dateCodecFactory, defaultRegion);
+      this.tagSetHandler = tagSetHandler;
+   }
+
+   @Override
+   public void startElement(String uri, String name, String qName, Attributes attrs) throws SAXException {
+      super.startElement(uri, name, qName, attrs);
+      if (equalsOrSuffix(qName, "tagSet")) {
+         inTagSet = true;
+      }
+      if (inTagSet) {
+         tagSetHandler.startElement(uri, name, qName, attrs);
+      }
+   }
+
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inTagSet) {
+         tagSetHandler.characters(ch, start, length);
+      } else {
+         super.characters(ch, start, length);
+      }
+   }
+
+   @Override
+   public void endElement(String uri, String name, String qName) {
+      if (equalsOrSuffix(qName, "tagSet")) {
+         inTagSet = false;
+         builder.tags(tagSetHandler.getResult());
+      } else if (inTagSet) {
+         tagSetHandler.endElement(uri, name, qName);
+      }
+      super.endElement(uri, name, qName);
+   }
+
+   @Override
+   public Set<Reservation<? extends RunningInstance>> getResult() {
+      return reservations.build();
+   }
+
+   protected boolean endOfReservationItem() {
+      return itemDepth == 1;
+   }
+
+   @Override
+   protected void inItem() {
+      if (endOfReservationItem()) {
+         reservations.add(super.newReservation());
+      } else {
+         super.inItem();
+      }
+   }
+
+   protected boolean endOfInstanceItem() {
+      return itemDepth == 2 && inInstancesSet;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2DescribeSecurityGroupsResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2DescribeSecurityGroupsResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2DescribeSecurityGroupsResponseHandler.java
new file mode 100644
index 0000000..4c25f3e
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2DescribeSecurityGroupsResponseHandler.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * Parses: DescribeSecurityGroupsResponse
+ * xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
+ *
+ * @see <a href=
+ *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribesecurityGroupInfo.html"
+ *      />
+ * @author Adrian Cole
+ */
+public class AWSEC2DescribeSecurityGroupsResponseHandler extends
+      HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> {
+
+   private final AWSEC2SecurityGroupHandler securityGroupHandler;
+
+   private StringBuilder currentText = new StringBuilder();
+   private Builder<SecurityGroup> securityGroups = ImmutableSet.<SecurityGroup> builder();
+   private boolean inSecurityGroupInfo;
+
+   protected int itemDepth;
+
+   @Inject
+   public AWSEC2DescribeSecurityGroupsResponseHandler(AWSEC2SecurityGroupHandler securityGroupHandler) {
+      this.securityGroupHandler = securityGroupHandler;
+   }
+
+   @Override
+   public HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> setContext(HttpRequest request) {
+      securityGroupHandler.setContext(request);
+      return super.setContext(request);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Set<SecurityGroup> getResult() {
+      return securityGroups.build();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
+      if (equalsOrSuffix(qName, "item")) {
+         itemDepth++;
+      } else if (equalsOrSuffix(qName, "securityGroupInfo")) {
+         inSecurityGroupInfo = true;
+      }
+      if (inSecurityGroupInfo) {
+         securityGroupHandler.startElement(url, name, qName, attributes);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void endElement(String uri, String name, String qName) throws SAXException {
+      if (equalsOrSuffix(qName, "item")) {
+         endItem(uri, name, qName);
+         itemDepth--;
+      } else if (equalsOrSuffix(qName, "securityGroupInfo")) {
+         inSecurityGroupInfo = false;
+      } else if (inSecurityGroupInfo) {
+         securityGroupHandler.endElement(uri, name, qName);
+      }
+      currentText = new StringBuilder();
+   }
+
+   protected void endItem(String uri, String name, String qName) throws SAXException {
+      if (inSecurityGroupInfo) {
+         if (itemDepth == 1)
+            securityGroups.add(securityGroupHandler.getResult());
+         else
+            securityGroupHandler.endElement(uri, name, qName);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inSecurityGroupInfo) {
+         securityGroupHandler.characters(ch, start, length);
+      } else {
+         currentText.append(ch, start, length);
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java
new file mode 100644
index 0000000..392fb5f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class AWSEC2IpPermissionHandler extends ParseSax.HandlerForGeneratedRequestWithResult<IpPermission> {
+
+   private StringBuilder currentText = new StringBuilder();
+   private IpPermission.Builder builder = IpPermission.builder();
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public IpPermission getResult() {
+      try {
+         return builder.build();
+      } finally {
+         builder = IpPermission.builder();
+      }
+   }
+
+   private String userId;
+   private String groupId;
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void endElement(String uri, String name, String qName) throws SAXException {
+      if (equalsOrSuffix(qName, "ipProtocol")) {
+         // Algorete: ipProtocol can be an empty tag on EC2 clone (e.g.
+         // OpenStack EC2)
+         builder.ipProtocol(IpProtocol.fromValue(currentOrNegative(currentText)));
+      } else if (equalsOrSuffix(qName, "fromPort")) {
+         // Algorete: fromPort can be an empty tag on EC2 clone (e.g. OpenStack
+         // EC2)
+         builder.fromPort(Integer.parseInt(currentOrNegative(currentText)));
+      } else if (equalsOrSuffix(qName, "toPort")) {
+         // Algorete: toPort can be an empty tag on EC2 clone (e.g. OpenStack
+         // EC2)
+         builder.toPort(Integer.parseInt(currentOrNegative(currentText)));
+      } else if (equalsOrSuffix(qName, "cidrIp")) {
+         builder.cidrBlock(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "userId")) {
+         this.userId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "groupId")) {
+         this.groupId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "item")) {
+         if (userId != null && groupId != null)
+            builder.tenantIdGroupNamePair(userId, groupId);
+         userId = groupId = null;
+      }
+      currentText = new StringBuilder();
+   }
+
+   private static String currentOrNegative(StringBuilder currentText) {
+      String returnVal = currentText.toString().trim();
+      return returnVal.equals("") ? "-1" : returnVal;
+   }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java
new file mode 100644
index 0000000..552303b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
+import org.jclouds.location.Region;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+/**
+ * @author Adrian Cole
+ */
+public class AWSEC2SecurityGroupHandler extends HandlerForGeneratedRequestWithResult<SecurityGroup> {
+
+   protected final AWSEC2IpPermissionHandler ipPermissionHandler;
+   protected final Supplier<String> defaultRegion;
+
+   protected StringBuilder currentText = new StringBuilder();
+   protected SecurityGroup.Builder<?> builder;
+   protected boolean inIpPermissions;
+
+   protected int itemDepth;
+
+   protected String region;
+
+   @Inject
+   public AWSEC2SecurityGroupHandler(AWSEC2IpPermissionHandler ipPermissionHandler, @Region Supplier<String> defaultRegion) {
+      this.ipPermissionHandler = ipPermissionHandler;
+      this.defaultRegion = defaultRegion;
+   }
+
+   protected SecurityGroup.Builder<?> builder() {
+      return SecurityGroup.builder().region(region);
+   }
+
+   @Override
+   public HandlerForGeneratedRequestWithResult<SecurityGroup> setContext(HttpRequest request) {
+      region = AWSUtils.findRegionInArgsOrNull(GeneratedHttpRequest.class.cast(request));
+      if (region == null)
+         region = defaultRegion.get();
+      builder = builder();
+      return super.setContext(request);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public SecurityGroup getResult() {
+      try {
+         return builder.build();
+      } finally {
+         builder = builder();
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
+      if (equalsOrSuffix(qName, "item")) {
+         itemDepth++;
+      } else if (equalsOrSuffix(qName, "ipPermissions")) {
+         inIpPermissions = true;
+      }
+      if (inIpPermissions) {
+         ipPermissionHandler.startElement(url, name, qName, attributes);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void endElement(String uri, String name, String qName) throws SAXException {
+      if (equalsOrSuffix(qName, "item")) {
+         endItem(uri, name, qName);
+         itemDepth--;
+      } else if (equalsOrSuffix(qName, "ipPermissions")) {
+         inIpPermissions = false;
+         itemDepth = 0;
+      } else if (inIpPermissions) {
+         ipPermissionHandler.endElement(uri, name, qName);
+      } else if (equalsOrSuffix(qName, "groupName")) {
+         builder.name(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "groupId")) {
+         builder.id(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "ownerId")) {
+         builder.ownerId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "groupDescription")) {
+         builder.description(currentOrNull(currentText));
+      }
+      currentText = new StringBuilder();
+   }
+
+   protected void endItem(String uri, String name, String qName) throws SAXException {
+      if (inIpPermissions) {
+         if (itemDepth == 2)
+            builder.ipPermission(ipPermissionHandler.getResult());
+         else
+            ipPermissionHandler.endElement(uri, name, qName);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inIpPermissions) {
+         ipPermissionHandler.characters(ch, start, length);
+      } else {
+         currentText.append(ch, start, length);
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java
new file mode 100644
index 0000000..b2ca4d2
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import javax.inject.Inject;
+
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ * Parses the following XML document:
+ * <p/>
+ * RunInstancesResponse xmlns="http:
+ * 
+ * @author Adrian Cole
+ * @see <a href="http: />
+ */
+public class AWSRunInstancesResponseHandler extends BaseAWSReservationHandler<Reservation<? extends RunningInstance>> {
+
+   @Inject
+   AWSRunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
+      super(dateCodecFactory, defaultRegion);
+   }
+
+   @Override
+   public Reservation<? extends RunningInstance> getResult() {
+      return newReservation();
+   }
+
+   protected boolean endOfInstanceItem() {
+      return itemDepth == 1 && inInstancesSet;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java
new file mode 100644
index 0000000..af11bc3
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.ec2.domain.Attachment;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.Hypervisor;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RootDeviceType;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
+import org.jclouds.location.Region;
+import org.jclouds.logging.Logger;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRequestWithResult<T> {
+
+   @Resource
+   protected Logger logger = Logger.NULL;
+
+   protected final DateCodec dateCodec;
+   protected final Supplier<String> defaultRegion;
+
+   @Inject
+   public BaseAWSReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
+      this.dateCodec = dateCodecFactory.iso8601();
+      this.defaultRegion = defaultRegion;
+   }
+
+   protected AWSRunningInstance.Builder builder = newBuilder();
+
+   protected AWSRunningInstance.Builder newBuilder() {
+      return AWSRunningInstance.builder();
+   }
+
+   protected StringBuilder currentText = new StringBuilder();
+   
+   protected int itemDepth;
+   boolean inInstancesSet;
+   // attachments
+   private String volumeId;
+   private Attachment.Status attachmentStatus;
+   private Date attachTime;
+   private boolean deleteOnTermination;
+   private String deviceName;
+
+   // reservation stuff
+   private String groupId;
+   private Map<String, String> reservationGroupIdToNames = Maps.newLinkedHashMap();
+   private String ownerId;
+   private String requesterId;
+   private String reservationId;
+
+   private Set<RunningInstance> instances = Sets.newLinkedHashSet();
+
+   private boolean inPlacement;
+   private boolean inIamInstanceProfile;
+
+   @Override
+   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+      if (equalsOrSuffix(qName, "item")) {
+         itemDepth++;
+      } else if (equalsOrSuffix(qName, "instancesSet")) {
+         inInstancesSet = true;
+      } else if (equalsOrSuffix(qName, "placement")) {
+         inPlacement = true;
+      } else if (equalsOrSuffix(qName, "iamInstanceProfile")) {
+         inIamInstanceProfile = true;
+      }
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (equalsOrSuffix(qName, "item")) {
+         inItem();
+         itemDepth--;
+      } else if (equalsOrSuffix(qName, "state")) {
+         builder.monitoringState(MonitoringState.fromValue(currentOrNull(currentText)));
+      } else if (equalsOrSuffix(qName, "groupId")) {
+         groupId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "groupName") && inPlacement) {
+         builder.placementGroup(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "arn") && inIamInstanceProfile) {
+         builder.iamInstanceProfileArn(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "id") && inIamInstanceProfile) {
+         builder.iamInstanceProfileId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "groupName")) {
+         switch (itemDepth) {
+         case 2:
+            reservationGroupIdToNames.put(groupId, currentOrNull(currentText));
+            break;
+         case 3:
+            builder.securityGroupIdToName(groupId, currentOrNull(currentText));
+            break;
+         }
+         groupId = null;
+      } else if (equalsOrSuffix(qName, "subnetId")) {
+         builder.subnetId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "spotInstanceRequestId")) {
+         builder.spotInstanceRequestId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "vpcId")) {
+         builder.vpcId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "hypervisor")) {
+         builder.hypervisor(Hypervisor.fromValue(currentOrNull(currentText)));
+      } else if (equalsOrSuffix(qName, "productCode")) {
+         builder.productCode(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "instancesSet")) {
+         inInstancesSet = false;
+      } else if (equalsOrSuffix(qName, "placement")) {
+         inPlacement = false;
+      } else if (equalsOrSuffix(qName, "iamInstanceProfile")) {
+         inIamInstanceProfile = false;
+      } else if (equalsOrSuffix(qName, "ownerId")) {
+         ownerId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "requesterId")) {
+         requesterId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "reservationId")) {
+         reservationId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "amiLaunchIndex")) {
+         builder.amiLaunchIndex(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "dnsName")) {
+         builder.dnsName(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "imageId")) {
+         builder.imageId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "instanceId")) {
+         builder.instanceId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "name")) {
+         String rawState = currentOrNull(currentText);
+         builder.rawState(rawState);
+         builder.instanceState(InstanceState.fromValue(rawState));
+      } else if (equalsOrSuffix(qName, "instanceType")) {
+         builder.instanceType(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "ipAddress")) {
+         builder.ipAddress(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "kernelId")) {
+         builder.kernelId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "keyName")) {
+         builder.keyName(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "launchTime")) {
+         builder.launchTime(dateCodec.toDate(currentOrNull(currentText)));
+      } else if (equalsOrSuffix(qName, "availabilityZone")) {
+         builder.availabilityZone(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "virtualizationType")) {
+         builder.virtualizationType(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "platform")) {
+         builder.platform(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "privateDnsName")) {
+         builder.privateDnsName(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "privateIpAddress")) {
+         builder.privateIpAddress(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "ramdiskId")) {
+         builder.ramdiskId(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "reason")) {
+         builder.reason(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "rootDeviceType")) {
+         builder.rootDeviceType(RootDeviceType.fromValue(currentOrNull(currentText)));
+      } else if (equalsOrSuffix(qName, "rootDeviceName")) {
+         builder.rootDeviceName(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "deviceName")) {
+         deviceName = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "volumeId")) {
+         volumeId = currentOrNull(currentText);
+      } else if (equalsOrSuffix(qName, "status")) {
+         attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
+      } else if (equalsOrSuffix(qName, "attachTime")) {
+         attachTime = dateCodec.toDate(currentOrNull(currentText));
+      } else if (equalsOrSuffix(qName, "deleteOnTermination")) {
+         deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
+      } else if (equalsOrSuffix(qName, "ebs")) {
+         builder.device(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination));
+         this.deviceName = null;
+         this.volumeId = null;
+         this.attachmentStatus = null;
+         this.attachTime = null;
+         this.deleteOnTermination = true;
+      }
+      currentText = new StringBuilder();
+   }
+   
+   protected void inItem() {
+      if (endOfInstanceItem()) {
+         refineBuilderBeforeAddingInstance();
+         instances.add(builder.build());
+         builder = newBuilder();
+      }
+   }
+
+   protected void refineBuilderBeforeAddingInstance() {
+      String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
+      builder.region((region == null) ? defaultRegion.get() : region);
+   }
+
+   protected abstract boolean endOfInstanceItem();
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+
+   protected Reservation<? extends RunningInstance> newReservation() {
+      String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
+      if (region == null)
+         region = defaultRegion.get();
+      Reservation<? extends RunningInstance> info = new Reservation<RunningInstance>(region,
+            reservationGroupIdToNames.values(), instances, ownerId, requesterId, reservationId);
+      this.reservationGroupIdToNames = Maps.newLinkedHashMap();
+      this.instances = Sets.newLinkedHashSet();
+      this.ownerId = null;
+      this.requesterId = null;
+      this.reservationId = null;
+      return info;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/CreateSecurityGroupResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/CreateSecurityGroupResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/CreateSecurityGroupResponseHandler.java
new file mode 100644
index 0000000..76fdda0
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/CreateSecurityGroupResponseHandler.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import org.jclouds.http.functions.ParseSax;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class CreateSecurityGroupResponseHandler extends ParseSax.HandlerWithResult<String> {
+
+   private StringBuilder currentText = new StringBuilder();
+   String id;
+
+   public String getResult() {
+      return id;
+   }
+
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("groupId")) {
+         id = currentText.toString().trim();
+      }
+      currentText = new StringBuilder();
+   }
+
+   public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandler.java
new file mode 100644
index 0000000..5620005
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandler.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.HandlerWithResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Sets;
+
+/**
+ * @author Adrian Cole
+ */
+public class DescribePlacementGroupsResponseHandler extends
+         ParseSax.HandlerWithResult<Set<PlacementGroup>> {
+
+   private Set<PlacementGroup> bundleTasks = Sets.newLinkedHashSet();
+   private final PlacementGroupHandler bundleTaskHandler;
+
+   @Inject
+   public DescribePlacementGroupsResponseHandler(PlacementGroupHandler bundleTaskHandler) {
+      this.bundleTaskHandler = bundleTaskHandler;
+   }
+
+   public Set<PlacementGroup> getResult() {
+      return bundleTasks;
+   }
+
+   @Override
+   public HandlerWithResult<Set<PlacementGroup>> setContext(HttpRequest request) {
+      bundleTaskHandler.setContext(request);
+      return super.setContext(request);
+   }
+
+   @Override
+   public void startElement(String uri, String localName, String qName, Attributes attributes)
+            throws SAXException {
+      if (!qName.equals("item"))
+         bundleTaskHandler.startElement(uri, localName, qName, attributes);
+   }
+
+   @Override
+   public void endElement(String uri, String localName, String qName) throws SAXException {
+      if (qName.equals("item")) {
+         bundleTasks.add(bundleTaskHandler.getResult());
+      }
+      bundleTaskHandler.endElement(uri, localName, qName);
+   }
+
+   public void characters(char ch[], int start, int length) {
+      bundleTaskHandler.characters(ch, start, length);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandler.java
new file mode 100644
index 0000000..fdf6abc
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandler.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.ec2.domain.ReservedInstancesOffering;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.HandlerWithResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Sets;
+
+/**
+ * @author Adrian Cole
+ */
+public class DescribeReservedInstancesOfferingResponseHandler extends
+      ParseSax.HandlerWithResult<Set<ReservedInstancesOffering>> {
+
+   private Set<ReservedInstancesOffering> reservedInstancesOfferings = Sets.newLinkedHashSet();
+   private final ReservedInstancesOfferingHandler reservedInstancesOffering;
+
+   @Inject
+   public DescribeReservedInstancesOfferingResponseHandler(ReservedInstancesOfferingHandler reservedInstancesOffering) {
+      this.reservedInstancesOffering = reservedInstancesOffering;
+   }
+
+   public Set<ReservedInstancesOffering> getResult() {
+      return reservedInstancesOfferings;
+   }
+
+   @Override
+   public HandlerWithResult<Set<ReservedInstancesOffering>> setContext(HttpRequest request) {
+      reservedInstancesOffering.setContext(request);
+      return super.setContext(request);
+   }
+
+   @Override
+   public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+      if (!qName.equals("item"))
+         reservedInstancesOffering.startElement(uri, localName, qName, attributes);
+   }
+
+   @Override
+   public void endElement(String uri, String localName, String qName) throws SAXException {
+      if (qName.equals("item")) {
+         reservedInstancesOfferings.add(reservedInstancesOffering.getResult());
+      }
+      reservedInstancesOffering.endElement(uri, localName, qName);
+   }
+
+   public void characters(char ch[], int start, int length) {
+      reservedInstancesOffering.characters(ch, start, length);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java
new file mode 100644
index 0000000..bb3f32d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.xml;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.HandlerWithResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * @author Adrian Cole
+ */
+public class DescribeSpotPriceHistoryResponseHandler extends
+         ParseSax.HandlerWithResult<Set<Spot>> {
+
+   private Builder<Spot> spots = ImmutableSet.builder();
+   private final SpotHandler spotHandler;
+
+   @Inject
+   public DescribeSpotPriceHistoryResponseHandler(SpotHandler spotHandler) {
+      this.spotHandler = spotHandler;
+   }
+
+   public Set<Spot> getResult() {
+      return spots.build();
+   }
+
+   @Override
+   public HandlerWithResult<Set<Spot>> setContext(HttpRequest request) {
+      spotHandler.setContext(request);
+      return super.setContext(request);
+   }
+
+   @Override
+   public void startElement(String uri, String localName, String qName, Attributes attributes)
+            throws SAXException {
+      if (!qName.equals("item"))
+         spotHandler.startElement(uri, localName, qName, attributes);
+   }
+
+   @Override
+   public void endElement(String uri, String localName, String qName) throws SAXException {
+      if (qName.equals("item")) {
+         spots.add(spotHandler.getResult());
+      }
+      spotHandler.endElement(uri, localName, qName);
+   }
+
+   public void characters(char ch[], int start, int length) {
+      spotHandler.characters(ch, start, length);
+   }
+
+}


[04/13] Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..7766d17
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.domain.UserIdGroupPair;
+import org.jclouds.ec2.features.SecurityGroupApiLiveTest;
+import org.jclouds.ec2.util.IpPermissions;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMultimap;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class AWSSecurityGroupApiLiveTest extends SecurityGroupApiLiveTest {
+   public AWSSecurityGroupApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressSourceGroup() {
+      final String group1Name = PREFIX + "ingress1";
+      String group2Name = PREFIX + "ingress2";
+      cleanupAndSleep(group2Name);
+      cleanupAndSleep(group1Name);
+      try {
+         final String group1Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+                 group1Name, group1Name);
+         String group2Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+                 group2Name, group2Name);
+         ensureGroupsExist(group1Name, group2Name);
+         client.authorizeSecurityGroupIngressInRegion(null, group1Name, IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
+         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
+         assertNotNull(oneResult);
+         assertEquals(oneResult.size(), 1);
+         final SecurityGroup group = oneResult.iterator().next();
+         assertEquals(group.getName(), group1Name);
+         final UserIdGroupPair to = new UserIdGroupPair(group.getOwnerId(), group1Name);
+         client.authorizeSecurityGroupIngressInRegion(null, group2Name, to);
+         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
+            @Override
+            public boolean apply(IpPermission arg0) {
+               return arg0.getTenantIdGroupNamePairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Id));
+            }
+         }));
+
+         client.revokeSecurityGroupIngressInRegion(null, group2Name,
+                 new UserIdGroupPair(group.getOwnerId(), group1Name));
+         assertEventually(new GroupHasNoPermissions(client, group2Name));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, group2Name);
+         client.deleteSecurityGroupInRegion(null, group1Name);
+      }
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressIpPermission() throws InterruptedException {
+      final String group1Name = PREFIX + "ingress11";
+      String group2Name = PREFIX + "ingress12";
+      cleanupAndSleep(group2Name);
+      cleanupAndSleep(group1Name);
+      try {
+         final String group1Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+               group1Name, group1Name);
+         final String group2Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+               group2Name, group2Name);
+         Thread.sleep(100);// eventual consistent
+         ensureGroupsExist(group1Name, group2Name);
+         AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group1Id,
+               IpPermissions.permit(IpProtocol.TCP).port(80));
+         assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
+         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
+         assertNotNull(oneResult);
+         assertEquals(oneResult.size(), 1);
+         final SecurityGroup group = oneResult.iterator().next();
+         assertEquals(group.getName(), group1Name);
+         IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).port(80)
+               .originatingFromSecurityGroupId(group1Id);
+         AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id,
+               group2CanHttpGroup1);
+         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
+            @Override
+            public boolean apply(IpPermission arg0) {
+               return arg0.getTenantIdGroupNamePairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Id))
+                     && arg0.getFromPort() == 80 && arg0.getToPort() == 80 && arg0.getIpProtocol() == IpProtocol.TCP;
+            }
+         }));
+
+         AWSSecurityGroupApi.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id,
+               group2CanHttpGroup1);
+         assertEventually(new GroupHasNoPermissions(client, group2Name));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, group2Name);
+         client.deleteSecurityGroupInRegion(null, group1Name);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
new file mode 100644
index 0000000..8b696ef
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.xml.AWSEC2DescribeSecurityGroupsResponseHandler;
+import org.jclouds.ec2.util.IpPermissions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code AWSSecurityGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "AWSSecurityGroupApiTest")
+public class AWSSecurityGroupApiTest extends BaseAWSEC2ApiTest<AWSSecurityGroupApi> {
+   public AWSSecurityGroupApiTest() {
+      provider = "aws-ec2";
+   }
+
+   public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "deleteSecurityGroupInRegionById", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DeleteSecurityGroup&GroupId=id",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeSecurityGroups",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSEC2DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeSecurityGroups&GroupId.1=1&GroupId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSEC2DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest createSecurityGroup = HttpRequest.builder().method("POST")
+                                                .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                .addFormParam("Action", "CreateSecurityGroup")
+                                                .addFormParam("GroupDescription", "description")
+                                                .addFormParam("GroupName", "name").build();
+
+   public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "createSecurityGroupInRegion", String.class,
+            String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "description"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(createSecurityGroup).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testAuthorizeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
+            String.class, String.class, IpPermission.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testAuthorizeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
+            String.class, String.class, Iterable.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
+            .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
+            .originatingFromSecurityGroupId("groupId"))));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRevokeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
+            String.class, IpPermission.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRevokeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
+            String.class, Iterable.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
+            .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
+            .originatingFromSecurityGroupId("groupId"))));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
new file mode 100644
index 0000000..74d4839
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import org.jclouds.ec2.features.SubnetApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "AWSSubnetApiLiveTest")
+public class AWSSubnetApiLiveTest extends SubnetApiLiveTest {
+   public AWSSubnetApiLiveTest() {
+      provider = "aws-ec2";
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
new file mode 100644
index 0000000..f617c9b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.collect.Maps.transformValues;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2ProviderMetadata;
+import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.location.config.LocationModule;
+import org.jclouds.location.suppliers.RegionIdToURISupplier;
+import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.internal.BaseAsyncApiTest;
+import org.jclouds.util.Suppliers2;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public abstract class BaseAWSEC2ApiTest<T> extends BaseAsyncApiTest<T> {
+
+      @ConfiguresHttpApi
+   protected static class StubAWSEC2HttpApiModule extends AWSEC2HttpApiModule {
+
+      @Override
+      protected String provideTimeStamp(DateService dateService) {
+         return "2009-11-08T15:54:08.897Z";
+      }
+
+      @Provides
+      @Singleton
+      LoadingCache<RegionAndName, Image> provide() {
+         return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
+
+            @Override
+            public Image load(RegionAndName key) throws Exception {
+               return null;
+            }
+
+         });
+      }
+
+      @Override
+      protected void installLocations() {
+         install(new LocationModule());
+         bind(RegionIdToURISupplier.class).toInstance(new RegionIdToURISupplier() {
+
+            @Override
+            public Map<String, Supplier<URI>> get() {
+               return transformValues(ImmutableMap.<String, URI> of(Region.EU_WEST_1, URI
+                        .create("https://ec2.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI
+                        .create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
+                        .create("https://ec2.us-west-1.amazonaws.com")), Suppliers2.<URI> ofInstanceFunction());
+            }
+
+         });
+         bind(RegionIdToZoneIdsSupplier.class).toInstance(new RegionIdToZoneIdsSupplier() {
+
+            @Override
+            public Map<String, Supplier<Set<String>>> get() {
+               return transformValues(ImmutableMap.<String, Set<String>> of("us-east-1", ImmutableSet.of("us-east-1a",
+                        "us-east-1b", "us-east-1c", "us-east-1b")), Suppliers2.<Set<String>> ofInstanceFunction());
+            }
+
+         });
+      }
+   }
+
+   protected FormSigner filter;
+
+   @Override
+   protected void checkFilters(HttpRequest request) {
+      assertEquals(request.getFilters().size(), 1);
+      assertEquals(request.getFilters().get(0).getClass(), FormSigner.class);
+   }
+
+   @Override
+   @BeforeTest
+   protected void setupFactory() throws IOException {
+      super.setupFactory();
+      this.filter = injector.getInstance(FormSigner.class);
+   }
+
+   @Override
+   protected Module createModule() {
+      return new StubAWSEC2HttpApiModule();
+   }
+
+   protected String provider = "aws-ec2";
+
+   @Override
+   public AWSEC2ProviderMetadata createProviderMetadata() {
+      return new AWSEC2ProviderMetadata();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
new file mode 100644
index 0000000..65c6ebd
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code MonitoringApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class MonitoringApiLiveTest extends BaseComputeServiceContextLiveTest {
+   public MonitoringApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private MonitoringApi client;
+   private static final String DEFAULT_INSTANCE = "i-TODO";
+
+   
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class).getMonitoringApi().get();
+   }
+
+   @Test(enabled = false)
+   // TODO get instance
+   public void testMonitorInstances() {
+      Map<String, MonitoringState> monitoringState = client.monitorInstancesInRegion(null, DEFAULT_INSTANCE);
+      assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
+   }
+
+   @Test(enabled = false)
+   // TODO get instance
+   public void testUnmonitorInstances() {
+      Map<String, MonitoringState> monitoringState = client.unmonitorInstancesInRegion(null, DEFAULT_INSTANCE);
+      assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
new file mode 100644
index 0000000..1d10906
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code MonitoringApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "MonitoringApiTest")
+public class MonitoringApiTest extends BaseAWSEC2ApiTest<MonitoringApi> {
+
+   public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(MonitoringApi.class, "unmonitorInstancesInRegion", String.class, String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "instance1", "instance2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      String payload = "Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, payload, "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, MonitoringStateHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testMonitorInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(MonitoringApi.class, "monitorInstancesInRegion", String.class, String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "instance1", "instance2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request,
+            "Action=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, MonitoringStateHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
new file mode 100644
index 0000000..c48e6a8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "PlacementGroupApiExpectTest")
+public class PlacementGroupApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribePlacementGroups")
+           .addFormParam("Filter.1.Name", "strategy")
+           .addFormParam("Filter.1.Value.1", "cluster")
+           .addFormParam("Signature", "SaA7Un1BE3m9jIEKyjXNdQPzFh/QAJSCebvKXiwUEK0%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2012-06-01")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              .payload(payloadFromResourceWithContentType("/describe_placement_groups.xml", "text/xml")).build();
+
+      AWSEC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      PlacementGroup group = getOnlyElement(apiWhenExist.getPlacementGroupApi().get().describePlacementGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("strategy", "cluster")
+                      .build()));
+
+      assertEquals(group.getName(), "XYZ-cluster");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(404).build();
+
+      AWSEC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      assertEquals(apiWhenNotExist.getPlacementGroupApi().get().describePlacementGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("strategy", "cluster")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
new file mode 100644
index 0000000..ae4d842
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Sets.newTreeSet;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.PlacementGroup.State;
+import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable;
+import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.ec2.compute.domain.EC2HardwareBuilder;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.scriptbuilder.domain.Statements;
+import org.jclouds.scriptbuilder.statements.java.InstallJDK;
+import org.jclouds.scriptbuilder.statements.login.AdminAccess;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Module;
+
+/**
+ * Tests behavior of {@code PlacementGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupApiLiveTest")
+public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest {
+   ArrayList<String> supportedRegions = newArrayList(Region.US_EAST_1, Region.US_WEST_2, Region.EU_WEST_1,
+           Region.US_WEST_2, Region.AP_NORTHEAST_1, Region.AP_SOUTHEAST_1, Region.AP_SOUTHEAST_2);
+
+   public PlacementGroupApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private AWSEC2Api client;
+   private Predicate<PlacementGroup> availableTester;
+   private Predicate<PlacementGroup> deletedTester;
+   private PlacementGroup group;
+
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class);
+      availableTester = retry(new PlacementGroupAvailable(client), 60, 1, SECONDS);
+      deletedTester = retry(new PlacementGroupDeleted(client), 60, 1, SECONDS);
+   }
+
+   @Test
+   public void testDescribe() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                  .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                     .describePlacementGroupsInRegion(region, group.getName()));
+            assertNotNull(result);
+            PlacementGroup compare = result.last();
+            assertEquals(compare, group);
+         }
+      }
+
+      for (String region : client.getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) {
+         if (!supportedRegions.contains(region))
+            try {
+               client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region);
+               fail("should be unsupported for region: " + region);
+            } catch (UnsupportedOperationException e) {
+            }
+      }
+   }
+
+   @Test
+   public void testFilter() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                 .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                    .describePlacementGroupsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                            .put("group-name", group.getName()).build()));
+            assertNotNull(result);
+            PlacementGroup compare = result.last();
+            assertEquals(compare, group);
+         }
+      }
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   public void testFilterInvalid() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                 .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                    .describePlacementGroupsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("invalid-filter", group.getName()).build()));
+         }
+      }
+   }
+
+   @Test
+   public void testCreatePlacementGroup() {
+      String groupName = PREFIX + "1";
+      for (String region : supportedRegions) {
+
+         client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, groupName);
+         client.getPlacementGroupApi().get().createPlacementGroupInRegion(region, groupName);
+
+         verifyPlacementGroup(region, groupName);
+      }
+   }
+
+   private void verifyPlacementGroup(String region, String groupName) {
+      assert availableTester.apply(new PlacementGroup(region, groupName, "cluster", State.PENDING)) : group;
+      Set<PlacementGroup> oneResult = client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region,
+               groupName);
+      assertNotNull(oneResult);
+      assertEquals(oneResult.size(), 1);
+      group = oneResult.iterator().next();
+      assertEquals(group.getName(), groupName);
+      assertEquals(group.getStrategy(), "cluster");
+      assert availableTester.apply(group) : group;
+   }
+
+   public void testStartCCInstance() throws Exception {
+
+      Template template = view.getComputeService().templateBuilder()
+               .fromHardware(EC2HardwareBuilder.cc2_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build();
+      assert template != null : "The returned template was null, but it should have a value.";
+      assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE);
+      assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
+      assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm");
+      assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen");
+
+      template.getOptions().runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
+
+      String group = PREFIX + "cccluster";
+      view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+      // TODO make this not lookup an explicit region
+      client.getPlacementGroupApi().get().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1");
+
+      try {
+         Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(group, 1, template);
+         NodeMetadata node = getOnlyElement(nodes);
+
+         getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(null,
+                  node.getProviderId())));
+
+      } catch (RunNodesException e) {
+         System.err.println(e.getNodeErrors().keySet());
+         Throwables.propagate(e);
+      } finally {
+         view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+      }
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + "ec2";
+
+   @Override
+   @AfterClass(groups = { "integration", "live" })
+   protected void tearDownContext() {
+      if (group != null) {
+         client.getPlacementGroupApi().get().deletePlacementGroupInRegion(group.getRegion(), group.getName());
+         assert deletedTester.apply(group) : group;
+      }
+      super.tearDownContext();
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
new file mode 100644
index 0000000..69eb068
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.xml.DescribePlacementGroupsResponseHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code PlacementGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "PlacementGroupApiTest")
+public class PlacementGroupApiTest extends BaseAWSEC2ApiTest<PlacementGroupApi> {
+
+   public void testDeletePlacementGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "deletePlacementGroupInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DeletePlacementGroup&GroupName=name",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest createPlacementGroup = HttpRequest.builder().method("POST")
+                                                 .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                 .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                 .addFormParam("Action", "CreatePlacementGroup")
+                                                 .addFormParam("GroupName", "name")
+                                                 .addFormParam("Strategy", "cluster").build();
+
+   public void testCreatePlacementGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class,
+               String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "cluster"));
+
+      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, filter.filter(createPlacementGroup).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testCreatePlacementGroupDefault() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=CreatePlacementGroup&Strategy=cluster&GroupName=name",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testDescribePlacementGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", String.class,
+               String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribePlacementGroups",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribePlacementGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribePlacementGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", String.class,
+               String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribePlacementGroups&GroupName.1=1&GroupName.2=2",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribePlacementGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
new file mode 100644
index 0000000..f15c7c7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "SpotInstanceApiExpectTest")
+public class SpotInstanceApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribeSpotInstanceRequests")
+           .addFormParam("Filter.1.Name", "instance-id")
+           .addFormParam("Filter.1.Value.1", "i-ef308e8e")
+           .addFormParam("Signature", "wQtGpumMCDEzvlldKepCKeEjD9iE7eAyiRBlQztcJMA%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2012-06-01")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              .payload(payloadFromResourceWithContentType("/describe_spot_instance.xml", "text/xml")).build();
+
+      AWSEC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      SpotInstanceRequest request = getOnlyElement(apiWhenExist.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-ef308e8e")
+                      .build()));
+
+      assertEquals(request.getId(), "sir-1ede0012");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(404).build();
+
+      AWSEC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      assertEquals(apiWhenNotExist.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-ef308e8e")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
new file mode 100644
index 0000000..ca6ee0a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.from;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.launchGroup;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.predicates.SpotInstanceRequestActive;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.ec2.domain.InstanceType;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * Tests behavior of {@code SpotInstanceApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class SpotInstanceApiLiveTest  extends BaseComputeServiceContextLiveTest {
+   public SpotInstanceApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private static final int SPOT_DELAY_SECONDS = 600;
+   private AWSEC2Api client;
+   private Predicate<SpotInstanceRequest> activeTester;
+   private Set<SpotInstanceRequest> requests;
+   private AWSRunningInstance instance;
+   private long start;
+
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class);
+      activeTester = retry(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, SECONDS);
+   }
+
+   @Test
+   public void testDescribeSpotRequestsInRegion() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                  .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                     .describeSpotInstanceRequestsInRegion(region, request.getId()));
+            assertNotNull(result);
+            SpotInstanceRequest compare = result.last();
+            assertEquals(compare, request);
+         }
+      }
+
+   }
+
+   @Test
+   public void testDescribeSpotRequestsInRegionFilter() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                 .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                    .describeSpotInstanceRequestsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("spot-instance-request-id", request.getId()).build()));
+
+            assertNotNull(result);
+            SpotInstanceRequest compare = result.last();
+            assertEquals(compare, request);
+         }
+      }
+
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   public void testDescribeSpotRequestsInRegionFilterInvalid() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                 .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                    .describeSpotInstanceRequestsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("invalid-filter", request.getId()).build()));
+         }
+      }
+
+   }
+
+   @Test
+   public void testDescribeSpotPriceHistoryInRegion() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         Set<Spot> spots = client.getSpotInstanceApi().get().describeSpotPriceHistoryInRegion(region, from(new Date()));
+         assertNotNull(spots);
+         assert spots.size() > 0;
+         for (Spot spot : spots) {
+            assert spot.getSpotPrice() > 0 : spots;
+            assertEquals(spot.getRegion(), region);
+            assert in(
+                     ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)",
+                              "Windows", "Windows (Amazon VPC)")).apply(spot.getProductDescription()) : spot;
+            assert in(
+                     ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large",
+                              "m1.small", "m1.medium", "m1.xlarge", "m2.2xlarge", "m2.4xlarge", "m2.xlarge", "m3.xlarge", 
+                              "m3.2xlarge", "t1.micro", "cr1.8xlarge")).apply(
+                     spot.getInstanceType()) : spot;
+
+         }
+      }
+
+   }
+
+   @Test(enabled = true)
+   public void testCreateSpotInstance() {
+      String launchGroup = PREFIX + "1";
+      for (String region : Region.DEFAULT_REGIONS)
+         for (SpotInstanceRequest request : client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
+                  region))
+            if (launchGroup.equals(request.getLaunchGroup()))
+               client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, request.getId());
+
+      start = System.currentTimeMillis();
+
+      requests = client.getSpotInstanceApi().get().requestSpotInstancesInRegion(
+               "sa-east-1",
+               0.09f,
+               1,
+               LaunchSpecification.builder().imageId("ami-3e3be423").instanceType(InstanceType.M1_SMALL).build(),
+               launchGroup(launchGroup).availabilityZoneGroup(launchGroup).validFrom(
+                        new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(2))).validUntil(
+                        new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(SPOT_DELAY_SECONDS))));
+      assertNotNull(requests);
+
+      for (SpotInstanceRequest request : requests)
+         verifySpotInstance(request);
+   }
+
+   private void verifySpotInstance(SpotInstanceRequest request) {
+      SpotInstanceRequest spot = refresh(request);
+      assertNotNull(spot);
+      assertEquals(spot, request);
+      assert activeTester.apply(request) : refresh(request);
+      System.out.println(System.currentTimeMillis() - start);
+      spot = refresh(request);
+      assert spot.getInstanceId() != null : spot;
+      instance = getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(spot.getRegion(),
+               spot.getInstanceId())));
+      assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
+   }
+
+   public SpotInstanceRequest refresh(SpotInstanceRequest request) {
+      return getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(request.getRegion(),
+               request.getId()));
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + "ec2";
+
+   @Override
+   @AfterClass(groups = { "integration", "live" })
+   protected void tearDownContext() {
+      if (requests != null) {
+         for (SpotInstanceRequest request : requests)
+            client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId());
+         // assert deletedTester.apply(request) : request;
+      }
+      if (instance != null) {
+         client.getInstanceApi().get().terminateInstancesInRegion(instance.getRegion(), instance.getId());
+      }
+      super.tearDownContext();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
new file mode 100644
index 0000000..f8276e3
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions;
+import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code SpotInstanceApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "SpotInstanceApiTest")
+public class SpotInstanceApiTest extends BaseAWSEC2ApiTest<SpotInstanceApi> {
+
+   public void testCancelSpotInstanceRequests() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "cancelSpotInstanceRequestsInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=CancelSpotInstanceRequests&SpotInstanceRequestId.1=id",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSpotPriceHistory() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class,
+            DescribeSpotPriceHistoryOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, "Action=DescribeSpotPriceHistory",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeSpotPriceHistoryResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   Date from = new Date(12345678910l);
+   Date to = new Date(1234567891011l);
+
+   public void testDescribeSpotPriceHistoryArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class,
+            DescribeSpotPriceHistoryOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from)
+            .to(to).productDescription("description").instanceType("m1.small")));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(
+            request,
+            "Action=DescribeSpotPriceHistory&StartTime=1970-05-23T21%3A21%3A18.910Z&EndTime=2009-02-13T23%3A31%3A31.011Z&ProductDescription=description&InstanceType.1=m1.small",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeSpotPriceHistoryResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
new file mode 100644
index 0000000..f5d6d4d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.ec2.domain.Tag.ResourceType.SECURITY_GROUP;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.ec2.features.internal.BaseTagApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest {
+   public TagSecurityGroupLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Override
+   protected Resource createResourceForTagging(String prefix) {
+      try {
+         return new Resource(securityGroupApi().createSecurityGroupInRegionAndReturnId(null, prefix, prefix),
+               SECURITY_GROUP);
+      } catch (IllegalStateException e) {
+         return new Resource(Iterables.get(securityGroupApi().describeSecurityGroupsInRegion(null, prefix), 0).getId(),
+               SECURITY_GROUP);
+      }
+   }
+
+   @Override
+   protected void cleanupResource(Resource resource) {
+      securityGroupApi().deleteSecurityGroupInRegionById(null, resource.id);
+   }
+
+   private AWSSecurityGroupApi securityGroupApi() {
+      return AWSEC2Api.class.cast(api).getSecurityGroupApi().get();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
new file mode 100644
index 0000000..cd6b3b7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jclouds.ssh.SshKeys.fingerprintPublicKey;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.features.AWSKeyPairApi;
+import org.jclouds.ec2.domain.KeyPair;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class ImportOrReturnExistingKeypairTest {
+   private static final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcm8DjTHg4r72dVhNLQ33XpUyMLr+ph78i4NR3LqF1bXDP0g4xNLcI/GUTQq6g07X8zs7vIWyjoitqBPFSQ2onaZQ6pXQF/QISRQgrN5hEZ+nH5Aw+isdstBeOMWKdYrCJtm6/qWq2+rByyuNbtulazP3H7SqoozSjRSGNQyFNGpmhjGgTbNQftYDwlFq0T9tCSO/+dYF8j79bNIOEmfsCMiqXQ13hD5vGiEgkRm7zIPDUfpOl3ubDzebpRgGTh5kfv2vd3Z665AxQoi6fItvDu80knyphMlC41giIm5YqfPOPG4lR+6aF06p+NKhvOeECNMtRsD9u1kKJD9NqxXhx";
+
+   private static final KeyPair pair = KeyPair.builder().region("region").keyName("jclouds#group").sha1OfPrivateKey(
+            "foo").build();
+   private static final KeyPair pairWithFingerprint = pair.toBuilder().fingerprint(fingerprintPublicKey(PUBLIC_KEY))
+            .build();
+
+   @Test
+   public void testApply() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair);
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+   }
+
+   @Test
+   public void testApplyWithIllegalStateExceptionReturnsExistingKey() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair));
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      // enriching to include the ssh fingerprint so that ssh logs are easier to correlate
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+
+   }
+
+   @Test
+   public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of());
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of(pair));
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+
+   }
+}


[13/13] git commit: Forking jclouds provider/aws-ec2 for STRATOS-559

Posted by la...@apache.org.
Forking jclouds provider/aws-ec2 for STRATOS-559


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/60b2f3fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/60b2f3fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/60b2f3fa

Branch: refs/heads/master
Commit: 60b2f3fac001c751ca0fe04635aed861d9d7eb99
Parents: 8bd3224
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Thu Mar 27 15:45:29 2014 -0700
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Thu Mar 27 15:45:29 2014 -0700

----------------------------------------------------------------------
 .../provider/aws-ec2/1.7.1-stratos/README.txt   |   8 +
 .../provider/aws-ec2/1.7.1-stratos/pom.xml      | 151 +++
 .../src/main/clojure/org/jclouds/aws/ec2.clj    |  62 ++
 .../java/org/jclouds/aws/ec2/AWSEC2Api.java     | 119 +++
 .../org/jclouds/aws/ec2/AWSEC2ApiMetadata.java  |  83 ++
 .../jclouds/aws/ec2/AWSEC2ProviderMetadata.java | 103 ++
 .../BindLaunchSpecificationToFormParams.java    |  92 ++
 ...otInstanceRequestIdsToIndexedFormParams.java |  37 +
 .../BindTagFiltersToIndexedFormParams.java      |  37 +
 .../binders/BindTagsToIndexedFormParams.java    |  37 +
 .../aws/ec2/compute/AWSEC2ComputeService.java   | 160 +++
 .../compute/AWSEC2ComputeServiceContext.java    |  31 +
 .../ec2/compute/AWSEC2TemplateBuilderImpl.java  |  51 +
 .../aws/ec2/compute/AWSEC2TemplateOptions.java  | 793 +++++++++++++++
 .../AWSEC2BindComputeSuppliersByClass.java      |  34 +
 .../AWSEC2ComputeServiceContextModule.java      | 182 ++++
 .../AWSEC2ComputeServiceDependenciesModule.java | 179 ++++
 .../aws/ec2/compute/config/ClusterCompute.java  |  37 +
 .../aws/ec2/compute/config/ImageQuery.java      |  37 +
 .../AWSEC2SecurityGroupExtension.java           | 220 +++++
 .../AWSEC2SecurityGroupToSecurityGroup.java     |  50 +
 .../AWSRunningInstanceToNodeMetadata.java       |  81 ++
 .../PresentSpotRequestsAndInstances.java        |  95 ++
 .../AWSEC2ComputeServiceContextImpl.java        |  48 +
 .../AWSEC2CreateSecurityGroupIfNeeded.java      | 140 +++
 .../AWSEC2CreateNodesInGroupThenAddToSet.java   | 116 +++
 .../strategy/AWSEC2DestroyNodeStrategy.java     |  75 ++
 .../strategy/AWSEC2GetNodeMetadataStrategy.java |  65 ++
 .../strategy/AWSEC2ListNodesStrategy.java       | 107 ++
 .../strategy/AWSEC2ReviseParsedImage.java       | 119 +++
 ...curityGroupsAsNeededAndReturnRunOptions.java | 190 ++++
 .../suppliers/AWSEC2HardwareSupplier.java       | 109 ++
 .../compute/suppliers/AWSEC2ImageSupplier.java  | 162 +++
 .../ec2/compute/suppliers/CallForImages.java    |  94 ++
 .../aws/ec2/config/AWSEC2HttpApiModule.java     |  82 ++
 .../aws/ec2/domain/AWSRunningInstance.java      | 337 +++++++
 .../aws/ec2/domain/LaunchSpecification.java     | 547 ++++++++++
 .../jclouds/aws/ec2/domain/MonitoringState.java |  50 +
 .../jclouds/aws/ec2/domain/PlacementGroup.java  | 157 +++
 .../domain/RegionNameAndPublicKeyMaterial.java  |  40 +
 .../java/org/jclouds/aws/ec2/domain/Spot.java   | 199 ++++
 .../aws/ec2/domain/SpotInstanceRequest.java     | 474 +++++++++
 .../org/jclouds/aws/ec2/features/AWSAMIApi.java | 126 +++
 .../aws/ec2/features/AWSInstanceApi.java        |  94 ++
 .../jclouds/aws/ec2/features/AWSKeyPairApi.java |  88 ++
 .../aws/ec2/features/AWSSecurityGroupApi.java   | 147 +++
 .../jclouds/aws/ec2/features/MonitoringApi.java |  97 ++
 .../aws/ec2/features/PlacementGroupApi.java     | 162 +++
 .../aws/ec2/features/SpotInstanceApi.java       | 247 +++++
 .../functions/CreatePlacementGroupIfNeeded.java |  81 ++
 .../ImportOrReturnExistingKeypair.java          |  90 ++
 ...SpotInstanceRequestToAWSRunningInstance.java |  63 ++
 .../ec2/options/AWSDescribeImagesOptions.java   | 152 +++
 .../aws/ec2/options/AWSRunInstancesOptions.java | 287 ++++++
 .../ec2/options/CreateSecurityGroupOptions.java |  63 ++
 .../DescribeSpotPriceHistoryOptions.java        | 115 +++
 .../options/RequestSpotInstancesOptions.java    | 139 +++
 .../ec2/predicates/PlacementGroupAvailable.java |  69 ++
 .../ec2/predicates/PlacementGroupDeleted.java   |  66 ++
 .../predicates/SpotInstanceRequestActive.java   |  75 ++
 .../aws/ec2/reference/AWSEC2Constants.java      |  39 +
 .../AWSDescribeInstancesResponseHandler.java    | 110 +++
 ...C2DescribeSecurityGroupsResponseHandler.java | 125 +++
 .../aws/ec2/xml/AWSEC2IpPermissionHandler.java  |  94 ++
 .../aws/ec2/xml/AWSEC2SecurityGroupHandler.java | 142 +++
 .../ec2/xml/AWSRunInstancesResponseHandler.java |  51 +
 .../aws/ec2/xml/BaseAWSReservationHandler.java  | 251 +++++
 .../xml/CreateSecurityGroupResponseHandler.java |  44 +
 .../DescribePlacementGroupsResponseHandler.java |  75 ++
 ...eservedInstancesOfferingResponseHandler.java |  74 ++
 ...DescribeSpotPriceHistoryResponseHandler.java |  76 ++
 .../aws/ec2/xml/LaunchSpecificationHandler.java | 147 +++
 .../aws/ec2/xml/MonitoringStateHandler.java     |  58 ++
 .../aws/ec2/xml/PlacementGroupHandler.java      |  70 ++
 .../aws/ec2/xml/ProductCodesHandler.java        |  51 +
 .../xml/ReservedInstancesOfferingHandler.java   |  90 ++
 .../org/jclouds/aws/ec2/xml/SpotHandler.java    |  77 ++
 .../aws/ec2/xml/SpotInstanceHandler.java        | 152 +++
 .../aws/ec2/xml/SpotInstancesHandler.java       |  81 ++
 .../org.jclouds.providers.ProviderMetadata      |   1 +
 .../test/clojure/org/jclouds/aws/ec2_test.clj   |  32 +
 .../aws/ec2/AWSEC2ContextBuilderTest.java       |  79 ++
 .../org/jclouds/aws/ec2/AWSEC2ProviderTest.java |  33 +
 ...BindLaunchSpecificationToFormParamsTest.java |  98 ++
 .../BindTagsToIndexedFormParamsTest.java        |  63 ++
 .../compute/AWSEC2ComputeServiceExpectTest.java | 280 ++++++
 .../compute/AWSEC2ComputeServiceLiveTest.java   | 196 ++++
 .../compute/AWSEC2TemplateBuilderLiveTest.java  | 367 +++++++
 .../AWSEC2ComputeServiceContextModuleTest.java  |  65 ++
 .../AWSEC2ImageExtensionLiveTest.java           |  62 ++
 .../AWSEC2SecurityGroupExtensionExpectTest.java | 364 +++++++
 .../AWSEC2SecurityGroupExtensionLiveTest.java   |  36 +
 .../AWSEC2SecurityGroupToSecurityGroupTest.java |  83 ++
 .../AWSRunningInstanceToNodeMetadataTest.java   | 220 +++++
 .../PresentSpotRequestsAndInstancesTest.java    | 100 ++
 .../BaseAWSEC2ComputeServiceExpectTest.java     | 153 +++
 .../AWSEC2CreateSecurityGroupIfNeededTest.java  | 103 ++
 .../options/AWSEC2TemplateOptionsTest.java      | 418 ++++++++
 .../compute/strategy/AWSEC2ImageParserTest.java | 242 +++++
 .../strategy/AWSEC2ReviseParsedImageTest.java   | 111 +++
 ...tyGroupsAsNeededAndReturnRunOptionsTest.java | 957 ++++++++++++++++++
 .../aws/ec2/features/AWSAMIApiLiveTest.java     |  58 ++
 .../jclouds/aws/ec2/features/AWSAMIApiTest.java | 497 ++++++++++
 .../ec2/features/AWSInstanceApiLiveTest.java    |  60 ++
 .../aws/ec2/features/AWSInstanceApiTest.java    | 539 ++++++++++
 .../aws/ec2/features/AWSKeyPairApiLiveTest.java | 208 ++++
 .../aws/ec2/features/AWSKeyPairApiTest.java     | 134 +++
 .../features/AWSSecurityGroupApiLiveTest.java   | 123 +++
 .../ec2/features/AWSSecurityGroupApiTest.java   | 207 ++++
 .../aws/ec2/features/AWSSubnetApiLiveTest.java  |  31 +
 .../aws/ec2/features/BaseAWSEC2ApiTest.java     | 135 +++
 .../aws/ec2/features/MonitoringApiLiveTest.java |  65 ++
 .../aws/ec2/features/MonitoringApiTest.java     |  73 ++
 .../features/PlacementGroupApiExpectTest.java   |  78 ++
 .../ec2/features/PlacementGroupApiLiveTest.java | 221 +++++
 .../aws/ec2/features/PlacementGroupApiTest.java | 136 +++
 .../ec2/features/SpotInstanceApiExpectTest.java |  78 ++
 .../ec2/features/SpotInstanceApiLiveTest.java   | 215 ++++
 .../aws/ec2/features/SpotInstanceApiTest.java   | 100 ++
 .../ec2/features/TagSecurityGroupLiveTest.java  |  56 ++
 .../ImportOrReturnExistingKeypairTest.java      | 115 +++
 ...InstanceRequestToAWSRunningInstanceTest.java |  91 ++
 .../options/AWSDescribeImagesOptionsTest.java   | 177 ++++
 .../ec2/options/AWSRunInstancesOptionsTest.java | 370 +++++++
 .../DescribeSpotPriceHistoryOptionsTest.java    | 119 +++
 .../RequestSpotInstancesOptionsTest.java        | 143 +++
 .../parse/DescribeInstancesResponseTest.java    | 112 +++
 .../DescribeSecurityGroupsResponseTest.java     |  77 ++
 ...AWSDescribeInstancesResponseHandlerTest.java | 167 ++++
 .../xml/AWSRunInstancesResponseHandlerTest.java | 114 +++
 ...cribePlacementGroupsResponseHandlerTest.java |  53 +
 ...vedInstancesOfferingResponseHandlerTest.java |  55 ++
 ...ribeSpotPriceHistoryResponseHandlerTest.java |  72 ++
 .../aws/ec2/xml/MonitoringStateHandlerTest.java |  50 +
 .../aws/ec2/xml/ProductCodesHandlerTest.java    |  49 +
 .../aws/ec2/xml/SpotInstanceHandlerTest.java    | 138 +++
 .../aws/ec2/xml/SpotInstancesHandlerTest.java   | 117 +++
 .../src/test/resources/alestic_canonical.xml    | 119 +++
 .../src/test/resources/amzn_images.xml          |  86 ++
 .../describe_image_attribute_productCodes.xml   |   9 +
 .../src/test/resources/describe_images_cc.xml   |  31 +
 .../src/test/resources/describe_instances_1.xml |  55 ++
 .../src/test/resources/describe_instances_2.xml | 986 +++++++++++++++++++
 .../src/test/resources/describe_instances_3.xml |   5 +
 .../resources/describe_instances_latest.xml     | 132 +++
 .../resources/describe_instances_pending.xml    |  82 ++
 .../resources/describe_placement_groups.xml     |  10 +
 .../describe_reserved_instances_offerings.xml   |  15 +
 .../resources/describe_security_groups_vpc.xml  |  35 +
 .../test/resources/describe_spot_instance.xml   |  45 +
 .../describe_spot_instance_requests.xml         | 425 ++++++++
 .../resources/describe_spot_instance_tags.xml   | 115 +++
 .../resources/describe_spot_instances_1.xml     | 207 ++++
 .../resources/describe_spot_price_history.xml   |  27 +
 .../src/test/resources/monitoring.xml           |  16 +
 .../resources/request_spot_instances-ebs.xml    |  52 +
 .../test/resources/request_spot_instances.xml   |  93 ++
 .../src/test/resources/rightscale_images.xml    |  94 ++
 .../src/test/resources/run_instances_1.xml      |  54 +
 .../1.7.1-stratos/src/test/resources/vostok.xml |  19 +
 160 files changed, 21566 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt
new file mode 100644
index 0000000..2ece686
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt
@@ -0,0 +1,8 @@
+#
+# The jclouds provider for Amazon's EC2 (http://aws.amazon.com/ec2/).
+#
+# Expects the jclouds ec2 API to be present on your application's classpath.
+#
+# TODO: Implementation status.
+# TODO: Supported features.
+# TODO: Usage example.

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml
new file mode 100644
index 0000000..4104aee
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.jclouds</groupId>
+    <artifactId>jclouds-project</artifactId>
+    <version>1.7.1</version>
+    <relativePath>../../project/pom.xml</relativePath>
+  </parent>
+  <groupId>org.apache.jclouds.provider</groupId>
+  <artifactId>aws-ec2</artifactId>
+  <name>jclouds Amazon EC2 provider</name>
+  <description>EC2 implementation targeted to Amazon Web Services</description>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <test.aws-ec2.endpoint>https://ec2.us-east-1.amazonaws.com</test.aws-ec2.endpoint>
+    <test.aws-ec2.api-version>2012-06-01</test.aws-ec2.api-version>
+    <test.aws-ec2.build-version />
+    <test.aws-ec2.identity>${test.aws.identity}</test.aws-ec2.identity>
+    <test.aws-ec2.credential>${test.aws.credential}</test.aws-ec2.credential>
+
+    <test.aws-ec2.template />
+    <!-- Active EBS template as of 9/25/2013 -->
+    <test.aws-ec2.ebs-template>hardwareId=m1.small,imageId=us-east-1/ami-53b1ff3a</test.aws-ec2.ebs-template>
+    <!-- Windows_Server-2008-R2 with WinRM enabled (setup instructions at http://www.frontiertown.co.uk/2011/12/overthere-control-windows-from-java/) -->
+    <test.aws-ec2.windows-template>hardwareId=m1.small,imageId=us-east-1/ami-0cb76d65</test.aws-ec2.windows-template>
+    <jclouds.osgi.export>org.jclouds.aws.ec2*;version="${project.version}"</jclouds.osgi.export>
+    <jclouds.osgi.import>
+      org.jclouds.compute.internal;version="${project.version}",
+      org.jclouds.rest.internal;version="${project.version}",
+      org.jclouds.aws;version="${project.version}",
+      org.jclouds.aws*;version="${project.version}",
+      org.jclouds*;version="${project.version}",
+      *
+    </jclouds.osgi.import>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.jclouds.api</groupId>
+      <artifactId>ec2</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds.api</groupId>
+      <artifactId>ec2</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds.provider</groupId>
+      <artifactId>aws-cloudwatch</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds</groupId>
+      <artifactId>jclouds-core</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds</groupId>
+      <artifactId>jclouds-compute</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds.driver</groupId>
+      <artifactId>jclouds-log4j</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jclouds.driver</groupId>
+      <artifactId>jclouds-sshj</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.theoryinpractise</groupId>
+        <artifactId>clojure-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build> 
+
+  <profiles>
+    <profile>
+      <id>live</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>integration</id>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+                <configuration>
+                  <systemPropertyVariables>
+                    <test.aws-ec2.endpoint>${test.aws-ec2.endpoint}</test.aws-ec2.endpoint>
+                    <test.aws-ec2.api-version>${test.aws-ec2.api-version}</test.aws-ec2.api-version>
+                    <test.aws-ec2.build-version>${test.aws-ec2.build-version}</test.aws-ec2.build-version>
+                    <test.aws-ec2.identity>${test.aws-ec2.identity}</test.aws-ec2.identity>
+                    <test.aws-ec2.credential>${test.aws-ec2.credential}</test.aws-ec2.credential>
+                    <test.aws-ec2.template>${test.aws-ec2.template}</test.aws-ec2.template>
+                    <test.aws-ec2.ebs-template>${test.aws-ec2.ebs-template}</test.aws-ec2.ebs-template>
+                    <test.aws-ec2.windows-template>${test.aws-ec2.windows-template}</test.aws-ec2.windows-template>
+                    <test.aws-ec2.windows-owner>${test.aws-ec2.windows-owner}</test.aws-ec2.windows-owner>
+                  </systemPropertyVariables>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+
+</project>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj
new file mode 100644
index 0000000..7bacecc
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj
@@ -0,0 +1,62 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements.  See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License.  You may obtain a copy of the License at
+;
+;     http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+(ns org.jclouds.aws.ec2
+  "AWS EC2 specific functionality"
+  (:require
+   [org.jclouds.core :as core])
+  (:import
+   org.jclouds.aws.ec2.domain.SpotInstanceRequest
+   org.jclouds.aws.ec2.options.RequestSpotInstancesOptions))
+
+(def
+  ^{:doc "TemplateBuilder functions" :private true}
+  spot-option-map
+  (core/make-option-map
+   core/kw-memfn-1arg
+   [:valid-from :valid-until :type :launch-group :availability-zone-group]))
+
+(defn spot-types []
+  (. org.jclouds.aws.ec2.domain.SpotInstanceRequest$Type values))
+
+(def enum-map {:type (spot-types)})
+
+(defn translate-enum-value [kword value]
+  (or (-> (filter #(= (name value) (str %)) (kword enum-map)) first)
+      value))
+
+(defn apply-option
+  [options [option value]]
+  (when-let [f (spot-option-map option)]
+    (f options (translate-enum-value option value)))
+  options)
+
+(defn spot-options
+  "Build a spot request options object, for passing to the :spot-options
+   key of the template builder options.
+
+   Takes a hash-map of keys and values that correspond to the methods of
+   RequestSpotInstancesOptions.
+
+   Options are:
+       :valid-from :valid-until :type :launch-group :availability-zone-group
+
+   :type takes either :one-time or :persistent"
+  [request-map]
+  (reduce
+   apply-option
+   (RequestSpotInstancesOptions.) request-map))

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
new file mode 100644
index 0000000..e54a0ea
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+
+import org.jclouds.aws.ec2.features.AWSAMIApi;
+import org.jclouds.aws.ec2.features.AWSInstanceApi;
+import org.jclouds.aws.ec2.features.AWSKeyPairApi;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.aws.ec2.features.MonitoringApi;
+import org.jclouds.aws.ec2.features.PlacementGroupApi;
+import org.jclouds.aws.ec2.features.SpotInstanceApi;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+
+/**
+ * Provides synchronous access to EC2 services.
+ * 
+ * @author Adrian Cole
+ */
+public interface AWSEC2Api extends EC2Api {
+
+   /**
+    * {@inheritDoc}
+    */
+   @Delegate
+   @Override
+   Optional<? extends AWSInstanceApi> getInstanceApi();
+
+   @Delegate
+   @Override
+   Optional<? extends AWSInstanceApi> getInstanceApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+   /**
+    * {@inheritDoc}
+    */
+   @Delegate
+   @Override
+   Optional<? extends AWSSecurityGroupApi> getSecurityGroupApi();
+
+   @Delegate
+   @Override
+   Optional<? extends AWSSecurityGroupApi> getSecurityGroupApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Delegate
+   @Override
+   Optional<? extends AWSAMIApi> getAMIApi();
+
+   @Delegate
+   @Override
+   Optional<? extends AWSAMIApi> getAMIApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+
+   /**
+    * Provides synchronous access to PlacementGroup services.
+    */
+   @Delegate
+   Optional<? extends PlacementGroupApi> getPlacementGroupApi();
+   
+   @Delegate
+   Optional<? extends PlacementGroupApi> getPlacementGroupApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+   /**
+    * Provides synchronous access to Monitoring services.
+    */
+   @Delegate
+   Optional<? extends MonitoringApi> getMonitoringApi();
+   
+   @Delegate
+   Optional<? extends MonitoringApi> getMonitoringApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+   /**
+    * {@inheritDoc}
+    */
+   @Delegate
+   @Override
+   Optional<? extends AWSKeyPairApi> getKeyPairApi();
+   
+   @Delegate
+   @Override
+   Optional<? extends AWSKeyPairApi> getKeyPairApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+   
+   /**
+    * Provides synchronous access to SpotInstance services.
+    */
+   @Delegate
+   Optional<? extends SpotInstanceApi> getSpotInstanceApi();
+   
+   @Delegate
+   Optional<? extends SpotInstanceApi> getSpotInstanceApiForRegion(
+            @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
new file mode 100644
index 0000000..7cb4c83
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext;
+import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule;
+import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule;
+import org.jclouds.ec2.EC2ApiMetadata;
+import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+public final class AWSEC2ApiMetadata extends BaseHttpApiMetadata<AWSEC2Api> {
+
+   @Override
+   public Builder toBuilder() {
+      return new Builder().fromApiMetadata(this);
+   }
+
+   public AWSEC2ApiMetadata() {
+      super(new Builder());
+   }
+
+   protected AWSEC2ApiMetadata(Builder builder) {
+      super(builder);
+   }
+
+   public static Properties defaultProperties() {
+      Properties properties = EC2ApiMetadata.defaultProperties();
+      properties.remove(PROPERTY_EC2_AMI_OWNERS);
+      // auth fail sometimes happens in EC2, as the rc.local script that injects the
+      // authorized key executes after ssh has started.  
+      properties.setProperty("jclouds.ssh.max-retries", "7");
+      properties.setProperty("jclouds.ssh.retry-auth", "true");
+      return properties;
+   }
+
+   public static final class Builder extends BaseHttpApiMetadata.Builder<AWSEC2Api, Builder> {
+      public Builder() {
+         id("aws-ec2")
+         .version("2012-06-01")
+         .name("Amazon-specific EC2 API")
+         .identityName("Access Key ID")
+         .credentialName("Secret Access Key")
+         .defaultEndpoint("https://ec2.us-east-1.amazonaws.com")
+         .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))
+         .defaultProperties(AWSEC2ApiMetadata.defaultProperties())
+         .view(AWSEC2ComputeServiceContext.class)
+         .defaultModules(ImmutableSet.<Class<? extends Module>>of(AWSEC2HttpApiModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class));
+      }
+
+      @Override
+      public AWSEC2ApiMetadata build() {
+         return new AWSEC2ApiMetadata(this);
+      }
+
+      @Override
+      protected Builder self() {
+         return this;
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java
new file mode 100644
index 0000000..7827171
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
+import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS;
+import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.providers.internal.BaseProviderMetadata;
+
+/**
+ * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's
+ * Elastic Compute Cloud (EC2) provider.
+ *
+ * @author Adrian Cole
+ */
+public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
+
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   @Override
+   public Builder toBuilder() {
+      return builder().fromProviderMetadata(this);
+   }
+   
+   public AWSEC2ProviderMetadata() {
+      super(builder());
+   }
+
+   public AWSEC2ProviderMetadata(Builder builder) {
+      super(builder);
+   }
+
+   public static Properties defaultProperties() {
+      Properties properties = new Properties();
+      // sometimes, like in ec2, stop takes a very long time, perhaps
+      // due to volume management. one example spent 2 minutes moving
+      // from stopping->stopped state on an ec2 micro
+      properties.setProperty(TIMEOUT_NODE_SUSPENDED, 120 * 1000 + "");
+      properties.putAll(Region.regionProperties());
+      // Amazon Linux, Amazon Windows, alestic, canonical, and rightscale
+      properties.setProperty(PROPERTY_EC2_AMI_QUERY,
+               "owner-id=137112412989,801119661308,063491364108,099720109477,411009282317;state=available;image-type=machine");
+      // amis that work with the cluster instances
+      properties.setProperty(PROPERTY_EC2_CC_REGIONS, Region.US_EAST_1 + "," + Region.US_WEST_2 + "," + Region.EU_WEST_1);
+      properties
+               .setProperty(
+                        PROPERTY_EC2_CC_AMI_QUERY,
+                        "virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;state=available;image-type=machine;root-device-type=ebs");
+      properties.setProperty(TEMPLATE, "osFamily=AMZN_LINUX,os64Bit=true");
+      return properties;
+   }
+   
+   public static class Builder extends BaseProviderMetadata.Builder {
+
+      protected Builder() {
+         id("aws-ec2")
+         .name("Amazon Elastic Compute Cloud (EC2)")
+         .apiMetadata(new AWSEC2ApiMetadata())
+         .endpoint("https://ec2.us-east-1.amazonaws.com")
+         .homepage(URI.create("http://aws.amazon.com/ec2"))
+         .console(URI.create("https://console.aws.amazon.com/ec2/home"))
+         .defaultProperties(AWSEC2ProviderMetadata.defaultProperties())
+         .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb")
+         .iso3166Codes("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "AU-NSW", "JP-13");
+      }
+
+      @Override
+      public AWSEC2ProviderMetadata build() {
+         return new AWSEC2ProviderMetadata(this);
+      }
+
+      @Override
+      public Builder fromProviderMetadata(
+            ProviderMetadata in) {
+         super.fromProviderMetadata(in);
+         return this;
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java
new file mode 100644
index 0000000..77f9d9d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.LaunchSpecification.IAMInstanceProfileRequest;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Multimaps;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindLaunchSpecificationToFormParams implements Binder, Function<LaunchSpecification, Map<String, String>> {
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      checkArgument(input instanceof LaunchSpecification, "this binder is only valid for LaunchSpecifications!");
+      LaunchSpecification launchSpec = LaunchSpecification.class.cast(input);
+      return (R) request.toBuilder().replaceFormParams(Multimaps.forMap(apply(launchSpec))).build();
+   }
+
+   @Override
+   public Map<String, String> apply(LaunchSpecification launchSpec) {
+      Builder<String, String> builder = ImmutableMap.builder();
+      builder.put("LaunchSpecification.ImageId", checkNotNull(launchSpec.getImageId(), "imageId"));
+      if (launchSpec.getAvailabilityZone() != null)
+         builder.put("LaunchSpecification.Placement.AvailabilityZone", launchSpec.getAvailabilityZone());
+
+      AWSRunInstancesOptions options = new AWSRunInstancesOptions();
+      if (launchSpec.getBlockDeviceMappings().size() > 0)
+         options.withBlockDeviceMappings(launchSpec.getBlockDeviceMappings());
+      if (launchSpec.getSecurityGroupNames().size() > 0)
+         options.withSecurityGroups(launchSpec.getSecurityGroupNames());
+      if (launchSpec.getSecurityGroupIds().size() > 0)
+         options.withSecurityGroupIds(launchSpec.getSecurityGroupIds());
+      options.asType(checkNotNull(launchSpec.getInstanceType(), "instanceType"));
+      if (launchSpec.getSubnetId() != null)
+         options.withSubnetId(launchSpec.getSubnetId());
+      if (launchSpec.getKernelId() != null)
+         options.withKernelId(launchSpec.getKernelId());
+      if (launchSpec.getKeyName() != null)
+         options.withKeyName(launchSpec.getKeyName());
+      if (launchSpec.getRamdiskId() != null)
+         options.withRamdisk(launchSpec.getRamdiskId());
+      if (Boolean.TRUE.equals(launchSpec.isMonitoringEnabled()))
+         options.enableMonitoring();
+      if (launchSpec.getUserData() != null)
+         options.withUserData(launchSpec.getUserData());
+      if (launchSpec.getIAMInstanceProfile().isPresent()) {
+         IAMInstanceProfileRequest profile = launchSpec.getIAMInstanceProfile().get();
+         if (profile.getArn().isPresent())
+            options.withIAMInstanceProfileArn(profile.getArn().get());
+         if (profile.getName().isPresent())
+            options.withIAMInstanceProfileName(profile.getName().get());
+      }
+      for (Entry<String, String> entry : options.buildFormParameters().entries()) {
+         builder.put("LaunchSpecification." + entry.getKey(), entry.getValue());
+      }
+      return builder.build();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java
new file mode 100644
index 0000000..dfdf38e
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+/**
+ * Binds the String [] to form parameters named with SpotInstanceRequestId.index
+ * 
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindSpotInstanceRequestIdsToIndexedFormParams implements Binder {
+   @Override
+   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      return AWSUtils.indexStringArrayToFormValuesWithPrefix(request, "SpotInstanceRequestId", input);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java
new file mode 100644
index 0000000..7641c56
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+/**
+ * @author grkvlt@apache.org
+ */
+public class BindTagFiltersToIndexedFormParams implements Binder {
+    @Override
+    public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+        checkArgument(checkNotNull(input, "input") instanceof Map<?,?>, "this binder is only valid for Map<?, Iterable<?>>");
+        return AWSUtils.indexMapOfIterableToFormValuesWithPrefix(request, "Filter", "Name", "Value", input);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java
new file mode 100644
index 0000000..f703b89
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import org.jclouds.aws.util.AWSUtils;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+/**
+ * @author grkvlt@apache.org
+ */
+public class BindTagsToIndexedFormParams implements Binder {
+    @Override
+    public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+        checkArgument(checkNotNull(input, "input") instanceof Map, "This binder is only valid for Map<String,String>");
+        return AWSUtils.indexMapToFormValuesWithPrefix(request, "Tag", "Key", "Value", input);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
new file mode 100644
index 0000000..f512074
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Strings.emptyToNull;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
+import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.PlacementGroup.State;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.callables.RunScriptOnNode;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.internal.PersistNodeCredentials;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
+import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
+import org.jclouds.compute.strategy.DestroyNodeStrategy;
+import org.jclouds.compute.strategy.GetImageStrategy;
+import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
+import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.compute.strategy.RebootNodeStrategy;
+import org.jclouds.compute.strategy.ResumeNodeStrategy;
+import org.jclouds.compute.strategy.SuspendNodeStrategy;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.ec2.compute.EC2ComputeService;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.scriptbuilder.functions.InitAdminAccess;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class AWSEC2ComputeService extends EC2ComputeService {
+
+   private final LoadingCache<RegionAndName, String> placementGroupMap;
+   private final Predicate<PlacementGroup> placementGroupDeleted;
+   private final AWSEC2Api client;
+
+   @Inject
+   protected AWSEC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
+         @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
+         @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
+         GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
+         CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
+         DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
+         SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
+         @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
+         @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
+         @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
+         @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
+         InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
+         RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
+         PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
+         @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Api client,
+         ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
+         @Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
+         @Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
+         @Named("DELETED") Predicate<PlacementGroup> placementGroupDeleted, Optional<ImageExtension> imageExtension,
+         GroupNamingConvention.Factory namingConvention,
+         @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
+         Optional<SecurityGroupExtension> securityGroupExtension) {
+      super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
+            getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
+            startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
+            nodeTerminated, nodeSuspended, initScriptRunnerFactory, runScriptOnNodeFactory, initAdminAccess,
+            persistNodeCredentials, timeouts, userExecutor, client, credentialsMap, securityGroupMap, imageExtension,
+            namingConvention, generateInstanceNames, securityGroupExtension);
+      this.client = client;
+      this.placementGroupMap = placementGroupMap;
+      this.placementGroupDeleted = placementGroupDeleted;
+   }
+
+   @VisibleForTesting
+   void deletePlacementGroup(String region, String group) {
+      checkNotNull(emptyToNull(group), "group must be defined");
+      // placementGroupName must be unique within an account per
+      // http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using_cluster_computing.html
+      String placementGroup = String.format("jclouds#%s#%s", group, region);
+      try {
+         if (client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region, placementGroup).size() > 0) {
+            logger.debug(">> deleting placementGroup(%s)", placementGroup);
+            try {
+               client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, placementGroup);
+               checkState(placementGroupDeleted.apply(new PlacementGroup(region, placementGroup, "cluster",
+                        State.PENDING)), String.format("placementGroup region(%s) name(%s) failed to delete", region,
+                        placementGroup));
+               placementGroupMap.invalidate(new RegionAndName(region, placementGroup));
+               logger.debug("<< deleted placementGroup(%s)", placementGroup);
+            } catch (IllegalStateException e) {
+               logger.debug("<< inUse placementGroup(%s)", placementGroup);
+            }
+         }
+      } catch (UnsupportedOperationException e) {
+         logger.trace("<< placementGroups unsupported in region %s", region);
+      }
+   }
+
+   @Override
+   protected void cleanUpIncidentalResources(String region, String group) {
+      super.cleanUpIncidentalResources(region, group);
+      deletePlacementGroup(region, group);
+   }
+
+   /**
+    * returns template options, except of type {@link AWSEC2TemplateOptions}.
+    */
+   @Override
+   public AWSEC2TemplateOptions templateOptions() {
+      return AWSEC2TemplateOptions.class.cast(super.templateOptions());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java
new file mode 100644
index 0000000..36c381f
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import org.jclouds.aws.ec2.compute.internal.AWSEC2ComputeServiceContextImpl;
+import org.jclouds.ec2.compute.EC2ComputeServiceContext;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * @author Adrian Cole
+ */
+@ImplementedBy(AWSEC2ComputeServiceContextImpl.class)
+public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext {
+   @Override
+   AWSEC2ComputeService getComputeService();
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java
new file mode 100644
index 0000000..b3adb8b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.Location;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
+
+   @Inject
+   protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
+         @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
+         Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
+         @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap) {
+      super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java
new file mode 100644
index 0000000..d419291
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java
@@ -0,0 +1,793 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.compute;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Strings.emptyToNull;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.options.EC2TemplateOptions;
+import org.jclouds.ec2.domain.BlockDeviceMapping;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.SinceApiVersion;
+import org.jclouds.scriptbuilder.domain.Statement;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Contains options supported in the {@code ComputeService#runNode} operation on
+ * the "ec2" provider. <h2>
+ * Usage</h2> The recommended way to instantiate a AWSEC2TemplateOptions object
+ * is to statically import AWSEC2TemplateOptions.* and invoke a static creation
+ * method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.compute.options.AWSEC2TemplateOptions.Builder.*;
+ * <p/>
+ * ComputeService client = // get connection
+ * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
+ * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
+ * <code>
+ * 
+ * @author Adrian Cole
+ */
+public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneable {
+   @Override
+   public AWSEC2TemplateOptions clone() {
+      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+      copyTo(options);
+      return options;
+   }
+
+   @Override
+   public void copyTo(TemplateOptions to) {
+      super.copyTo(to);
+      if (to instanceof AWSEC2TemplateOptions) {
+         AWSEC2TemplateOptions eTo = AWSEC2TemplateOptions.class.cast(to);
+         if (getSubnetId() != null)
+            eTo.subnetId(getSubnetId());
+         if (getIAMInstanceProfileArn() != null)
+            eTo.iamInstanceProfileArn(getIAMInstanceProfileArn());
+         if (getIAMInstanceProfileName() != null)
+            eTo.iamInstanceProfileName(getIAMInstanceProfileName());
+         if (isMonitoringEnabled())
+            eTo.enableMonitoring();
+         if (!shouldAutomaticallyCreatePlacementGroup())
+            eTo.noPlacementGroup();
+         if (getPlacementGroup() != null)
+            eTo.placementGroup(getPlacementGroup());
+         if (getGroupIds().size() > 0)
+            eTo.securityGroupIds(getGroupIds());
+         if (getSpotPrice() != null)
+            eTo.spotPrice(getSpotPrice());
+         if (getSpotOptions() != null)
+            eTo.spotOptions(getSpotOptions());
+      }
+   }
+
+   private boolean monitoringEnabled;
+   private String placementGroup = null;
+   private boolean noPlacementGroup;
+   private String subnetId;
+   private Float spotPrice;
+   private RequestSpotInstancesOptions spotOptions = RequestSpotInstancesOptions.NONE;
+   private Set<String> groupIds = ImmutableSet.of();
+   private String iamInstanceProfileArn;
+   private String iamInstanceProfileName;
+
+   @Override
+   public boolean equals(Object o) {
+      if (this == o)
+         return true;
+      if (o == null || getClass() != o.getClass())
+         return false;
+      AWSEC2TemplateOptions that = AWSEC2TemplateOptions.class.cast(o);
+      return super.equals(that) && equal(this.monitoringEnabled, that.monitoringEnabled)
+               && equal(this.placementGroup, that.placementGroup)
+               && equal(this.noPlacementGroup, that.noPlacementGroup) && equal(this.subnetId, that.subnetId)
+               && equal(this.spotPrice, that.spotPrice) && equal(this.spotOptions, that.spotOptions)
+               && equal(this.groupIds, that.groupIds) && equal(this.iamInstanceProfileArn, that.iamInstanceProfileArn)
+               && equal(this.iamInstanceProfileName, that.iamInstanceProfileName);
+   }
+
+   @Override
+   public int hashCode() {
+      return Objects.hashCode(super.hashCode(), monitoringEnabled, placementGroup, noPlacementGroup, subnetId,
+               spotPrice, spotOptions, groupIds, iamInstanceProfileArn, iamInstanceProfileName);
+   }
+
+   @Override
+   public ToStringHelper string() {
+      ToStringHelper toString = super.string();
+      if (monitoringEnabled)
+         toString.add("monitoringEnabled", monitoringEnabled);
+      toString.add("placementGroup", placementGroup);
+      if (noPlacementGroup)
+         toString.add("noPlacementGroup", noPlacementGroup);
+      toString.add("subnetId", subnetId);
+      toString.add("spotPrice", spotPrice);
+      if (spotOptions != RequestSpotInstancesOptions.NONE)
+         toString.add("spotOptions", spotOptions);
+      if (groupIds.size() != 0)
+         toString.add("groupIds", groupIds);
+      toString.add("iamInstanceProfileArn", iamInstanceProfileArn);
+      toString.add("iamInstanceProfileName", iamInstanceProfileName);
+      return toString;
+   }
+
+   public static final AWSEC2TemplateOptions NONE = new AWSEC2TemplateOptions();
+
+   /**
+    * Enable Cloudwatch monitoring
+    * 
+    * @see CloudWatchClient
+    */
+   public AWSEC2TemplateOptions enableMonitoring() {
+      this.monitoringEnabled = true;
+      return this;
+   }
+
+   /**
+    * Specifies the keypair used to run instances with
+    */
+   public AWSEC2TemplateOptions placementGroup(String placementGroup) {
+      checkNotNull(emptyToNull(placementGroup), "use noPlacementGroup option instead of passing null");
+      checkState(!noPlacementGroup, "you cannot specify both options placementGroup and noPlacementGroup");
+      this.placementGroup = placementGroup;
+      return this;
+   }
+
+   /**
+    * Do not use a keypair on instances
+    */
+   public AWSEC2TemplateOptions noPlacementGroup() {
+      checkState(placementGroup == null, "you cannot specify both options placementGroup and noPlacementGroup");
+      this.noPlacementGroup = true;
+      return this;
+   }
+
+   /**
+    * Specifies the subnetId used to run instances in
+    */
+   public AWSEC2TemplateOptions subnetId(String subnetId) {
+      this.subnetId = checkNotNull(emptyToNull(subnetId), "subnetId must be defined");
+      return this;
+   }
+
+   /**
+    * @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileArn(String)
+    */
+   @SinceApiVersion("2012-06-01")
+   public AWSEC2TemplateOptions iamInstanceProfileArn(String arn) {
+      this.iamInstanceProfileArn = checkNotNull(emptyToNull(arn), "arn must be defined");
+      return this;
+   }
+
+   /**
+    * @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileName(String)
+    */
+   @SinceApiVersion("2012-06-01")
+   public AWSEC2TemplateOptions iamInstanceProfileName(String name) {
+      this.iamInstanceProfileName = checkNotNull(emptyToNull(name), "name must be defined");
+      return this;
+   }
+
+   /**
+    * Specifies the maximum spot price to use
+    */
+   public AWSEC2TemplateOptions spotPrice(Float spotPrice) {
+      this.spotPrice = spotPrice;
+      return this;
+   }
+
+   /**
+    * Options for starting spot instances
+    */
+   public AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
+      this.spotOptions = spotOptions != null ? spotOptions : RequestSpotInstancesOptions.NONE;
+      return this;
+   }
+
+   /**
+    * 
+    * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
+    */
+   public AWSEC2TemplateOptions securityGroupIds(String... groupIds) {
+      return securityGroupIds(ImmutableSet.copyOf(groupIds));
+   }
+
+   /**
+    * Specifies the security group ids to be used for nodes with this template
+    */
+   public AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupIds) {
+      checkArgument(Iterables.size(groupIds) > 0, "you must specify at least one security group");
+      for (String groupId : groupIds)
+         checkNotNull(emptyToNull(groupId), "all security groups must be non-empty");
+      this.groupIds = ImmutableSet.copyOf(groupIds);
+      return this;
+   }
+
+   public Set<String> getGroupIds() {
+      return groupIds;
+   }
+
+   public static class Builder {
+
+      public static AWSEC2TemplateOptions overrideLoginUser(String user) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.overrideLoginUser(user);
+      }
+
+      public static AWSEC2TemplateOptions overrideLoginPassword(String password) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.overrideLoginPassword(password);
+      }
+
+      public static AWSEC2TemplateOptions overrideLoginPrivateKey(String privateKey) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.overrideLoginPrivateKey(privateKey);
+      }
+
+      public static AWSEC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.overrideAuthenticateSudo(authenticateSudo);
+      }
+
+      public static AWSEC2TemplateOptions overrideLoginCredentials(LoginCredentials credentials) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.overrideLoginCredentials(credentials);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
+       */
+      public static AWSEC2TemplateOptions securityGroupIds(String... groupNames) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
+       */
+      public static AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupNames) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
+      }
+
+      /**
+       * @see EC2TemplateOptions#blockDeviceMappings
+       */
+      public static AWSEC2TemplateOptions blockDeviceMappings(Set<? extends BlockDeviceMapping> blockDeviceMappings) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.blockDeviceMappings(blockDeviceMappings);
+      }
+
+      /**
+       * @see EC2TemplateOptions#mapEBSSnapshotToDeviceName
+       */
+      public static AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId,
+            @Nullable Integer sizeInGib, boolean deleteOnTermination) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib, deleteOnTermination);
+      }
+
+      /**
+       * @see EC2TemplateOptions#mapNewVolumeToDeviceName
+       */
+      public static AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib,
+            boolean deleteOnTermination) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination);
+      }
+
+      /**
+       * @see EC2TemplateOptions#mapEphemeralDeviceToDeviceName
+       */
+      public static AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.mapEphemeralDeviceToDeviceName(deviceName, virtualName);
+      }
+
+      /**
+       * @see EC2TemplateOptions#unmapDeviceNamed
+       */
+      public static AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.unmapDeviceNamed(deviceName);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
+       */
+      public static AWSEC2TemplateOptions securityGroups(String... groupIds) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.securityGroups(groupIds);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
+       */
+      public static AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.securityGroups(groupIds);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#keyPair
+       */
+      public static AWSEC2TemplateOptions keyPair(String keyPair) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.keyPair(keyPair);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#userData
+       */
+      public static AWSEC2TemplateOptions userData(byte[] unencodedData) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.userData(unencodedData);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#noKeyPair
+       */
+      public static AWSEC2TemplateOptions noKeyPair() {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.noKeyPair();
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#placementGroup
+       */
+      public static AWSEC2TemplateOptions placementGroup(String placementGroup) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.placementGroup(placementGroup);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#noPlacementGroup
+       */
+      public static AWSEC2TemplateOptions noPlacementGroup() {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.noPlacementGroup();
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#enableMonitoring
+       */
+      public static AWSEC2TemplateOptions enableMonitoring() {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.enableMonitoring();
+      }
+
+      // methods that only facilitate returning the correct object type
+      /**
+       * @see TemplateOptions#inboundPorts
+       */
+      public static AWSEC2TemplateOptions inboundPorts(int... ports) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.inboundPorts(ports);
+      }
+
+      /**
+       * @see TemplateOptions#port
+       */
+      public static AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.blockOnPort(port, seconds);
+      }
+
+      /**
+       * @see TemplateOptions#installPrivateKey
+       */
+      public static AWSEC2TemplateOptions installPrivateKey(String rsaKey) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.installPrivateKey(rsaKey);
+      }
+
+      /**
+       * @see TemplateOptions#authorizePublicKey
+       */
+      public static AWSEC2TemplateOptions authorizePublicKey(String rsaKey) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.authorizePublicKey(rsaKey);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#subnetId
+       */
+      public static AWSEC2TemplateOptions subnetId(String subnetId) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.subnetId(subnetId);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#iamInstanceProfileArn
+       */
+      @SinceApiVersion("2012-06-01")
+      public static AWSEC2TemplateOptions iamInstanceProfileArn(String arn) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.iamInstanceProfileArn(arn);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#iamInstanceProfileName
+       */
+      @SinceApiVersion("2012-06-01")
+      public static AWSEC2TemplateOptions iamInstanceProfileName(String name) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.iamInstanceProfileName(name);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#spotPrice
+       */
+      public static AWSEC2TemplateOptions spotPrice(Float spotPrice) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.spotPrice(spotPrice);
+      }
+
+      /**
+       * @see AWSEC2TemplateOptions#spotOptions
+       */
+      public static AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.spotOptions(spotOptions);
+      }
+
+      /**
+       * @see TemplateOptions#userMetadata(Map)
+       */
+      public static AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.userMetadata(userMetadata));
+      }
+
+      /**
+       * @see TemplateOptions#userMetadata(String, String)
+       */
+      public static AWSEC2TemplateOptions userMetadata(String key, String value) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.userMetadata(key, value));
+      }
+
+      public static AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return options.blockUntilRunning(blockUntilRunning);
+      }
+
+      /**
+       * @see TemplateOptions#nodeNames(Iterable)
+       */
+      public static AWSEC2TemplateOptions nodeNames(Iterable<String> nodeNames) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.nodeNames(nodeNames));
+      }
+
+      /**
+       * @see TemplateOptions#networks(Iterable)
+       */
+      public static AWSEC2TemplateOptions networks(Iterable<String> networks) {
+         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
+         return AWSEC2TemplateOptions.class.cast(options.networks(networks));
+      }
+   }
+
+   // methods that only facilitate returning the correct object type
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings) {
+      return AWSEC2TemplateOptions.class.cast(super.blockDeviceMappings(blockDeviceMappings));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
+      return AWSEC2TemplateOptions.class.cast(super.userMetadata(userMetadata));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions userMetadata(String key, String value) {
+      return AWSEC2TemplateOptions.class.cast(super.userMetadata(key, value));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions nodeNames(Iterable<String> nodeNames) {
+      return AWSEC2TemplateOptions.class.cast(super.nodeNames(nodeNames));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions networks(Iterable<String> networks) {
+      return AWSEC2TemplateOptions.class.cast(super.networks(networks));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions keyPair(String keyPair) {
+      return AWSEC2TemplateOptions.class.cast(super.keyPair(keyPair));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+
+   @Override
+   public AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib,
+         boolean deleteOnTermination) {
+      return AWSEC2TemplateOptions.class.cast(super.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib,
+            deleteOnTermination));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
+      return AWSEC2TemplateOptions.class.cast(super.mapEphemeralDeviceToDeviceName(deviceName, virtualName));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination) {
+      return AWSEC2TemplateOptions.class.cast(super
+            .mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions noKeyPair() {
+      return AWSEC2TemplateOptions.class.cast(super.noKeyPair());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
+      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions securityGroups(String... groupIds) {
+      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
+      return AWSEC2TemplateOptions.class.cast(super.unmapDeviceNamed(deviceName));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions userData(byte[] unencodedData) {
+      return AWSEC2TemplateOptions.class.cast(super.userData(unencodedData));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
+      return AWSEC2TemplateOptions.class.cast(super.blockOnPort(port, seconds));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions inboundPorts(int... ports) {
+      return AWSEC2TemplateOptions.class.cast(super.inboundPorts(ports));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions authorizePublicKey(String publicKey) {
+      return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions installPrivateKey(String privateKey) {
+      return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+      return AWSEC2TemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions dontAuthorizePublicKey() {
+      return AWSEC2TemplateOptions.class.cast(super.dontAuthorizePublicKey());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions nameTask(String name) {
+      return AWSEC2TemplateOptions.class.cast(super.nameTask(name));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions runAsRoot(boolean runAsRoot) {
+      return AWSEC2TemplateOptions.class.cast(super.runAsRoot(runAsRoot));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions runScript(Statement script) {
+      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
+      return AWSEC2TemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions overrideLoginPassword(String password) {
+      return AWSEC2TemplateOptions.class.cast(super.overrideLoginPassword(password));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions overrideLoginPrivateKey(String privateKey) {
+      return AWSEC2TemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions overrideLoginUser(String loginUser) {
+      return AWSEC2TemplateOptions.class.cast(super.overrideLoginUser(loginUser));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public AWSEC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+      return AWSEC2TemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
+   }
+
+   /**
+    * @return placementGroup to use when running the instance or null, to
+    *         generate a placementGroup.
+    */
+   public String getPlacementGroup() {
+      return placementGroup;
+   }
+
+   /**
+    * @return true (default) if we are supposed to use a placementGroup
+    */
+   public boolean shouldAutomaticallyCreatePlacementGroup() {
+      return !noPlacementGroup;
+   }
+
+   /**
+    * @return true (default) if we are supposed to enable cloudwatch
+    */
+   public boolean isMonitoringEnabled() {
+      return monitoringEnabled;
+   }
+
+   /**
+    * @return subnetId to use when running the instance or null.
+    */
+   public String getSubnetId() {
+      return subnetId;
+   }
+
+   /**
+    * @return maximum spot price or null.
+    */
+   public Float getSpotPrice() {
+      return spotPrice;
+   }
+
+   /**
+    * @return options for controlling spot instance requests.
+    */
+   public RequestSpotInstancesOptions getSpotOptions() {
+      return spotOptions;
+   }
+
+   /**
+    * The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instance.
+    * 
+    * @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileArn(String)
+    */
+   @SinceApiVersion("2012-06-01")
+   public String getIAMInstanceProfileArn() {
+      return iamInstanceProfileArn;
+   }
+
+   /**
+    * The name of the IAM Instance Profile (IIP) to associate with the instance.
+    * 
+    * @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileName(String)
+    */
+   @SinceApiVersion("2012-06-01")
+   public String getIAMInstanceProfileName() {
+      return iamInstanceProfileName;
+   }
+}