You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/07/01 21:13:12 UTC
[07/20] JCLOUDS-150 - Removal of async from AWS - specifically EC2
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java
deleted file mode 100644
index e4a83a2..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java
+++ /dev/null
@@ -1,64 +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.openstack.nova.ec2.services;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Set;
-
-import org.jclouds.ec2.domain.Attachment;
-import org.jclouds.ec2.domain.Volume;
-import org.jclouds.ec2.services.ElasticBlockStoreClient;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * @author Adam Lowe
- */
-@Test(groups = "unit", testName = "NovaEC2ElasticBlockStoreClientTest")
-public class NovaEC2ElasticBlockStoreExpectClientTest extends BaseNovaEC2RestClientExpectTest {
-
- public void testDescribeVolumesWithNovaEC2Status() {
- ElasticBlockStoreClient client = requestsSendResponses(
- describeAvailabilityZonesRequest,
- describeAvailabilityZonesResponse,
- HttpRequest.builder().method("POST")
- .endpoint("http://localhost:8773/services/Cloud/")
- .addHeader("Host", "localhost:8773")
- .payload(payloadFromStringWithContentType("Action=DescribeVolumes&Signature=AvRznSzGExM%2Buaj2JJj66wq4v4f%2BakicyLooRDtC0t0%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
- HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_describe_volumes.xml")).build()
- ).getElasticBlockStoreServices();
-
- Set<Volume> expected = ImmutableSet.of(Volume
- .builder()
- .status(Volume.Status.AVAILABLE)
- .availabilityZone("nova")
- .region("nova")
- .id("vol-00000007")
- .size(1)
- .attachments(Attachment.builder().region("nova").build())
- .createTime(dateService.iso8601SecondsDateParse("2012-04-10T10:39:52Z"))
- .build());
-
- assertEquals(client.describeVolumesInRegion("nova"), expected);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java
deleted file mode 100644
index fcf8c1b..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java
+++ /dev/null
@@ -1,32 +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.openstack.nova.ec2.services;
-
-import org.jclouds.ec2.services.ElasticIPAddressClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "NovaEC2ElasticIPAddressClientLiveTest")
-public class NovaEC2ElasticIPAddressClientLiveTest extends ElasticIPAddressClientLiveTest {
- public NovaEC2ElasticIPAddressClientLiveTest() {
- provider = "openstack-nova-ec2";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java
deleted file mode 100644
index 3c412f3..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java
+++ /dev/null
@@ -1,67 +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.openstack.nova.ec2.services;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-
-import java.util.Set;
-
-import org.jclouds.ec2.domain.BlockDevice;
-import org.jclouds.ec2.domain.Reservation;
-import org.jclouds.ec2.domain.RunningInstance;
-import org.jclouds.ec2.services.InstanceClient;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest;
-
-import com.google.common.collect.Iterables;
-
-/**
- * @author Adam Lowe
- */
-public class NovaEC2InstanceClientExpectTest extends BaseNovaEC2RestClientExpectTest {
-
- public void testDescribeInstancesWithDashesInPlaceOfNullDates() {
- InstanceClient client = requestsSendResponses(
- describeAvailabilityZonesRequest,
- describeAvailabilityZonesResponse,
- HttpRequest.builder().method("POST")
- .endpoint("http://localhost:8773/services/Cloud/")
- .addHeader("Host", "localhost:8773")
- .payload(payloadFromStringWithContentType("Action=DescribeInstances&Signature=kkCE1HzyntmkICEidOizw50B9yjLdNZvAWUXVse1c8o%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
- HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_describe_instances.xml")).build()
- ).getInstanceServices();
-
- Set<? extends Reservation<? extends RunningInstance>> response = client.describeInstancesInRegion("nova");
-
- assertEquals(response.size(), 3);
-
- Reservation<? extends RunningInstance> target = Iterables.get(response, 2);
- RunningInstance runningInstance = Iterables.getOnlyElement(target);
- BlockDevice bd = Iterables.getOnlyElement(runningInstance.getEbsBlockDevices().values());
-
- // this is a '-' in the nova_ec2_describe_instances.xml
- assertNull(bd.getAttachTime());
-
- // double-check the other fields
- assertFalse(bd.isDeleteOnTermination());
- assertEquals(bd.getVolumeId(), "1");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java
deleted file mode 100644
index 4244688..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java
+++ /dev/null
@@ -1,32 +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.openstack.nova.ec2.services;
-
-import org.jclouds.ec2.services.InstanceClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "NovaEC2InstanceClientLiveTest")
-public class NovaEC2InstanceClientLiveTest extends InstanceClientLiveTest {
- public NovaEC2InstanceClientLiveTest() {
- provider = "openstack-nova-ec2";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java
deleted file mode 100644
index 9c3903d..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java
+++ /dev/null
@@ -1,78 +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.openstack.nova.ec2.services;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-/**
- * @author Adam Lowe
- */
-public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectTest {
-
- public void testImportKeyPair() {
- NovaEC2KeyPairClient client = requestsSendResponses(
- describeAvailabilityZonesRequest,
- describeAvailabilityZonesResponse,
- HttpRequest.builder().method("POST")
- .endpoint("http://localhost:8773/services/Cloud/")
- .addHeader("Host", "localhost:8773")
- .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
- HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_import_keypair_response.xml")).build()
- ).getKeyPairServices();
-
- KeyPair result = client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA");
- assertEquals(result.getKeyName(), "aplowe-nova-ec22");
- assertEquals(result.getSha1OfPrivateKey(), "e3:fd:de:f6:4c:36:7d:9b:8f:2f:4c:20:f8:ae:b0:ea");
- }
-
- @Test(expectedExceptions = ResourceNotFoundException.class)
- public void testImportKeyPairFailsNotFound() {
- NovaEC2KeyPairClient client = requestsSendResponses(
- describeAvailabilityZonesRequest,
- describeAvailabilityZonesResponse,
- HttpRequest.builder().method("POST")
- .endpoint("http://localhost:8773/services/Cloud/")
- .addHeader("Host", "localhost:8773")
- .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
- HttpResponse.builder().statusCode(404).build()
- ).getKeyPairServices();
-
- client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA");
- }
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testImportKeyPairFailsAlreadyExists() {
- NovaEC2KeyPairClient client = requestsSendResponses(
- describeAvailabilityZonesRequest,
- describeAvailabilityZonesResponse,
- HttpRequest.builder().method("POST")
- .endpoint("http://localhost:8773/services/Cloud/")
- .addHeader("Host", "localhost:8773")
- .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
- HttpResponse.builder().statusCode(409).build()
- ).getKeyPairServices();
-
- client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java
deleted file mode 100644
index 85aa0c5..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java
+++ /dev/null
@@ -1,134 +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.openstack.nova.ec2.services;
-
-import static com.google.common.collect.Sets.newTreeSet;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-
-import org.jclouds.compute.ComputeTestUtils;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.openstack.nova.ec2.NovaEC2ApiMetadata;
-import org.jclouds.ssh.SshKeys;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code NovaKeyPairClient}
- *
- * @author Adam Lowe
- */
-@Test(groups = "live", singleThreaded = true)
-public class NovaEC2KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest {
-
- public static final String PREFIX = System.getProperty("user.name") + "-nova-ec2";
-
- public NovaEC2KeyPairClientLiveTest() {
- provider = "openstack-nova-ec2";
- }
-
- private NovaEC2KeyPairClient client;
- private Set<String> regions;
-
- @Override
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- client = view.unwrap(NovaEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices();
- regions = view.unwrap(NovaEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet();
- }
-
- @Test
- void testDescribeKeyPairs() {
- for (String region : regions) {
- SortedSet<KeyPair> allResults = newTreeSet(client.describeKeyPairsInRegion(region));
- assertNotNull(allResults);
- if (allResults.size() >= 1) {
- KeyPair pair = allResults.last();
- SortedSet<KeyPair> result = newTreeSet(client.describeKeyPairsInRegion(region, pair.getKeyName()));
- assertNotNull(result);
- KeyPair compare = result.last();
- assertEquals(compare, pair);
- }
- }
- }
-
- @Test
- void testCreateKeyPair() {
- String keyName = PREFIX + "1";
- cleanupKeyPair(keyName);
- try {
- KeyPair keyPair = client.createKeyPairInRegion(null, keyName);
- checkKeyPair(keyName, keyPair);
- assertNotNull(keyPair.getKeyMaterial());
- } finally {
- cleanupKeyPair(keyName);
- }
- }
-
- protected void cleanupKeyPair(String keyName) {
- try {
- client.deleteKeyPairInRegion(null, keyName);
- } catch (Exception e) {
-
- }
- client.deleteKeyPairInRegion(null, keyName);
- }
-
- @Test
- void testImportKeyPair() throws IOException {
- String keyName = PREFIX + "2";
- cleanupKeyPair(keyName);
- Map<String, String> myKey = ComputeTestUtils.setupKeyPair();
- try {
- KeyPair keyPair = client.importKeyPairInRegion(null, keyName, myKey.get("public"));
- checkKeyPair(keyName, keyPair);
-
- // check the fingerprint of public key (in the sha10OfPrivateKey field)
- assertEquals(keyPair.getSha1OfPrivateKey(), SshKeys.fingerprintPublicKey(myKey.get("public")));
-
- // try again to see if there's an error
- try {
- client.importKeyPairInRegion(null, keyName, myKey.get("public"));
- fail("Duplicate call importKeyPairInRegion should have failed!");
- } catch (IllegalStateException e) {
- }
- } finally {
- cleanupKeyPair(keyName);
- }
- }
-
- protected void checkKeyPair(String keyName, KeyPair keyPair) {
- assertNotNull(keyPair);
- assertNotNull(keyPair.getSha1OfPrivateKey());
- assertEquals(keyPair.getKeyName(), keyName);
-
- Set<KeyPair> twoResults = client.describeKeyPairsInRegion(null, keyName);
- assertNotNull(twoResults);
- assertEquals(twoResults.size(), 1);
- KeyPair listPair = twoResults.iterator().next();
- assertEquals(listPair.getKeyName(), keyPair.getKeyName());
- assertEquals(listPair.getSha1OfPrivateKey(), keyPair.getSha1OfPrivateKey());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java
deleted file mode 100644
index 4c3dced..0000000
--- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java
+++ /dev/null
@@ -1,32 +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.openstack.nova.ec2.services;
-
-import org.jclouds.ec2.services.SecurityGroupClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "NovaEC2SecurityGroupClientLiveTest")
-public class NovaEC2SecurityGroupClientLiveTest extends SecurityGroupClientLiveTest {
- public NovaEC2SecurityGroupClientLiveTest() {
- provider = "openstack-nova-ec2";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
new file mode 100644
index 0000000..ad6e536
--- /dev/null
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2;
+
+import org.jclouds.aws.ec2.features.AWSAMIApi;
+import org.jclouds.aws.ec2.features.AWSInstanceApi;
+import org.jclouds.aws.ec2.features.AWSKeyPairApi;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.aws.ec2.features.MonitoringApi;
+import org.jclouds.aws.ec2.features.PlacementGroupApi;
+import org.jclouds.aws.ec2.features.SpotInstanceApi;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.Region;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+
+/**
+ * Provides synchronous access to EC2 services.
+ *
+ * @author Adrian Cole
+ */
+public interface AWSEC2Api extends EC2Api {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Delegate
+ @Override
+ Optional<? extends AWSInstanceApi> getInstanceApi();
+
+ @Delegate
+ @Override
+ Optional<? extends AWSInstanceApi> getInstanceApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Delegate
+ @Override
+ Optional<? extends AWSSecurityGroupApi> getSecurityGroupApi();
+
+ @Delegate
+ @Override
+ Optional<? extends AWSSecurityGroupApi> getSecurityGroupApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Delegate
+ @Override
+ Optional<? extends AWSAMIApi> getAMIApi();
+
+ @Delegate
+ @Override
+ Optional<? extends AWSAMIApi> getAMIApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+
+ /**
+ * Provides synchronous access to PlacementGroup services.
+ */
+ @Delegate
+ Optional<? extends PlacementGroupApi> getPlacementGroupApi();
+
+ @Delegate
+ Optional<? extends PlacementGroupApi> getPlacementGroupApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+ /**
+ * Provides synchronous access to Monitoring services.
+ */
+ @Delegate
+ Optional<? extends MonitoringApi> getMonitoringApi();
+
+ @Delegate
+ Optional<? extends MonitoringApi> getMonitoringApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Delegate
+ @Override
+ Optional<? extends AWSKeyPairApi> getKeyPairApi();
+
+ @Delegate
+ @Override
+ Optional<? extends AWSKeyPairApi> getKeyPairApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+
+ /**
+ * Provides synchronous access to SpotInstance services.
+ */
+ @Delegate
+ Optional<? extends SpotInstanceApi> getSpotInstanceApi();
+
+ @Delegate
+ Optional<? extends SpotInstanceApi> getSpotInstanceApiForRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
index 4427fdd..1724331 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java
@@ -23,7 +23,7 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext;
import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule;
-import org.jclouds.aws.ec2.config.AWSEC2RestClientModule;
+import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
@@ -38,15 +38,6 @@ import com.google.inject.Module;
*/
public class AWSEC2ApiMetadata extends EC2ApiMetadata {
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(AWSEC2Client.class)} as
- * {@link AWSEC2AsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<AWSEC2Client, AWSEC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<AWSEC2Client, AWSEC2AsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -73,14 +64,12 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata {
public static class Builder extends EC2ApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder(){
- super(AWSEC2Client.class, AWSEC2AsyncClient.class);
id("aws-ec2")
.version("2012-06-01")
.name("Amazon-specific EC2 API")
.view(AWSEC2ComputeServiceContext.class)
- .context(CONTEXT_TOKEN)
.defaultProperties(AWSEC2ApiMetadata.defaultProperties())
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(AWSEC2RestClientModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class));
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(AWSEC2HttpApiModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java
deleted file mode 100644
index 2d638b0..0000000
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.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.aws.ec2;
-
-import org.jclouds.aws.ec2.services.AWSAMIAsyncClient;
-import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient;
-import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient;
-import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient;
-import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
-import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient;
-import org.jclouds.aws.ec2.services.SpotInstanceAsyncClient;
-import org.jclouds.ec2.EC2AsyncClient;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * Provides asynchronous access to EC2 services.
- *
- * @author Adrian Cole
- *
- * @deprecated please use
- * {@code org.jclouds.ContextBuilder#buildApi(AWSEC2Client.class)}
- * as {@link AWSEC2AsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public interface AWSEC2AsyncClient extends EC2AsyncClient {
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSInstanceAsyncClient getInstanceServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSAMIAsyncClient getAMIServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSSecurityGroupAsyncClient getSecurityGroupServices();
-
- /**
- * Provides asynchronous access to PlacementGroup services.
- */
- @Delegate
- PlacementGroupAsyncClient getPlacementGroupServices();
-
- /**
- * Provides asynchronous access to Monitoring services.
- */
- @Delegate
- MonitoringAsyncClient getMonitoringServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSKeyPairAsyncClient getKeyPairServices();
-
- /**
- * Provides asynchronous access to SpotInstance services.
- */
- @Delegate
- SpotInstanceAsyncClient getSpotInstanceServices();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java
deleted file mode 100644
index a605e3c..0000000
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java
+++ /dev/null
@@ -1,81 +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.aws.ec2;
-
-import org.jclouds.aws.ec2.services.AWSAMIClient;
-import org.jclouds.aws.ec2.services.AWSInstanceClient;
-import org.jclouds.aws.ec2.services.AWSKeyPairClient;
-import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
-import org.jclouds.aws.ec2.services.MonitoringClient;
-import org.jclouds.aws.ec2.services.PlacementGroupClient;
-import org.jclouds.aws.ec2.services.SpotInstanceClient;
-import org.jclouds.ec2.EC2Client;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * Provides synchronous access to EC2 services.
- *
- * @author Adrian Cole
- */
-public interface AWSEC2Client extends EC2Client {
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSInstanceClient getInstanceServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSSecurityGroupClient getSecurityGroupServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSAMIClient getAMIServices();
-
- /**
- * Provides synchronous access to PlacementGroup services.
- */
- @Delegate
- PlacementGroupClient getPlacementGroupServices();
-
- /**
- * Provides synchronous access to Monitoring services.
- */
- @Delegate
- MonitoringClient getMonitoringServices();
-
- /**
- * {@inheritDoc}
- */
- @Delegate
- @Override
- AWSKeyPairClient getKeyPairServices();
-
- /**
- * Provides synchronous access to SpotInstance services.
- */
- @Delegate
- SpotInstanceClient getSpotInstanceServices();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
index 8bcc4d5..f512074 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java
@@ -35,7 +35,7 @@ import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.Constants;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.ec2.domain.PlacementGroup;
import org.jclouds.aws.ec2.domain.PlacementGroup.State;
import org.jclouds.collect.Memoized;
@@ -82,7 +82,7 @@ public class AWSEC2ComputeService extends EC2ComputeService {
private final LoadingCache<RegionAndName, String> placementGroupMap;
private final Predicate<PlacementGroup> placementGroupDeleted;
- private final AWSEC2Client client;
+ private final AWSEC2Api client;
@Inject
protected AWSEC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
@@ -99,7 +99,7 @@ public class AWSEC2ComputeService extends EC2ComputeService {
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
- @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Client client,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Api client,
ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
@Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
@Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
@@ -125,10 +125,10 @@ public class AWSEC2ComputeService extends EC2ComputeService {
// http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using_cluster_computing.html
String placementGroup = String.format("jclouds#%s#%s", group, region);
try {
- if (client.getPlacementGroupServices().describePlacementGroupsInRegion(region, placementGroup).size() > 0) {
+ if (client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region, placementGroup).size() > 0) {
logger.debug(">> deleting placementGroup(%s)", placementGroup);
try {
- client.getPlacementGroupServices().deletePlacementGroupInRegion(region, placementGroup);
+ client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, placementGroup);
checkState(placementGroupDeleted.apply(new PlacementGroup(region, placementGroup, "cluster",
State.PENDING)), String.format("placementGroup region(%s) name(%s) failed to delete", region,
placementGroup));
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
index c0e21f0..ef12576 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
@@ -35,7 +35,7 @@ import javax.inject.Named;
import javax.inject.Provider;
import org.jclouds.Constants;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.util.AWSUtils;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.SecurityGroup;
@@ -72,10 +72,10 @@ import com.google.common.util.concurrent.UncheckedTimeoutException;
* @author Andrew Bayer
*/
public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
- protected final AWSEC2Client client;
+ protected final AWSEC2Api client;
@Inject
- public AWSEC2SecurityGroupExtension(AWSEC2Client client,
+ public AWSEC2SecurityGroupExtension(AWSEC2Api client,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
@Region Supplier<Set<String>> regions,
Function<org.jclouds.ec2.domain.SecurityGroup, SecurityGroup> groupConverter,
@@ -93,7 +93,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
String name = group.getName();
- client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name, ipPermission);
+ client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, name, ipPermission);
return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode());
}
@@ -126,7 +126,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
}
}
- client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name, builder.build());
+ client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, name, builder.build());
return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode());
}
@@ -136,7 +136,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
String name = group.getName();
- client.getSecurityGroupServices().revokeSecurityGroupIngressInRegion(region, name, ipPermission);
+ client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, name, ipPermission);
return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode());
}
@@ -170,7 +170,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
}
}
- client.getSecurityGroupServices().revokeSecurityGroupIngressInRegion(region, name, builder.build());
+ client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, name, builder.build());
return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode());
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
index ee04c14..24b3a8a 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java
@@ -33,7 +33,7 @@ import java.util.Set;
import javax.inject.Singleton;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
@@ -56,11 +56,11 @@ import com.google.inject.Inject;
@Singleton
public class PresentSpotRequestsAndInstances extends PresentInstances {
- private final AWSEC2Client client;
+ private final AWSEC2Api client;
private final Function<SpotInstanceRequest, AWSRunningInstance> spotConverter;
@Inject
- public PresentSpotRequestsAndInstances(AWSEC2Client client, Function<SpotInstanceRequest, AWSRunningInstance> spotConverter) {
+ public PresentSpotRequestsAndInstances(AWSEC2Api client, Function<SpotInstanceRequest, AWSRunningInstance> spotConverter) {
super(client);
this.client = checkNotNull(client, "client");
this.spotConverter = checkNotNull(spotConverter, "spotConverter");
@@ -83,7 +83,7 @@ public class PresentSpotRequestsAndInstances extends PresentInstances {
Collection<String> spotIds = entry.getValue();
logger.trace("looking for spots %s in region %s", spotIds, region);
builder.addAll(transform(
- client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(region,
+ client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(region,
toArray(spotIds, String.class)), spotConverter));
}
return builder.build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
index 6676ef6..c794fdb 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
@@ -27,8 +27,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.aws.ec2.AWSEC2Client;
-import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.ec2.compute.domain.RegionAndName;
import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
@@ -52,18 +52,18 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader<RegionAndName
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
- protected final AWSSecurityGroupClient securityClient;
+ protected final AWSSecurityGroupApi securityApi;
protected final Predicate<RegionAndName> securityGroupEventualConsistencyDelay;
@Inject
- public AWSEC2CreateSecurityGroupIfNeeded(AWSEC2Client ec2Client,
+ public AWSEC2CreateSecurityGroupIfNeeded(AWSEC2Api ec2Api,
@Named("SECURITY") Predicate<RegionAndName> securityGroupEventualConsistencyDelay) {
- this(checkNotNull(ec2Client, "ec2Client").getSecurityGroupServices(), securityGroupEventualConsistencyDelay);
+ this(checkNotNull(ec2Api, "ec2Api").getSecurityGroupApi().get(), securityGroupEventualConsistencyDelay);
}
- public AWSEC2CreateSecurityGroupIfNeeded(AWSSecurityGroupClient securityClient,
+ public AWSEC2CreateSecurityGroupIfNeeded(AWSSecurityGroupApi securityApi,
@Named("SECURITY") Predicate<RegionAndName> securityGroupEventualConsistencyDelay) {
- this.securityClient = checkNotNull(securityClient, "securityClient");
+ this.securityApi = checkNotNull(securityApi, "securityApi");
this.securityGroupEventualConsistencyDelay = checkNotNull(securityGroupEventualConsistencyDelay,
"securityGroupEventualConsistencyDelay");
}
@@ -80,7 +80,7 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader<RegionAndName
checkNotNull(name, "name");
logger.debug(">> creating securityGroup region(%s) name(%s)", region, name);
try {
- securityClient.createSecurityGroupInRegion(region, name, name);
+ securityApi.createSecurityGroupInRegion(region, name, name);
boolean created = securityGroupEventualConsistencyDelay.apply(new RegionAndName(region, name));
if (!created)
throw new RuntimeException(String.format("security group %s/%s is not available after creating", region,
@@ -99,7 +99,7 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader<RegionAndName
.build());
}
- String myOwnerId = Iterables.get(securityClient.describeSecurityGroupsInRegion(region, name), 0).getOwnerId();
+ String myOwnerId = Iterables.get(securityApi.describeSecurityGroupsInRegion(region, name), 0).getOwnerId();
permissions.add(IpPermission.builder()
.fromPort(0)
.toPort(65535)
@@ -118,7 +118,7 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader<RegionAndName
if (perms.size() > 0) {
logger.debug(">> authorizing securityGroup region(%s) name(%s) IpPermissions(%s)", region, name, perms);
- securityClient.authorizeSecurityGroupIngressInRegion(region, name, perms);
+ securityApi.authorizeSecurityGroupIngressInRegion(region, name, perms);
logger.debug("<< authorized securityGroup(%s)", name);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
index b9c205f..5faaba6 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java
@@ -29,7 +29,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
import org.jclouds.aws.ec2.compute.functions.PresentSpotRequestsAndInstances;
import org.jclouds.aws.ec2.domain.LaunchSpecification;
@@ -68,12 +68,12 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT
private Logger logger = Logger.NULL;
@VisibleForTesting
- private final AWSEC2Client client;
+ private final AWSEC2Api client;
private final SpotInstanceRequestToAWSRunningInstance spotConverter;
@Inject
protected AWSEC2CreateNodesInGroupThenAddToSet(
- AWSEC2Client client,
+ AWSEC2Api client,
@Named("ELASTICIP") LoadingCache<RegionAndName, String> elasticIpCache,
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
@Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
@@ -103,7 +103,7 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT
if (logger.isDebugEnabled())
logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region,
spotPrice, spec, options);
- return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceServices()
+ return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceApi().get()
.requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter));
}
return super.createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
index 84efca0..ee7b03b 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java
@@ -26,7 +26,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.ec2.compute.domain.RegionAndName;
@@ -42,11 +42,11 @@ import com.google.common.collect.Iterables;
@Singleton
public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy {
- protected final AWSEC2Client client;
+ protected final AWSEC2Api client;
protected final Map<String, Credentials> credentialStore;
@Inject
- protected AWSEC2DestroyNodeStrategy(AWSEC2Client client, GetNodeMetadataStrategy getNode,
+ protected AWSEC2DestroyNodeStrategy(AWSEC2Api client, GetNodeMetadataStrategy getNode,
@Named("ELASTICIP") LoadingCache<RegionAndName, String> elasticIpCache,
Map<String, Credentials> credentialStore) {
super(client, getNode, elasticIpCache);
@@ -60,14 +60,14 @@ public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy {
if (id.indexOf("sir-") != 0) {
try {
spotId = getOnlyElement(
- Iterables.concat(client.getInstanceServices().describeInstancesInRegion(region, id)))
+ Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, id)))
.getSpotInstanceRequestId();
credentialStore.remove("node#" + region + "/" + spotId);
} catch (NoSuchElementException e) {
}
super.destroyInstanceInRegion(id, region);
} else {
- client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(region, spotId);
+ client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, spotId);
credentialStore.remove("node#" + region + "/" + id);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
index b442576..ffc2e0b 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java
@@ -22,7 +22,7 @@ import static com.google.common.collect.Iterables.getOnlyElement;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
import org.jclouds.compute.domain.NodeMetadata;
@@ -38,11 +38,11 @@ import com.google.common.base.Function;
@Singleton
public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy {
- private final AWSEC2Client client;
+ private final AWSEC2Api client;
private final SpotInstanceRequestToAWSRunningInstance spotConverter;
@Inject
- protected AWSEC2GetNodeMetadataStrategy(AWSEC2Client client,
+ protected AWSEC2GetNodeMetadataStrategy(AWSEC2Api client,
Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
SpotInstanceRequestToAWSRunningInstance spotConverter) {
super(client, runningInstanceToNodeMetadata);
@@ -54,7 +54,7 @@ public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy {
public RunningInstance getRunningInstanceInRegion(String region, String id) {
if (id.indexOf("sir-") != 0)
return super.getRunningInstanceInRegion(region, id);
- SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
+ SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
region, id));
if (spot.getState() == SpotInstanceRequest.State.ACTIVE)
return super.getRunningInstanceInRegion(region, spot.getInstanceId());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
index 35d193e..0d3b034 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java
@@ -31,7 +31,7 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
-import org.jclouds.aws.ec2.AWSEC2Client;
+import org.jclouds.aws.ec2.AWSEC2Api;
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
@@ -55,11 +55,11 @@ import com.google.inject.Inject;
@Singleton
public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
- protected final AWSEC2Client client;
+ protected final AWSEC2Api client;
protected final SpotInstanceRequestToAWSRunningInstance spotConverter;
@Inject
- protected AWSEC2ListNodesStrategy(AWSEC2Client client, @Region Supplier<Set<String>> regions,
+ protected AWSEC2ListNodesStrategy(AWSEC2Api client, @Region Supplier<Set<String>> regions,
Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
SpotInstanceRequestToAWSRunningInstance spotConverter) {
@@ -92,7 +92,7 @@ public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
@Override
public Set<SpotInstanceRequest> apply(String from) {
- return client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(from);
+ return client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(from);
}
};
}
@@ -102,7 +102,7 @@ public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
@Override
public Set<SpotInstanceRequest> apply(String from) {
- return client.getSpotInstanceServices()
+ return client.getSpotInstanceApi().get()
.describeSpotInstanceRequestsInRegion(from, toArray(idsByRegions.get(from), String.class));
}
};
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
new file mode 100644
index 0000000..db1f8d2
--- /dev/null
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.config;
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.util.Map;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
+import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
+import org.jclouds.aws.ec2.features.AWSAMIApi;
+import org.jclouds.aws.ec2.features.AWSInstanceApi;
+import org.jclouds.aws.ec2.features.AWSKeyPairApi;
+import org.jclouds.aws.ec2.features.AWSSecurityGroupApi;
+import org.jclouds.aws.ec2.features.MonitoringApi;
+import org.jclouds.aws.ec2.features.PlacementGroupApi;
+import org.jclouds.aws.ec2.features.SpotInstanceApi;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.config.BaseEC2HttpApiModule;
+import org.jclouds.ec2.features.SubnetApi;
+import org.jclouds.ec2.features.TagApi;
+import org.jclouds.ec2.features.WindowsApi;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.ec2.features.AMIApi;
+import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi;
+import org.jclouds.ec2.features.ElasticBlockStoreApi;
+import org.jclouds.ec2.features.ElasticIPAddressApi;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.ec2.features.SecurityGroupApi;
+import org.jclouds.rest.ConfiguresHttpApi;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Configures the EC2 connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresHttpApi
+public class AWSEC2HttpApiModule extends BaseEC2HttpApiModule<AWSEC2Api> {
+
+ public AWSEC2HttpApiModule() {
+ super(AWSEC2Api.class);
+ }
+
+ @Singleton
+ @Provides
+ EC2Api provide(AWSEC2Api in) {
+ return in;
+ }
+
+ @Singleton
+ @Provides
+ InstanceApi getInstanceApi(AWSEC2Api in) {
+ return in.getInstanceApi().get();
+ }
+
+ @Singleton
+ @Provides
+ SecurityGroupApi getSecurityGroupApi(AWSEC2Api in) {
+ return in.getSecurityGroupApi().get();
+ }
+
+ @Singleton
+ @Provides
+ AMIApi getAMIApi(AWSEC2Api in) {
+ return in.getAMIApi().get();
+ }
+
+ @Override
+ protected void configure() {
+ bind(RunInstancesOptions.class).to(AWSRunInstancesOptions.class);
+ bind(new TypeLiteral<Function<SpotInstanceRequest, AWSRunningInstance>>() {
+ }).to(SpotInstanceRequestToAWSRunningInstance.class);
+ super.configure();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java
deleted file mode 100644
index 0ebba84..0000000
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java
+++ /dev/null
@@ -1,159 +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.aws.ec2.config;
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.aws.ec2.AWSEC2AsyncClient;
-import org.jclouds.aws.ec2.AWSEC2Client;
-import org.jclouds.aws.ec2.domain.AWSRunningInstance;
-import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
-import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
-import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
-import org.jclouds.aws.ec2.services.AWSAMIAsyncClient;
-import org.jclouds.aws.ec2.services.AWSAMIClient;
-import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient;
-import org.jclouds.aws.ec2.services.AWSInstanceClient;
-import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient;
-import org.jclouds.aws.ec2.services.AWSKeyPairClient;
-import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient;
-import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
-import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
-import org.jclouds.aws.ec2.services.MonitoringClient;
-import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient;
-import org.jclouds.aws.ec2.services.PlacementGroupClient;
-import org.jclouds.aws.ec2.services.SpotInstanceAsyncClient;
-import org.jclouds.aws.ec2.services.SpotInstanceClient;
-import org.jclouds.ec2.EC2AsyncClient;
-import org.jclouds.ec2.EC2Client;
-import org.jclouds.ec2.config.EC2RestClientModule;
-import org.jclouds.ec2.features.SubnetApi;
-import org.jclouds.ec2.features.SubnetAsyncApi;
-import org.jclouds.ec2.features.TagApi;
-import org.jclouds.ec2.features.TagAsyncApi;
-import org.jclouds.ec2.features.WindowsApi;
-import org.jclouds.ec2.features.WindowsAsyncApi;
-import org.jclouds.ec2.options.RunInstancesOptions;
-import org.jclouds.ec2.services.AMIAsyncClient;
-import org.jclouds.ec2.services.AMIClient;
-import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient;
-import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient;
-import org.jclouds.ec2.services.ElasticBlockStoreAsyncClient;
-import org.jclouds.ec2.services.ElasticBlockStoreClient;
-import org.jclouds.ec2.services.ElasticIPAddressAsyncClient;
-import org.jclouds.ec2.services.ElasticIPAddressClient;
-import org.jclouds.ec2.services.InstanceAsyncClient;
-import org.jclouds.ec2.services.InstanceClient;
-import org.jclouds.ec2.services.SecurityGroupAsyncClient;
-import org.jclouds.ec2.services.SecurityGroupClient;
-import org.jclouds.ec2.services.WindowsAsyncClient;
-import org.jclouds.ec2.services.WindowsClient;
-import org.jclouds.rest.ConfiguresRestClient;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-
-/**
- * Configures the EC2 connection.
- *
- * @author Adrian Cole
- */
-@ConfiguresRestClient
-public class AWSEC2RestClientModule extends EC2RestClientModule<AWSEC2Client, AWSEC2AsyncClient> {
-
- public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
- .put(AWSAMIClient.class, AWSAMIAsyncClient.class)//
- .put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
- .put(AWSInstanceClient.class, AWSInstanceAsyncClient.class)//
- .put(AWSKeyPairClient.class, AWSKeyPairAsyncClient.class)//
- .put(AWSSecurityGroupClient.class, AWSSecurityGroupAsyncClient.class)//
- .put(PlacementGroupClient.class, PlacementGroupAsyncClient.class)//
- .put(MonitoringClient.class, MonitoringAsyncClient.class)//
- .put(WindowsClient.class, WindowsAsyncClient.class)//
- .put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
- .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
- .put(SpotInstanceClient.class, SpotInstanceAsyncClient.class)//
- .put(WindowsApi.class, WindowsAsyncApi.class)//
- .put(TagApi.class, TagAsyncApi.class)//
- .put(SubnetApi.class, SubnetAsyncApi.class)//
- .build();
-
- public AWSEC2RestClientModule() {
- super(typeToken(AWSEC2Client.class), typeToken(AWSEC2AsyncClient.class), DELEGATE_MAP);
- }
-
- @Singleton
- @Provides
- EC2Client provide(AWSEC2Client in) {
- return in;
- }
-
- @Singleton
- @Provides
- EC2AsyncClient provide(AWSEC2AsyncClient in) {
- return in;
- }
-
- @Singleton
- @Provides
- InstanceClient getInstanceServices(AWSEC2Client in) {
- return in.getInstanceServices();
- }
-
- @Singleton
- @Provides
- InstanceAsyncClient getInstanceServices(AWSEC2AsyncClient in) {
- return in.getInstanceServices();
- }
-
- @Singleton
- @Provides
- SecurityGroupClient getSecurityGroupServices(AWSEC2Client in) {
- return in.getSecurityGroupServices();
- }
-
- @Singleton
- @Provides
- SecurityGroupAsyncClient getSecurityGroupServices(AWSEC2AsyncClient in) {
- return in.getSecurityGroupServices();
- }
-
- @Singleton
- @Provides
- AMIClient getAMIServices(AWSEC2Client in) {
- return in.getAMIServices();
- }
-
- @Singleton
- @Provides
- AMIAsyncClient getAMIServices(AWSEC2AsyncClient in) {
- return in.getAMIServices();
- }
-
- @Override
- protected void configure() {
- bind(RunInstancesOptions.class).to(AWSRunInstancesOptions.class);
- bind(new TypeLiteral<Function<SpotInstanceRequest, AWSRunningInstance>>() {
- }).to(SpotInstanceRequestToAWSRunningInstance.class);
- super.configure();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
new file mode 100644
index 0000000..92eb3b0
--- /dev/null
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.aws.ec2.xml.ProductCodesHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindProductCodesToIndexedFormParams;
+import org.jclouds.ec2.features.AMIApi;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * Provides access to AMI Services.
+ * <p/>
+ *
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSAMIApi extends AMIApi {
+ // TODO make AWSImage as it has product codes...
+
+ /**
+ * Returns the Product Codes of an image.
+ *
+ * @param region
+ * AMIs are tied to the Region where its files are located within Amazon S3.
+ * @param imageId
+ * The ID of the AMI for which an attribute will be described
+ * @see #describeImages
+ * @see #modifyImageAttribute
+ * @see #resetImageAttribute
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImageAttribute.html"
+ * />
+ * @see DescribeImagesOptions
+ */
+ @Named("DescribeImageAttribute")
+ @POST
+ @Path("/")
+ @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
+ @XMLResponseParser(ProductCodesHandler.class)
+ Set<String> getProductCodesForImageInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @FormParam("ImageId") String imageId);
+
+ /**
+ * Adds {@code productCode}s to an AMI.
+ *
+ * @param region
+ * AMIs are tied to the Region where its files are located within Amazon S3.
+ * @param productCodes
+ * Product Codes
+ * @param imageId
+ * The AMI ID.
+ *
+ * @see #removeProductCodesFromImage
+ * @see #describeImageAttribute
+ * @see #resetImageAttribute
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
+ * />
+ */
+ @Named("ModifyImageAttribute")
+ @POST
+ @Path("/")
+ @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "add",
+ "productCodes" })
+ void addProductCodesToImageInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
+ @FormParam("ImageId") String imageId);
+
+ /**
+ * Removes {@code productCode}s from an AMI.
+ *
+ * @param region
+ * AMIs are tied to the Region where its files are located within Amazon S3.
+ * @param productCodes
+ * Product Codes
+ * @param imageId
+ * The AMI ID.
+ *
+ * @see #addProductCodesToImage
+ * @see #describeImageAttribute
+ * @see #resetImageAttribute
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
+ * />
+ */
+ @Named("ModifyImageAttribute")
+ @POST
+ @Path("/")
+ @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "remove",
+ "productCodes" })
+ void removeProductCodesFromImageInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
+ @FormParam("ImageId") String imageId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
new file mode 100644
index 0000000..5a26707
--- /dev/null
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
+import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams;
+import org.jclouds.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.options.RunInstancesOptions;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * Provides access to EC2 Instance Services via their REST API.
+ * <p/>
+ *
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSInstanceApi extends InstanceApi {
+
+ @Named("DescribeInstances")
+ @Override
+ @POST
+ @Path("/")
+ @FormParams(keys = ACTION, values = "DescribeInstances")
+ @XMLResponseParser(AWSDescribeInstancesResponseHandler.class)
+ @Fallback(EmptySetOnNotFoundOr404.class)
+ Set<? extends Reservation<? extends AWSRunningInstance>> describeInstancesInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
+
+ @Named("RunInstances")
+ @Override
+ @POST
+ @Path("/")
+ @FormParams(keys = ACTION, values = "RunInstances")
+ @XMLResponseParser(AWSRunInstancesResponseHandler.class)
+ Reservation<? extends AWSRunningInstance> runInstancesInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone,
+ @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount,
+ @FormParam("MaxCount") int maxCount, RunInstancesOptions... options);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/5f3b8d3f/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
new file mode 100644
index 0000000..5813dce
--- /dev/null
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.aws.ec2.features;
+
+import static org.jclouds.aws.reference.FormParameters.ACTION;
+
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64;
+import org.jclouds.ec2.features.KeyPairApi;
+import org.jclouds.ec2.xml.KeyPairResponseHandler;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * @author Adrian Cole
+ */
+@RequestFilters(FormSigner.class)
+@VirtualHost
+public interface AWSKeyPairApi extends KeyPairApi {
+
+ /**
+ * Imports the public key from an RSA key pair that you created with a third-party tool. Compare
+ * this with CreateKeyPair, in which AWS creates the key pair and gives the keys to you (AWS
+ * keeps a copy of the public key). With ImportKeyPair, you create the key pair and give AWS just
+ * the public key. The private key is never transferred between you and AWS.
+ *
+ * <p/>
+ * You can easily create an RSA key pair on Windows and Linux using the ssh-keygen command line
+ * tool (provided with the standard OpenSSH installation). Standard library support for RSA key
+ * pair creation is also available in Java, Ruby, Python, and many other programming languages.
+ *
+ * <p/>
+ * <h4>Supported Formats</h4>
+ * <ul>
+ * <li>OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys)</li>
+ * <li>Base64 encoded DER format</li>
+ * <li>SSH public key file format as specified in RFC4716</li>
+ * </ul>
+ * DSA keys are not supported. Make sure your key generator is set up to create RSA keys.
+ * <p/>
+ * Supported lengths: 1024, 2048, and 4096.
+ * <p/>
+ *
+ * @param region
+ * region to import the key into
+ * @param keyName
+ * A unique name for the key pair. Accepts alphanumeric characters, spaces, dashes, and
+ * underscores.
+ * @param publicKeyMaterial
+ * The public key
+ * @return imported key including fingerprint
+ */
+ @Named("ImportKeyPair")
+ @POST
+ @Path("/")
+ @FormParams(keys = ACTION, values = "ImportKeyPair")
+ @XMLResponseParser(KeyPairResponseHandler.class)
+ KeyPair importKeyPairInRegion(
+ @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
+ @FormParam("KeyName") String keyName,
+ @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial);
+}