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:57 UTC
[09/13] Forking jclouds provider/aws-ec2 for STRATOS-559
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);
+ }
+
+}