http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java deleted file mode 100644 index ec655ae..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.ec2.options; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import org.jclouds.domain.Credentials; -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; -import org.jclouds.location.Provider; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Supplier; -import com.google.common.collect.Multimap; -import com.google.inject.Inject; - -/** - * Contains options supported in the Form API for the RegisterImage operation. - * <h2> - * Usage</h2> The recommended way to instantiate a - * BundleInstanceS3StorageOptions object is to statically import - * BundleInstanceS3StorageOptions.Builder.* and invoke a static creation method - * followed by an instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.BundleInstanceS3StorageOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * String imageId = connection.getWindowsServices().bundleInstanceInRegion(...bucketOwnedBy(anotherAccessKey)); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-BundleInstance.html" - * /> - */ -public class BundleInstanceS3StorageOptions extends BaseEC2RequestOptions { - - @Inject - @VisibleForTesting - @Provider - Supplier<Credentials> creds; - - @Override - public Multimap<String, String> buildFormParameters() { - if (getAwsAccessKeyId() == null) { - checkState(creds != null, "creds should have been injected"); - bucketOwnedBy(creds.get().identity); - } - return super.buildFormParameters(); - } - - /** - * - * @param ccessKeyId - * The Access Key ID of the owner of the Amazon S3 bucket. - */ - public BundleInstanceS3StorageOptions bucketOwnedBy(String ccessKeyId) { - formParameters.put("Storage.S3.AWSAccessKeyId", checkNotNull(ccessKeyId, "ccessKeyId")); - return this; - } - - /** - * - * @return The Access Key ID of the owner of the Amazon S3 bucket. - */ - public String getAwsAccessKeyId() { - return getFirstFormOrNull("Storage.S3.AWSAccessKeyId"); - } - - public static class Builder { - /** - * @see BundleInstanceS3StorageOptions#bucketOwnedBy(accessKeyId) - */ - public static BundleInstanceS3StorageOptions bucketOwnedBy(String accessKeyId) { - BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); - return options.bucketOwnedBy(accessKeyId); - } - - } -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java deleted file mode 100644 index 8c604d5..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.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 CreateImage operation. <h2> - * Usage</h2> The recommended way to instantiate a CreateImageOptions object is to statically import - * CreateImageOptions.Builder.* and invoke a static creation method followed by an instance mutator - * (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.CreateImageOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Future<Set<ImageMetadata>> images = connection.getAMIApi().get().createImage(withDescription("123125").noReboot()); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-CreateImage.html" - * /> - */ -public class CreateImageOptions extends BaseEC2RequestOptions { - public static final CreateImageOptions NONE = new CreateImageOptions(); - - /** - * The description of the AMI that was provided during image creation. - * <p/> - * - * Up to 255 characters - */ - public CreateImageOptions withDescription(String description) { - formParameters.put("Description", checkNotNull(description, "description")); - return this; - } - - public String getDescription() { - return getFirstFormOrNull("Description"); - - } - - /** - * By default this property is set to false, which means Amazon EC2 attempts to cleanly shut down - * the instance before image creation and reboots the instance afterwards. When set to true, - * Amazon EC2 does not shut down the instance before creating the image. When this option is - * used, file system integrity on the created image cannot be guaranteed. - */ - public CreateImageOptions noReboot() { - formParameters.put("NoReboot", "true"); - return this; - } - - public boolean getNoReboot() { - return getFirstFormOrNull("NoReboot") != null; - } - - public static class Builder { - - /** - * @see CreateImageOptions#withDescription(String ) - */ - public static CreateImageOptions withDescription(String description) { - CreateImageOptions options = new CreateImageOptions(); - return options.withDescription(description); - } - - /** - * @see CreateImageOptions#noReboot() - */ - public static CreateImageOptions noReboot() { - CreateImageOptions options = new CreateImageOptions(); - return options.noReboot(); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java deleted file mode 100644 index 2c05a27..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.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 CreateSnapshot operation. <h2> - * Usage</h2> The recommended way to instantiate a CreateSnapshotOptions object is to statically - * import CreateSnapshotOptions.Builder.* and invoke a static creation method followed by an - * instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.CreateSnapshotOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Snapshot snapshot = connection.getElasticBlockStoreApi().get().createSnapshotInRegion(volumeId, withDescription("123125")); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-CreateSnapshot.html" - * /> - */ -public class CreateSnapshotOptions extends BaseEC2RequestOptions { - - /** - * Description of the Amazon EBS snapshot. - * <p/> - * - * Up to 255 characters - */ - public CreateSnapshotOptions withDescription(String description) { - formParameters.put("Description", checkNotNull(description, "description")); - return this; - } - - public String getDescription() { - return getFirstFormOrNull("Description"); - - } - - public static class Builder { - - /** - * @see CreateSnapshotOptions#withDescription(String ) - */ - public static CreateSnapshotOptions withDescription(String identityId) { - CreateSnapshotOptions options = new CreateSnapshotOptions(); - return options.withDescription(identityId); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java deleted file mode 100644 index 5b3f693..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.ec2.options; - -import java.util.Arrays; -import java.util.Set; - -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * Contains options supported in the Form API for the DescribeAvailabilityZones operation. <h2> - * Usage</h2> The recommended way to instantiate a DescribeAvailabilityZonesOptions object is to - * statically import DescribeAvailabilityZonesOptions.Builder.* and invoke a static creation method - * followed by an instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Future<Set<ImageMetadata>> images = connection.getAvailabilityZoneAndRegionApi().get().describeAvailabilityZones(zones("us-east-1a", "us-east-1b")); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeAvailabilityZones.html" - * /> - */ -public class DescribeAvailabilityZonesOptions extends BaseEC2RequestOptions { - - /** - * Availability Zone name. - */ - public DescribeAvailabilityZonesOptions zones(String... zones) { - String[] zoneStrings = Arrays.copyOf(zones, zones.length, String[].class); - indexFormValuesWithPrefix("ZoneName", zoneStrings); - return this; - } - - public Set<String> getZones() { - return getFormValuesWithKeysPrefixedBy("ZoneName."); - } - - public static class Builder { - - /** - * @see DescribeAvailabilityZonesOptions#zones(String...) - */ - public static DescribeAvailabilityZonesOptions availabilityZones(String... zones) { - DescribeAvailabilityZonesOptions options = new DescribeAvailabilityZonesOptions(); - return options.zones(zones); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java deleted file mode 100644 index d81ba88..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.ec2.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * Contains options supported in the Form API for the DescribeImages operation. <h2> - * Usage</h2> The recommended way to instantiate a DescribeImagesOptions object is to statically - * import DescribeImagesOptions.Builder.* and invoke a static creation method followed by an - * instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Future<Set<ImageMetadata>> images = connection.getAMIApi().get().describeImages(executableBy("123125").imageIds(1000, 1004)); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeImages.html" - * /> - */ -public class DescribeImagesOptions extends BaseEC2RequestOptions { - public static final DescribeImagesOptions NONE = new DescribeImagesOptions(); - - /** - * AMIs for which the specified user has explicit launch permissions. - * - */ - public DescribeImagesOptions executableBy(String identityId) { - formParameters.put("ExecutableBy", checkNotNull(identityId, "identityId")); - return this; - } - - public String getExecutableBy() { - return getFirstFormOrNull("ExecutableBy"); - } - - /** - * AMI IDs to describe. - */ - public DescribeImagesOptions imageIds(String... imageIds) { - indexFormValuesWithPrefix("ImageId", imageIds); - return this; - } - - public DescribeImagesOptions imageIds(Iterable<String> imageIds) { - indexFormValuesWithPrefix("ImageId", imageIds); - return this; - } - - public Set<String> getImageIds() { - return getFormValuesWithKeysPrefixedBy("ImageId."); - } - - /** - * Returns AMIs owned by the specified owner. Multiple owners can be specified. - */ - public DescribeImagesOptions ownedBy(String... owners) { - indexFormValuesWithPrefix("Owner", owners); - return this; - } - - public Set<String> getOwners() { - return getFormValuesWithKeysPrefixedBy("Owner."); - } - - public static class Builder { - - /** - * @see DescribeImagesOptions#executableBy(String ) - */ - public static DescribeImagesOptions executableBy(String identityId) { - DescribeImagesOptions options = new DescribeImagesOptions(); - return options.executableBy(identityId); - } - - /** - * @see DescribeImagesOptions#imageIds(String[] ) - */ - public static DescribeImagesOptions imageIds(String... imageIds) { - DescribeImagesOptions options = new DescribeImagesOptions(); - return options.imageIds(imageIds); - } - - /** - * @see DescribeImagesOptions#ownedBy(String[] ) - */ - public static DescribeImagesOptions ownedBy(String... owners) { - DescribeImagesOptions options = new DescribeImagesOptions(); - return options.ownedBy(owners); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java deleted file mode 100644 index 594194d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.ec2.options; - -import java.util.Arrays; -import java.util.Set; - -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * Contains options supported in the Form API for the DescribeRegions operation. <h2> - * Usage</h2> The recommended way to instantiate a DescribeRegionsOptions object is to statically - * import DescribeRegionsOptions.Builder.* and invoke a static creation method followed by an - * instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Future<Set<ImageMetadata>> images = connection.getRegionsAndRegionsServices().describeRegions(regions("us-east-1a", "us-east-1b")); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeRegions.html" - * /> - */ -public class DescribeRegionsOptions extends BaseEC2RequestOptions { - - /** - * Name of a Region. - */ - public DescribeRegionsOptions regions(String... regions) { - String[] regionStrings = Arrays.copyOf(regions, regions.length, String[].class); - indexFormValuesWithPrefix("RegionName", regionStrings); - return this; - } - - public Set<String> getZones() { - return getFormValuesWithKeysPrefixedBy("RegionName."); - } - - public static class Builder { - - /** - * @see DescribeRegionsOptions#regions(String[] ) - */ - public static DescribeRegionsOptions regions(String... regions) { - DescribeRegionsOptions options = new DescribeRegionsOptions(); - return options.regions(regions); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java deleted file mode 100644 index 8dfe3cb..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.ec2.options; - -import java.util.Set; - -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * Contains options supported in the Form API for the DescribeSnapshots operation. <h2> - * Usage</h2> The recommended way to instantiate a DescribeSnapshotsOptions object is to statically - * import DescribeSnapshotsOptions.Builder.* and invoke a static creation method followed by an - * instance mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * Set<Snapshot> snapshots = connection.getElasticBlockStoreApi().get().describeSnapshots(restorableBy("123125").snapshotIds(1000, 1004)); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeSnapshots.html" - * /> - */ -public class DescribeSnapshotsOptions extends BaseEC2RequestOptions { - - /** - * Account ID of a user that can create volumes from the snapshot. - * - */ - public DescribeSnapshotsOptions restorableBy(String... accountIds) { - indexFormValuesWithPrefix("RestorableBy", accountIds); - return this; - } - - public String getRestorableBy() { - return getFirstFormOrNull("RestorableBy"); - } - - /** - * The ID of the Amazon EBS snapshot. - */ - public DescribeSnapshotsOptions snapshotIds(String... snapshotIds) { - indexFormValuesWithPrefix("SnapshotId", snapshotIds); - return this; - } - - public Set<String> getSnapshotIds() { - return getFormValuesWithKeysPrefixedBy("SnapshotId."); - } - - /** - * Returns snapshots owned by the specified owner. Multiple owners can be specified. - * <p/> - * Valid Values: self | amazon | AWS Account ID - */ - public DescribeSnapshotsOptions ownedBy(String... owners) { - indexFormValuesWithPrefix("Owner", owners); - return this; - } - - public Set<String> getOwners() { - return getFormValuesWithKeysPrefixedBy("Owner."); - } - - public static class Builder { - - /** - * @see DescribeSnapshotsOptions#restorableBy(String[] ) - */ - public static DescribeSnapshotsOptions restorableBy(String... accountIds) { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - return options.restorableBy(accountIds); - } - - /** - * @see DescribeSnapshotsOptions#snapshotIds(String[] ) - */ - public static DescribeSnapshotsOptions snapshotIds(String... snapshotIds) { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - return options.snapshotIds(snapshotIds); - } - - /** - * @see DescribeSnapshotsOptions#ownedBy(String[] ) - */ - public static DescribeSnapshotsOptions ownedBy(String... owners) { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - return options.ownedBy(owners); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java deleted file mode 100644 index 0b9fc89..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.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 DetachVolume operation. <h2> - * Usage</h2> The recommended way to instantiate a DetachVolumeOptions object is to statically - * import DetachVolumeOptions.Builder.* and invoke a static creation method followed by an instance - * mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.* - * <p/> - * EC2Api client = // get connection - * client.getElasticBlockStoreApi().get().detachVolumeInRegion(null, id, fromDevice("123125").force()); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DetachVolume.html" - * /> - */ -public class DetachVolumeOptions extends BaseEC2RequestOptions { - /** - * The ID of the instance. - */ - public DetachVolumeOptions fromInstance(String instanceId) { - formParameters.put("InstanceId", checkNotNull(instanceId, "instanceId")); - return this; - } - - public String getInstance() { - return getFirstFormOrNull("InstanceId"); - - } - - /** - * The device name. - */ - public DetachVolumeOptions fromDevice(String device) { - formParameters.put("Device", checkNotNull(device, "device")); - return this; - } - - public String getDevice() { - return getFirstFormOrNull("Device"); - - } - - public static class Builder { - /** - * @see DetachVolumeOptions#fromInstance(String ) - */ - public static DetachVolumeOptions fromInstance(String instance) { - DetachVolumeOptions options = new DetachVolumeOptions(); - return options.fromInstance(instance); - } - - /** - * @see DetachVolumeOptions#fromDevice(String ) - */ - public static DetachVolumeOptions fromDevice(String device) { - DetachVolumeOptions options = new DetachVolumeOptions(); - return options.fromDevice(device); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java deleted file mode 100644 index 1da21c0..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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.ec2.options; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.javax.annotation.Nullable; - -/** - * Contains options supported in the Form API for the RegisterImage operation. <h2> - * Usage</h2> The recommended way to instantiate a RegisterImageBackedByEbsOptions object is to statically - * import RegisterImageBackedByEbsOptions.Builder.* and invoke a static creation method followed by an instance - * mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * String imageId = connection.getImageServices().registerImageBackedByEbs(...addEphemeralBlockDeviceFromSnapshot("/dev/sda2","virtual-1","snapshot-id")); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RegisterImage.html" - * /> - */ -public class RegisterImageBackedByEbsOptions extends RegisterImageOptions { - - private int deviceIndex = 1; - - /** - * - * adds a block device to the image from an ebs snapshot. This device is deleted on instance - * termination. - * - * @param name - * The device name (e.g., /dev/sdh). - * @param virtualName - * The virtual device name. (nullable) - * @param snapshotId - * The ID of the snapshot. - */ - public RegisterImageBackedByEbsOptions addEphemeralBlockDeviceFromSnapshot(String deviceName, - @Nullable String virtualName, String snapshotId) { - formParameters.put("BlockDeviceMapping." + deviceIndex + ".DeviceName", checkNotNull( - deviceName, "deviceName")); - if (virtualName != null) - formParameters.put("BlockDeviceMapping." + deviceIndex + ".VirtualName", checkNotNull( - virtualName, "virtualName")); - formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.SnapshotId", checkNotNull( - snapshotId, "snapshotId")); - deviceIndex++; - return this; - } - - /** - * - * adds a new block device to the image. This device is deleted on instance termination. - * - * @param name - * The device name (e.g., /dev/sdh). - * @param virtualName - * The virtual device name. - * @param volumeSize - * The size of the volume, in GiBs. - */ - public RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName, - @Nullable String virtualName, int volumeSize) { - checkArgument(volumeSize > 0 && volumeSize < 1025, "volumeSize must be between 1 and 1024 gb"); - formParameters.put("BlockDeviceMapping." + deviceIndex + ".DeviceName", checkNotNull( - deviceName, "deviceName")); - if (virtualName != null) - formParameters.put("BlockDeviceMapping." + deviceIndex + ".VirtualName", checkNotNull( - virtualName, "virtualName")); - formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.VolumeSize", volumeSize + ""); - deviceIndex++; - return this; - } - - /** - * - * adds a block device to the image from an ebs snapshot. This device is retained on instance - * termination. - * - * @param name - * The device name (e.g., /dev/sdh). - * @param virtualName - * The virtual device name. (nullable) - * @param snapshotId - * The ID of the snapshot. - */ - public RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, - @Nullable String virtualName, String snapshotId) { - formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false"); - addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); - return this; - } - - /** - * - * adds a new block device to the image. This device is retained on instance termination. - * - * @param name - * The device name (e.g., /dev/sdh). - * @param virtualName - * The virtual device name. - * @param volumeSize - * The size of the volume, in GiBs.. - */ - public RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName, - @Nullable String virtualName, int volumeSize) { - formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false"); - addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize); - return this; - } - - public static class Builder { - /** - * @see RegisterImageBackedByEbsOptions#asArchitecture(Architecture) - */ - public static RegisterImageBackedByEbsOptions asArchitecture(Architecture architecture) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.asArchitecture(architecture); - } - - /** - * @see RegisterImageBackedByEbsOptions#withDescription(String) - */ - public static RegisterImageBackedByEbsOptions withDescription(String additionalInfo) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.withDescription(additionalInfo); - } - - /** - * @see RegisterImageBackedByEbsOptions#withKernelId(String) - */ - public static RegisterImageBackedByEbsOptions withKernelId(String kernelId) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.withKernelId(kernelId); - } - - /** - * @see RegisterImageBackedByEbsOptions#withRamdisk(String) - */ - public static RegisterImageBackedByEbsOptions withRamdisk(String ramdiskId) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.withRamdisk(ramdiskId); - } - - /** - * @see RegisterImageBackedByEbsOptions#addBlockDeviceFromSnapshot(String, String, String) - */ - public static RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, - @Nullable String virtualName, String snapshotId) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.addBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); - } - - /** - * @see RegisterImageBackedByEbsOptions#addEphemeralBlockDeviceFromSnapshot(String, String, - * String) - */ - public static RegisterImageBackedByEbsOptions addEphemeralBlockDeviceFromSnapshot( - String deviceName, @Nullable String virtualName, String snapshotId) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); - } - - /** - * @see RegisterImageBackedByEbsOptions#addNewBlockDevice(String, String, int) - */ - public static RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName, - @Nullable String virtualName, int volumeSize) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.addNewBlockDevice(deviceName, virtualName, volumeSize); - } - - /** - * @see RegisterImageBackedByEbsOptions#addNewEphemeralBlockDevice(String, String, int) - */ - public static RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName, - @Nullable String virtualName, int volumeSize) { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - return options.addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize); - } - } - - /** - * {@inheritDoc} - */ - @Override - public RegisterImageBackedByEbsOptions asArchitecture(Architecture architecture) { - return (RegisterImageBackedByEbsOptions) super.asArchitecture(architecture); - } - - /** - * {@inheritDoc} - */ - @Override - public RegisterImageBackedByEbsOptions withDescription(String info) { - return (RegisterImageBackedByEbsOptions) super.withDescription(info); - } - - /** - * {@inheritDoc} - */ - @Override - public RegisterImageBackedByEbsOptions withKernelId(String kernelId) { - return (RegisterImageBackedByEbsOptions) super.withKernelId(kernelId); - } - - /** - * {@inheritDoc} - */ - @Override - public RegisterImageBackedByEbsOptions withRamdisk(String ramDiskId) { - return (RegisterImageBackedByEbsOptions) super.withRamdisk(ramDiskId); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java deleted file mode 100644 index 76c2a01..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.ec2.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * Contains options supported in the Form API for the RegisterImage operation. <h2> - * Usage</h2> The recommended way to instantiate a RegisterImageOptions object is to statically - * import RegisterImageOptions.Builder.* and invoke a static creation method followed by an instance - * mutator (if needed): - * <p/> - * <code> - * import static org.jclouds.ec2.options.RegisterImageOptions.Builder.* - * <p/> - * EC2Api connection = // get connection - * String imageId = connection.getImageServices().registerImageFromManifest(...withArchitecture(Architecture.I386).withDescription("description")); - * <code> - * - * @author Adrian Cole - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RegisterImage.html" - * /> - */ -public class RegisterImageOptions extends BaseEC2RequestOptions { - - /** - * The architecture of the image. - */ - public RegisterImageOptions asArchitecture(Architecture architecture) { - formParameters.put("Architecture", checkNotNull(architecture, "architecture").value()); - return this; - } - - String getArchitecture() { - return getFirstFormOrNull("Architecture"); - } - - /** - *The description of the AMI. "Up to 255 characters." - */ - public RegisterImageOptions withDescription(String info) { - formParameters.put("Description", checkNotNull(info, "info")); - return this; - } - - String getDescription() { - return getFirstFormOrNull("Description"); - } - - /** - * The ID of the kernel to select. - */ - public RegisterImageOptions withKernelId(String kernelId) { - formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); - return this; - } - - String getKernelId() { - return getFirstFormOrNull("KernelId"); - } - - /** - * The ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the - * kernel requirements for information on whether you need to specify a RAM disk. To find kernel - * requirements, refer to the Resource Center and search for the kernel ID. - */ - public RegisterImageOptions withRamdisk(String ramDiskId) { - formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); - return this; - } - - String getRamdiskId() { - return getFirstFormOrNull("RamdiskId"); - } - - public static class Builder { - /** - * @see RegisterImageOptions#asArchitecture(Architecture) - */ - public static RegisterImageOptions asArchitecture(Architecture architecture) { - RegisterImageOptions options = new RegisterImageOptions(); - return options.asArchitecture(architecture); - } - - /** - * @see RegisterImageOptions#withDescription(String) - */ - public static RegisterImageOptions withDescription(String additionalInfo) { - RegisterImageOptions options = new RegisterImageOptions(); - return options.withDescription(additionalInfo); - } - - /** - * @see RegisterImageOptions#withKernelId(String) - */ - public static RegisterImageOptions withKernelId(String kernelId) { - RegisterImageOptions options = new RegisterImageOptions(); - return options.withKernelId(kernelId); - } - - /** - * @see RegisterImageOptions#withRamdisk(String) - */ - public static RegisterImageOptions withRamdisk(String ramdiskId) { - RegisterImageOptions options = new RegisterImageOptions(); - return options.withRamdisk(ramdiskId); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java deleted file mode 100644 index 7ccb209..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.ec2.options; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.io.BaseEncoding.base64; - -import java.util.Set; - -import org.jclouds.ec2.domain.BlockDeviceMapping; -import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; - -/** - * 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 RunInstancesOptions extends BaseEC2RequestOptions { - public static final RunInstancesOptions NONE = new RunInstancesOptions(); - - /** - * The name of the key pair. - */ - public RunInstancesOptions withKeyName(String keyName) { - formParameters.put("KeyName", checkNotNull(keyName, "keyName")); - return this; - } - - /** - * Attach multiple security groups - */ - public RunInstancesOptions withSecurityGroups(String... securityGroups) { - indexFormValuesWithPrefix("SecurityGroup", securityGroups); - return this; - } - - /** - * Attach multiple security groups - */ - public RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups) { - indexFormValuesWithPrefix("SecurityGroup", securityGroups); - return this; - } - - /** - * Attaches a single security group. Multiple calls to this method won't add more groups. - * - * @param securityGroup - * name of an existing security group - */ - public RunInstancesOptions withSecurityGroup(String securityGroup) { - return withSecurityGroups(securityGroup); - } - - /** - * Unencoded data - */ - public RunInstancesOptions withUserData(byte[] unencodedData) { - int length = checkNotNull(unencodedData, "unencodedData").length; - checkArgument(length > 0, "userData cannot be empty"); - checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); - formParameters.put("UserData", base64().encode(unencodedData)); - return this; - } - - /** - * Specifies the instance type. default small; - */ - public RunInstancesOptions asType(String type) { - formParameters.put("InstanceType", checkNotNull(type, "type")); - return this; - } - - /** - * The ID of the kernel with which to launch the instance. - */ - public RunInstancesOptions withKernelId(String kernelId) { - formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); - return this; - } - - /** - * The ID of the RAM disk with which to launch the instance. Some kernels require additional - * drivers at launch. Check the kernel requirements for information on whether you need to - * specify a RAM disk. To find kernel requirements, go to the Resource Center and search for the - * kernel ID. - */ - public RunInstancesOptions withRamdisk(String ramDiskId) { - formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); - return this; - } - - /** - * Specifies the Block Device Mapping for the instance - * - */ - public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { - int i = 1; - for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { - checkNotNull(mapping.getDeviceName(), "deviceName"); - formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); - if (mapping.getVirtualName() != null) - formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); - if (mapping.getEbsSnapshotId() != null) - formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); - if (mapping.getEbsVolumeSize() != null) - formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), - String.valueOf(mapping.getEbsVolumeSize())); - if (mapping.getEbsNoDevice() != null) - formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), - String.valueOf(mapping.getEbsNoDevice())); - if (mapping.getEbsDeleteOnTermination() != null) - formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), - String.valueOf(mapping.getEbsDeleteOnTermination())); - i++; - } - return this; - } - - public static class Builder { - /** - * @see RunInstancesOptions#withKeyName(String) - */ - public static RunInstancesOptions withKeyName(String keyName) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withKeyName(keyName); - } - - /** - * @see RunInstancesOptions#withSecurityGroup(String) - */ - public static RunInstancesOptions withSecurityGroup(String securityGroup) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withSecurityGroup(securityGroup); - } - - /** - * @see RunInstancesOptions#withUserData(byte []) - */ - public static RunInstancesOptions withUserData(byte[] unencodedData) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withUserData(unencodedData); - } - - /** - * @see RunInstancesOptions#asType(InstanceType) - */ - public static RunInstancesOptions asType(String instanceType) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.asType(instanceType); - } - - /** - * @see RunInstancesOptions#withKernelId(String) - */ - public static RunInstancesOptions withKernelId(String kernelId) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withKernelId(kernelId); - } - - /** - * @see RunInstancesOptions#withRamdisk(String) - */ - public static RunInstancesOptions withRamdisk(String ramdiskId) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withRamdisk(ramdiskId); - } - - /** - * @see RunInstancesOptions#withBlockDeviceMappings(Set<BlockDeviceMapping> mappings) - */ - public static RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { - RunInstancesOptions options = new RunInstancesOptions(); - return options.withBlockDeviceMappings(mappings); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java deleted file mode 100644 index 3ec5e8d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.ec2.options.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.http.options.BaseHttpRequestOptions; -import org.jclouds.util.Predicates2; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -public class BaseEC2RequestOptions extends BaseHttpRequestOptions { - - @Override - public String toString() { - return "[formParameters=" + formParameters + "]"; - } - - protected void indexFormValuesWithPrefix(String prefix, String... values) { - for (int i = 0; i < values.length; i++) { - formParameters.put(prefix + "." + (i + 1), checkNotNull(values[i], prefix.toLowerCase() + "s[" + i + "]")); - } - } - - protected void indexFormValuesWithPrefix(String prefix, Iterable<String> values) { - indexFormValuesWithPrefix(prefix, Iterables.toArray(values, String.class)); - } - - protected Set<String> getFormValuesWithKeysPrefixedBy(final String prefix) { - Builder<String> values = ImmutableSet.builder(); - for (String key : Iterables.filter(formParameters.keySet(), Predicates2.startsWith(prefix))) { - values.add(Iterables.get(formParameters.get(key), 0)); - } - return values.build(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java deleted file mode 100644 index 57d576d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.ec2.predicates; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.aws.AWSResponseException; -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - -/** - * - * Tests to see if a task succeeds. - * - * @author Adrian Cole - */ -@Singleton -public class InstanceHasIpAddress implements Predicate<RunningInstance> { - - private final EC2Api client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public InstanceHasIpAddress(EC2Api client) { - this.client = client; - } - - public boolean apply(RunningInstance instance) { - logger.trace("looking for ipAddress on instance %s", instance); - try { - instance = refresh(instance); - return instance.getIpAddress() != null; - } catch (AWSResponseException e) { - if (e.getError().getCode().equals("InvalidInstanceID.NotFound")) - return false; - throw e; - } - } - - private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceApi().get() - .describeInstancesInRegion(instance.getRegion(), instance.getId()))); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java deleted file mode 100644 index 893e689..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.ec2.predicates; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.RunningInstance; -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; - -/** - * - * Tests to see if a task succeeds. - * - * @author Adrian Cole - */ -@Singleton -public class InstanceStateRunning implements Predicate<RunningInstance> { - - private final EC2Api client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public InstanceStateRunning(EC2Api client) { - this.client = client; - } - - public boolean apply(RunningInstance instance) { - logger.trace("looking for state on instance %s", instance); - try { - instance = refresh(instance); - logger.trace("%s: looking for instance state %s: currently: %s", - instance.getId(), InstanceState.RUNNING, instance - .getInstanceState()); - return instance.getInstanceState() == InstanceState.RUNNING; - } catch (ResourceNotFoundException e) { - return false; - } - } - - private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client - .getInstanceApi().get().describeInstancesInRegion( - instance.getRegion(), instance.getId()))); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java deleted file mode 100644 index 644d858..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.ec2.predicates; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.features.InstanceApi; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - -/** - * - * Tests to see if a task succeeds. - * - * @author Adrian Cole - */ -@Singleton -public class InstanceStateStopped implements Predicate<RunningInstance> { - - private final InstanceApi client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public InstanceStateStopped(InstanceApi client) { - this.client = client; - } - - public boolean apply(RunningInstance instance) { - logger.trace("looking for state on instance %s", instance); - instance = refresh(instance); - logger.trace("%s: looking for instance state %s: currently: %s", instance.getId(), - InstanceState.STOPPED, instance.getInstanceState()); - return instance.getInstanceState() == InstanceState.STOPPED; - } - - private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client.describeInstancesInRegion( - instance.getRegion(), instance.getId()))); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java deleted file mode 100644 index 8c9a3fd..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.ec2.predicates; - -import java.util.NoSuchElementException; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - -/** - * - * Tests to see if a task succeeds. - * - * @author Adrian Cole - */ -@Singleton -public class InstanceStateTerminated implements Predicate<RunningInstance> { - - private final EC2Api client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public InstanceStateTerminated(EC2Api client) { - this.client = client; - } - - public boolean apply(RunningInstance instance) { - logger.trace("looking for state on instance %s", instance); - try { - instance = refresh(instance); - } catch (NoSuchElementException e) { - return true; - } - logger.trace("%s: looking for instance state %s: currently: %s", instance.getId(), - InstanceState.TERMINATED, instance.getInstanceState()); - return instance.getInstanceState() == InstanceState.TERMINATED; - } - - private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceApi().get() - .describeInstancesInRegion(instance.getRegion(), instance.getId()))); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java deleted file mode 100644 index ef5281a..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.ec2.predicates; - -import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.ec2.features.ElasticBlockStoreApi; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - -/** - * - * Tests to see if a snapshot is completed. - * - * @author Adrian Cole - */ -@Singleton -public class SnapshotCompleted implements Predicate<Snapshot> { - - private final ElasticBlockStoreApi client; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public SnapshotCompleted(ElasticBlockStoreApi client) { - this.client = client; - } - - public boolean apply(Snapshot snapshot) { - logger.trace("looking for status on snapshot %s", snapshot.getId()); - - snapshot = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(), - snapshotIds(snapshot.getId()))); - logger.trace("%s: looking for status %s: currently: %s; progress %d/100", snapshot, - Snapshot.Status.COMPLETED, snapshot.getStatus(), snapshot.getProgress()); - return snapshot.getStatus() == Snapshot.Status.COMPLETED; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java deleted file mode 100644 index f3ebfaf..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.ec2.predicates; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.features.ElasticBlockStoreApi; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.inject.Inject; - -/** - * - * Tests to see if a volume is attached. - * - * @author Adrian Cole - */ -@Singleton -public class VolumeAttached implements Predicate<Attachment> { - - private final ElasticBlockStoreApi client; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public VolumeAttached(ElasticBlockStoreApi client) { - this.client = client; - } - - public boolean apply(Attachment attachment) { - logger.trace("looking for volume %s", attachment.getVolumeId()); - Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment - .getRegion(), attachment.getVolumeId())); - if (volume.getAttachments().size() == 0) { - return false; - } - Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); - logger.trace("%s: looking for status %s: currently: %s", lastAttachment, - Attachment.Status.ATTACHED, lastAttachment.getStatus()); - return lastAttachment.getStatus() == Attachment.Status.ATTACHED; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java deleted file mode 100644 index 9688add..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.ec2.predicates; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.features.ElasticBlockStoreApi; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - -/** - * - * Tests to see if a volume is completed. - * - * @author Adrian Cole - */ -@Singleton -public class VolumeAvailable implements Predicate<Volume> { - - private final ElasticBlockStoreApi client; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public VolumeAvailable(ElasticBlockStoreApi client) { - this.client = client; - } - - public boolean apply(Volume volume) { - logger.trace("looking for status on volume %s", volume.getId()); - volume = Iterables.getOnlyElement(client.describeVolumesInRegion(volume.getRegion(), volume - .getId())); - logger.trace("%s: looking for status %s: currently: %s", volume, Volume.Status.AVAILABLE, - volume.getStatus()); - return volume.getStatus() == Volume.Status.AVAILABLE; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java deleted file mode 100644 index accabe8..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.ec2.predicates; - -import static com.google.common.collect.Iterables.getLast; - -import javax.annotation.Resource; - -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.features.ElasticBlockStoreApi; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * Tests to see if a volume is detached. - * - * @author Karthik Arunachalam - */ -@Singleton -public class VolumeDetached implements Predicate<Attachment> { - - private final ElasticBlockStoreApi client; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public VolumeDetached(ElasticBlockStoreApi client) { - this.client = client; - } - - public boolean apply(Attachment attachment) { - logger.trace("looking for volume %s", attachment.getVolumeId()); - Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment - .getRegion(), attachment.getVolumeId())); - - /*If attachment size is 0 volume is detached for sure.*/ - if (volume.getAttachments().size() == 0) { - return true; - } - - /* But if attachment size is > 0, then the attachment could be in any state. - * So we need to check if the status is DETACHED (return true) or not (return false). - */ - Attachment lastAttachment = getLast(volume.getAttachments()); - logger.trace("%s: looking for status %s: currently: %s", lastAttachment, - Attachment.Status.DETACHED, lastAttachment.getStatus()); - return lastAttachment.getStatus() == Attachment.Status.DETACHED; - } -} - http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java deleted file mode 100644 index 0d45789..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.ec2.reference; - - -/** - * Configuration properties and constants used in EC2 connections. - * - * @author Adrian Cole - */ -public interface EC2Constants { - /** - * Listing the universe of amis is extremely expensive. set this to a comma separated value of - * the ami owners you wish to use in {@link ComputeService} - */ - public static final String PROPERTY_EC2_AMI_OWNERS = "jclouds.ec2.ami-owners"; - - /** - * Eventual consistency delay for retrieving a security group after it is created (in ms) - */ - public static final String PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT = "jclouds.ec2.timeout.securitygroup-present"; - - /** - * Whenever a node is created, automatically allocate and assign an elastic ip address, also - * deallocate when the node is destroyed. - */ - public static final String PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS = "jclouds.ec2.auto-allocate-elastic-ips"; - - /** - * If this property is set to true(default), jclouds generate a name for each instance based on the group. ex. - * i-ef34ae2 becomes hadoop-ef34ae2. Note that this depends on {@link EC2Api#getTagApi} returning present. - */ - public static final String PROPERTY_EC2_GENERATE_INSTANCE_NAMES = "jclouds.ec2.generate-instance-names"; - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java deleted file mode 100644 index f97e962..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.ec2.suppliers; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; -import org.jclouds.http.HttpResponseException; -import org.jclouds.location.Region; -import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; -import org.jclouds.logging.Logger; -import org.jclouds.util.Suppliers2; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; - -@Singleton -public class DescribeAvailabilityZonesInRegion implements RegionIdToZoneIdsSupplier { - @Resource - protected Logger logger = Logger.NULL; - - private final AvailabilityZoneAndRegionApi client; - private final Supplier<Set<String>> regions; - - @Inject - public DescribeAvailabilityZonesInRegion(EC2Api client, @Region Supplier<Set<String>> regions) { - this.client = client.getAvailabilityZoneAndRegionApi().get(); - this.regions = regions; - } - - @Override - public Map<String, Supplier<Set<String>>> get() { - Builder<String, Set<String>> map = ImmutableMap.builder(); - HttpResponseException exception = null; - // TODO: this should be parallel - for (String region : regions.get()) { - try { - ImmutableSet<String> zones = ImmutableSet.copyOf(Iterables.transform(client - .describeAvailabilityZonesInRegion(region), new Function<AvailabilityZoneInfo, String>() { - - @Override - public String apply(AvailabilityZoneInfo arg0) { - return arg0.getZone(); - } - - })); - if (zones.size() > 0) - map.put(region, zones); - } catch (HttpResponseException e) { - // TODO: this should be in retry handler, not here. - if (e.getMessage().contains("Unable to tunnel through proxy")) { - exception = e; - logger.error(e, "Could not describe availability zones in Region: %s", region); - } else { - throw e; - } - } - } - ImmutableMap<String, Set<String>> result = map.build(); - if (result.isEmpty() && exception != null) { - throw exception; - } - return Maps.transformValues(result, Suppliers2.<Set<String>> ofInstanceFunction()); - } - -}
