You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/11/02 12:43:17 UTC
[1/5] jclouds-labs git commit: Remove DigitalOcean v1
Repository: jclouds-labs
Updated Branches:
refs/heads/master ca240899f -> 114b35289
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/predicates/SameFingerprintTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/predicates/SameFingerprintTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/predicates/SameFingerprintTest.java
deleted file mode 100644
index be204a6..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/predicates/SameFingerprintTest.java
+++ /dev/null
@@ -1,72 +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.digitalocean.predicates;
-
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
-
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.ssh.DSAKeys;
-import org.jclouds.ssh.SshKeys;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link SameFingerprint} class.
- */
-@Test(groups = "unit", testName = "SameFingerprintTest")
-public class SameFingerprintTest {
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "key cannot be null")
- public void testPublicKeyCannotBeNull() {
- new SameFingerprint(null);
- }
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "public key cannot be null")
- public void testPublicKeyInSshKeyCannotBeNull() throws IOException, InvalidKeySpecException,
- NoSuchAlgorithmException {
- String rsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- PublicKey key = KeyFactory.getInstance("RSA").generatePublic(SshKeys.publicKeySpecFromOpenSSH(rsa));
-
- SameFingerprint predicate = new SameFingerprint(key);
- predicate.apply(new SshKey(0, "foo", null));
- }
-
- @Test
- public void testSameFingerPrintRSA() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
- String rsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- PublicKey key = KeyFactory.getInstance("RSA").generatePublic(SshKeys.publicKeySpecFromOpenSSH(rsa));
-
- SameFingerprint predicate = new SameFingerprint(key);
- assertTrue(predicate.apply(new SshKey(0, "foo", key)));
- }
-
- @Test
- public void testSameFingerPrintDSA() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
- String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
- PublicKey key = KeyFactory.getInstance("DSA").generatePublic(DSAKeys.publicKeySpecFromOpenSSH(dsa));
-
- SameFingerprint predicate = new SameFingerprint(key);
- assertTrue(predicate.apply(new SshKey(0, "foo", key)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/ssh/DSAKeysTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/ssh/DSAKeysTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/ssh/DSAKeysTest.java
deleted file mode 100644
index da93ad3..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/ssh/DSAKeysTest.java
+++ /dev/null
@@ -1,54 +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.digitalocean.ssh;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.interfaces.DSAPublicKey;
-import java.security.spec.DSAPublicKeySpec;
-import java.security.spec.InvalidKeySpecException;
-
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link DSAKeys} class.
- */
-@Test(groups = "unit", testName = "DSAKeysTest")
-public class DSAKeysTest {
-
- private static final String expectedFingerPrint = "2a:54:bb:8e:ba:44:96:c8:6c:9c:40:34:3c:4d:38:e4";
-
- @Test
- public void testCanReadRsaAndCompareFingerprintOnPublicRSAKey() throws IOException {
- String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
- String fingerPrint = DSAKeys.fingerprintPublicKey(dsa);
- assertEquals(fingerPrint, expectedFingerPrint);
- }
-
- @Test
- public void testEncodeAsOpenSSH() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
- String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
- DSAPublicKeySpec spec = DSAKeys.publicKeySpecFromOpenSSH(dsa);
- DSAPublicKey key = (DSAPublicKey) KeyFactory.getInstance("DSA").generatePublic(spec);
-
- assertEquals(DSAKeys.encodeAsOpenSSH(key), dsa);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/strategy/ListSshKeysLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/strategy/ListSshKeysLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/strategy/ListSshKeysLiveTest.java
deleted file mode 100644
index 5969377..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/strategy/ListSshKeysLiveTest.java
+++ /dev/null
@@ -1,83 +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.digitalocean.strategy;
-
-import static com.google.common.collect.Iterables.all;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.util.concurrent.MoreExecutors;
-
-/**
- * Live tests for the {@link ListSshKeys} strategy.
- */
-@Test(groups = "live", testName = "ListSshKeysLiveTest")
-public class ListSshKeysLiveTest extends BaseDigitalOceanLiveTest {
-
- private ListSshKeys strategy;
-
- private SshKey rsaKey;
-
- private SshKey dsaKey;
-
- @Override
- protected void initialize() {
- super.initialize();
- strategy = new ListSshKeys(api, MoreExecutors.sameThreadExecutor());
- }
-
- @BeforeClass
- public void setupKeys() throws IOException {
- String rsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
-
- rsaKey = api.getKeyPairApi().create("jclouds-test-rsa", rsa);
- dsaKey = api.getKeyPairApi().create("jclouds-test-dsa", dsa);
- }
-
- @AfterClass(alwaysRun = true)
- public void cleanupKeys() {
- if (rsaKey != null) {
- api.getKeyPairApi().delete(rsaKey.getId());
- }
- if (dsaKey != null) {
- api.getKeyPairApi().delete(dsaKey.getId());
- }
- }
-
- public void testListWithDetails() {
- List<SshKey> keys = strategy.execute();
-
- assertTrue(keys.size() >= 2);
- assertTrue(all(keys, new Predicate<SshKey>() {
- @Override
- public boolean apply(SshKey input) {
- return input.getPublicKey() != null;
- }
- }));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/access-denied.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/access-denied.json b/digitalocean/src/test/resources/access-denied.json
deleted file mode 100644
index 94ff31b..0000000
--- a/digitalocean/src/test/resources/access-denied.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "status":"ERROR",
- "error_message":"Access Denied",
- "message":"Access Denied"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/droplet-creation.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/droplet-creation.json b/digitalocean/src/test/resources/droplet-creation.json
deleted file mode 100644
index a92c0aa..0000000
--- a/digitalocean/src/test/resources/droplet-creation.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "status": "OK",
- "droplet": {
- "id": 100824,
- "name": "test",
- "image_id": 419,
- "size_id": 32,
- "event_id": 7499
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/droplet.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/droplet.json b/digitalocean/src/test/resources/droplet.json
deleted file mode 100644
index 6b4b88d..0000000
--- a/digitalocean/src/test/resources/droplet.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "status": "OK",
- "droplet": {
- "id": 100823,
- "image_id": 420,
- "name": "test222",
- "region_id": 1,
- "size_id": 33,
- "backups_active": false,
- "backups": [],
- "snapshots": [],
- "ip_address": "127.0.0.1",
- "private_ip_address": null,
- "locked": false,
- "status": "active"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/droplets.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/droplets.json b/digitalocean/src/test/resources/droplets.json
deleted file mode 100644
index 516da96..0000000
--- a/digitalocean/src/test/resources/droplets.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "status":"OK",
- "droplets":[
- {
- "id":981645,
- "name":"test",
- "image_id":1505699,
- "size_id":66,
- "region_id":1,
- "backups_active":false,
- "ip_address":"192.241.158.116",
- "private_ip_address":null,
- "locked":false,
- "status":"active",
- "created_at":"2014-01-13T20:53:08Z"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/error.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/error.json b/digitalocean/src/test/resources/error.json
deleted file mode 100644
index 101693c..0000000
--- a/digitalocean/src/test/resources/error.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "status":"ERROR",
- "error_message":"No Image Found",
- "message":"No Image Found"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/event-pending.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/event-pending.json b/digitalocean/src/test/resources/event-pending.json
deleted file mode 100644
index a025b0d..0000000
--- a/digitalocean/src/test/resources/event-pending.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "status": "OK",
- "event": {
- "id": 7499,
- "action_status": null,
- "droplet_id": 100824,
- "event_type_id": 1,
- "percentage": "50"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/event.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/event.json b/digitalocean/src/test/resources/event.json
deleted file mode 100644
index 3947ec3..0000000
--- a/digitalocean/src/test/resources/event.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "status": "OK",
- "event": {
- "id": 7499,
- "action_status": "done",
- "droplet_id": 100824,
- "event_type_id": 1,
- "percentage": "100"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/eventid.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/eventid.json b/digitalocean/src/test/resources/eventid.json
deleted file mode 100644
index 410a3db..0000000
--- a/digitalocean/src/test/resources/eventid.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "status": "OK",
- "event_id": 7499
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/image1.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/image1.json b/digitalocean/src/test/resources/image1.json
deleted file mode 100644
index 780057c..0000000
--- a/digitalocean/src/test/resources/image1.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "status": "OK",
- "image": {
- "id" : 1,
- "name" : "Arch Linux 2013.05 x32",
- "distribution" : "Arch Linux",
- "public" : true,
- "slug" : "arch-linux-x32",
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/image2.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/image2.json b/digitalocean/src/test/resources/image2.json
deleted file mode 100644
index 2d51360..0000000
--- a/digitalocean/src/test/resources/image2.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "status": "OK",
- "image": {
- "id" : 2,
- "name" : "Fedora 17 x64 Desktop",
- "distribution" : "Fedora",
- "public" : true,
- "slug" : "fedora-17-x64",
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/image3.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/image3.json b/digitalocean/src/test/resources/image3.json
deleted file mode 100644
index 9156ba4..0000000
--- a/digitalocean/src/test/resources/image3.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "status": "OK",
- "image": {
- "id" : 3,
- "name" : "Dokku on Ubuntu 13.04 0.2.0rc3",
- "distribution" : "Ubuntu",
- "public" : true,
- "slug" : null,
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/images.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/images.json b/digitalocean/src/test/resources/images.json
deleted file mode 100644
index b4eb1f5..0000000
--- a/digitalocean/src/test/resources/images.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "status":"OK",
- "images":[
- {
- "id":1601,
- "name":"CentOS 5.8 x64",
- "slug":"centos-58-x64",
- "distribution":"CentOS",
- "public":true,
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- },
- {
- "id":1602,
- "name":"CentOS 5.8 x32",
- "slug":"centos-58-x32",
- "distribution":"CentOS",
- "public":true,
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- },
- {
- "id":12573,
- "name":"Debian 6.0 x64",
- "slug":null,
- "distribution":"Debian",
- "public":true,
- "regions": [1, 2, 3],
- "region_slugs": ["nyc1", "ams1", "sfo1"]
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/key.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/key.json b/digitalocean/src/test/resources/key.json
deleted file mode 100644
index e6a463b..0000000
--- a/digitalocean/src/test/resources/key.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "status": "OK",
- "ssh_key": {
- "id": 47,
- "name": "my_key",
- "ssh_pub_key": "ssh-dss AAAAB3NzaC1kc3MAAACBAK5uLwicCrFEpaVKBzkWxC7RQn+smg5ZQb5keh9RQKo8AszFTol5npgUAr0JWmqKIHv7nof0HndO86x9iIqNjq3vrz9CIVcFfZM7poKBJZ27Hv3v0fmSKfAc6eGdx8eM9UkZe1gzcLXK8UP2HaeY1Y4LlaHXS5tPi/dXooFVgiA7AAAAFQCQl6LZo/VYB9VgPEZzOmsmQevnswAAAIBCNKGsVP5eZ+IJklXheUyzyuL75i04OOtEGW6MO5TymKMwTZlU9r4ukuwxty+T9Ot2LqlNRnLSPQUjb0vplasZ8Ix45JOpRbuSvPovryn7rvS7//klu9hIkFAAQ/AZfGTw+696EjFBg4F5tN6MGMA6KrTQVLXeuYcZeRXwE5t5lwAAAIEAl2xYh098bozJUANQ82DiZznjHc5FW76Xm1apEqsZtVRFuh3V9nc7QNcBekhmHp5Z0sHthXCm1XqnFbkRCdFlX02NpgtNs7OcKpaJP47N8C+C/Yrf8qK/Wt3fExrL2ZLX5XD2tiotugSkwZJMW5Bv0mtjrNt0Q7P45rZjNNTag2c= user@host"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/keys.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/keys.json b/digitalocean/src/test/resources/keys.json
deleted file mode 100644
index ecaa322..0000000
--- a/digitalocean/src/test/resources/keys.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "status": "OK",
- "ssh_keys": [
- {
- "id": 47,
- "name": "my_key",
- "ssh_pub_key": "ssh-dss AAAAB3NzaC1kc3MAAACBAK5uLwicCrFEpaVKBzkWxC7RQn+smg5ZQb5keh9RQKo8AszFTol5npgUAr0JWmqKIHv7nof0HndO86x9iIqNjq3vrz9CIVcFfZM7poKBJZ27Hv3v0fmSKfAc6eGdx8eM9UkZe1gzcLXK8UP2HaeY1Y4LlaHXS5tPi/dXooFVgiA7AAAAFQCQl6LZo/VYB9VgPEZzOmsmQevnswAAAIBCNKGsVP5eZ+IJklXheUyzyuL75i04OOtEGW6MO5TymKMwTZlU9r4ukuwxty+T9Ot2LqlNRnLSPQUjb0vplasZ8Ix45JOpRbuSvPovryn7rvS7//klu9hIkFAAQ/AZfGTw+696EjFBg4F5tN6MGMA6KrTQVLXeuYcZeRXwE5t5lwAAAIEAl2xYh098bozJUANQ82DiZznjHc5FW76Xm1apEqsZtVRFuh3V9nc7QNcBekhmHp5Z0sHthXCm1XqnFbkRCdFlX02NpgtNs7OcKpaJP47N8C+C/Yrf8qK/Wt3fExrL2ZLX5XD2tiotugSkwZJMW5Bv0mtjrNt0Q7P45rZjNNTag2c= user@host"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/not-found.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/not-found.json b/digitalocean/src/test/resources/not-found.json
deleted file mode 100644
index e8fa1fc..0000000
--- a/digitalocean/src/test/resources/not-found.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "status":"ERROR",
- "error_message":"Not Found",
- "message":"Not Found"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/regions.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/regions.json b/digitalocean/src/test/resources/regions.json
deleted file mode 100644
index cb2d4aa..0000000
--- a/digitalocean/src/test/resources/regions.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "status":"OK",
- "regions":[
- {
- "id":1,
- "name":"New York 1",
- "slug":"nyc1"
- },
- {
- "id":3,
- "name":"San Francisco 1",
- "slug":"sfo1"
- },
- {
- "id":4,
- "name":"New York 2",
- "slug":"nyc2"
- },
- {
- "id":5,
- "name":"Amsterdam 2",
- "slug":"ams2"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/sizes.json
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/sizes.json b/digitalocean/src/test/resources/sizes.json
deleted file mode 100644
index 5bb2a1f..0000000
--- a/digitalocean/src/test/resources/sizes.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "status":"OK",
- "sizes":[
- {
- "id":66,
- "name":"512MB",
- "slug":"512mb",
- "memory":512,
- "cpu":1,
- "disk":20,
- "cost_per_hour":0.00744,
- "cost_per_month":"5.0"
- },
- {
- "id":63,
- "name":"1GB",
- "slug":"1gb",
- "memory":1024,
- "cpu":1,
- "disk":30,
- "cost_per_hour":0.01488,
- "cost_per_month":"10.0"
- },
- {
- "id":62,
- "name":"2GB",
- "slug":"2gb",
- "memory":2048,
- "cpu":2,
- "disk":40,
- "cost_per_hour":0.02976,
- "cost_per_month":"20.0"
- },
- {
- "id":64,
- "name":"4GB",
- "slug":"4gb",
- "memory":4096,
- "cpu":2,
- "disk":60,
- "cost_per_hour":0.05952,
- "cost_per_month":"40.0"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/ssh-dsa.txt
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/ssh-dsa.txt b/digitalocean/src/test/resources/ssh-dsa.txt
deleted file mode 100644
index 3dc78e4..0000000
--- a/digitalocean/src/test/resources/ssh-dsa.txt
+++ /dev/null
@@ -1 +0,0 @@
-ssh-dss AAAAB3NzaC1kc3MAAACBAK5uLwicCrFEpaVKBzkWxC7RQn+smg5ZQb5keh9RQKo8AszFTol5npgUAr0JWmqKIHv7nof0HndO86x9iIqNjq3vrz9CIVcFfZM7poKBJZ27Hv3v0fmSKfAc6eGdx8eM9UkZe1gzcLXK8UP2HaeY1Y4LlaHXS5tPi/dXooFVgiA7AAAAFQCQl6LZo/VYB9VgPEZzOmsmQevnswAAAIBCNKGsVP5eZ+IJklXheUyzyuL75i04OOtEGW6MO5TymKMwTZlU9r4ukuwxty+T9Ot2LqlNRnLSPQUjb0vplasZ8Ix45JOpRbuSvPovryn7rvS7//klu9hIkFAAQ/AZfGTw+696EjFBg4F5tN6MGMA6KrTQVLXeuYcZeRXwE5t5lwAAAIEAl2xYh098bozJUANQ82DiZznjHc5FW76Xm1apEqsZtVRFuh3V9nc7QNcBekhmHp5Z0sHthXCm1XqnFbkRCdFlX02NpgtNs7OcKpaJP47N8C+C/Yrf8qK/Wt3fExrL2ZLX5XD2tiotugSkwZJMW5Bv0mtjrNt0Q7P45rZjNNTag2c=
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/resources/ssh-rsa.txt
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/resources/ssh-rsa.txt b/digitalocean/src/test/resources/ssh-rsa.txt
deleted file mode 100644
index dd2b930..0000000
--- a/digitalocean/src/test/resources/ssh-rsa.txt
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDH3GRbR2QHnHwCHF+Zj0qmunj+jBATzDeWW4FfMvIphQr1yHzEl+EaGETKB3oWQ7pjmmPwKBPcE3GMKsbQI8PJvae7w9SEaCJ2aNUdRhv18AnEoDemaSDLH6Nyyi001Vk6Xuff17Sfe3UpmM4qaK017A7Qgr6wfwj4txVQwDII3eMvyhSldF+S41ZxOdeMVy45nk0fJoMSgkc50u8ofTuAAS/sFZnxT6caUcvE3hKhwqL48i1yjDjTKiqCwMfsdqavnHMjDVi6xP3trPgSxjqzEJ6fkrNOpkM42uAEdc9nso/C/+whFYFWzdNXPyuBgYcHahQPBpzkJM5o0ZIhf3yp user@host
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6967c2a..5864fc3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,7 +76,6 @@
<module>cloudsigma2-sjc</module>
<module>cloudsigma2-wdc</module>
<module>cloudsigma2-zrh</module>
- <module>digitalocean</module>
<module>digitalocean2</module>
<module>jdbc</module>
<module>joyent-cloudapi</module>
[5/5] jclouds-labs git commit: Remove DigitalOcean v1
Posted by na...@apache.org.
Remove DigitalOcean v1
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/114b3528
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/114b3528
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/114b3528
Branch: refs/heads/master
Commit: 114b35289fbd39f40a036179310cade5d941cc13
Parents: ca24089
Author: Ignasi Barrera <na...@apache.org>
Authored: Fri Oct 30 22:36:02 2015 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Fri Oct 30 22:36:02 2015 +0100
----------------------------------------------------------------------
digitalocean/README.txt | 1 -
digitalocean/pom.xml | 130 ----
.../jclouds/digitalocean/DigitalOceanApi.java | 70 --
.../digitalocean/DigitalOceanApiMetadata.java | 90 ---
.../DigitalOceanProviderMetadata.java | 78 --
...DigitalOceanComputeServiceContextModule.java | 166 ----
.../extensions/DigitalOceanImageExtension.java | 132 ----
.../functions/DropletStatusToStatus.java | 47 --
.../functions/DropletToNodeMetadata.java | 162 ----
.../compute/functions/ImageToImage.java | 66 --
.../compute/functions/RegionToLocation.java | 58 --
.../compute/functions/SizeToHardware.java | 60 --
...plateOptionsToStatementWithoutPublicKey.java | 60 --
.../options/DigitalOceanTemplateOptions.java | 179 -----
.../strategy/CreateKeyPairsThenCreateNodes.java | 205 -----
.../DigitalOceanComputeServiceAdapter.java | 183 -----
.../compute/util/LocationNamingUtils.java | 70 --
.../config/DigitalOceanHttpApiModule.java | 65 --
.../config/DigitalOceanParserModule.java | 141 ----
.../digitalocean/domain/BaseResponse.java | 118 ---
.../digitalocean/domain/Distribution.java | 66 --
.../jclouds/digitalocean/domain/Droplet.java | 250 ------
.../digitalocean/domain/DropletCreation.java | 120 ---
.../org/jclouds/digitalocean/domain/Event.java | 141 ----
.../org/jclouds/digitalocean/domain/Image.java | 160 ----
.../digitalocean/domain/OperatingSystem.java | 135 ----
.../org/jclouds/digitalocean/domain/Region.java | 98 ---
.../org/jclouds/digitalocean/domain/Size.java | 161 ----
.../org/jclouds/digitalocean/domain/SshKey.java | 96 ---
.../domain/options/CreateDropletOptions.java | 161 ----
.../digitalocean/features/DropletApi.java | 327 --------
.../jclouds/digitalocean/features/EventApi.java | 58 --
.../jclouds/digitalocean/features/ImageApi.java | 140 ----
.../digitalocean/features/KeyPairApi.java | 106 ---
.../digitalocean/features/RegionApi.java | 51 --
.../jclouds/digitalocean/features/SizesApi.java | 51 --
.../handlers/DigitalOceanErrorHandler.java | 59 --
...usFromPayloadHttpCommandExecutorService.java | 131 ----
.../http/filters/AuthenticationFilter.java | 55 --
.../predicates/SameFingerprint.java | 61 --
.../org/jclouds/digitalocean/ssh/DSAKeys.java | 172 -----
.../digitalocean/strategy/ListSshKeys.java | 80 --
.../DigitalOceanProviderMetadataTest.java | 32 -
.../DigitalOceanComputeServiceLiveTest.java | 59 --
.../DigitalOceanImageExtensionLiveTest.java | 40 -
.../compute/config/EventDonePredicateTest.java | 76 --
.../functions/DropletStatusToStatusTest.java | 39 -
.../functions/DropletToNodeMetadataTest.java | 198 -----
.../compute/functions/ImageToImageTest.java | 58 --
.../compute/functions/RegionToLocationTest.java | 54 --
.../compute/functions/SizeToHardwareTest.java | 48 --
...eOptionsToStatementWithoutPublicKeyTest.java | 75 --
.../DigitalOceanTemplateOptionsTest.java | 49 --
.../compute/util/LocationNamingUtilsTest.java | 109 ---
.../domain/OperatingSystemTest.java | 107 ---
.../features/DropletApiLiveTest.java | 205 -----
.../features/DropletApiMockTest.java | 770 -------------------
.../digitalocean/features/EventApiLiveTest.java | 56 --
.../digitalocean/features/EventApiMockTest.java | 93 ---
.../digitalocean/features/ImageApiLiveTest.java | 139 ----
.../digitalocean/features/ImageApiMockTest.java | 262 -------
.../features/KeyPairApiLiveTest.java | 76 --
.../features/KeyPairApiMockTest.java | 213 -----
.../features/RegionApiLiveTest.java | 46 --
.../features/RegionApiMockTest.java | 54 --
.../digitalocean/features/SizeApiLiveTest.java | 46 --
.../digitalocean/features/SizesApiMockTest.java | 54 --
...omPayloadHttpCommandExecutorServiceTest.java | 112 ---
.../http/filters/AuthenticationFilterTest.java | 58 --
.../internal/BaseDigitalOceanLiveTest.java | 90 ---
.../internal/BaseDigitalOceanMockTest.java | 107 ---
.../predicates/SameFingerprintTest.java | 72 --
.../jclouds/digitalocean/ssh/DSAKeysTest.java | 54 --
.../strategy/ListSshKeysLiveTest.java | 83 --
.../src/test/resources/access-denied.json | 5 -
.../src/test/resources/droplet-creation.json | 10 -
digitalocean/src/test/resources/droplet.json | 17 -
digitalocean/src/test/resources/droplets.json | 18 -
digitalocean/src/test/resources/error.json | 5 -
.../src/test/resources/event-pending.json | 10 -
digitalocean/src/test/resources/event.json | 10 -
digitalocean/src/test/resources/eventid.json | 4 -
digitalocean/src/test/resources/image1.json | 12 -
digitalocean/src/test/resources/image2.json | 12 -
digitalocean/src/test/resources/image3.json | 12 -
digitalocean/src/test/resources/images.json | 32 -
digitalocean/src/test/resources/key.json | 8 -
digitalocean/src/test/resources/keys.json | 10 -
digitalocean/src/test/resources/not-found.json | 5 -
digitalocean/src/test/resources/regions.json | 25 -
digitalocean/src/test/resources/sizes.json | 45 --
digitalocean/src/test/resources/ssh-dsa.txt | 1 -
digitalocean/src/test/resources/ssh-rsa.txt | 1 -
pom.xml | 1 -
94 files changed, 8537 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/README.txt
----------------------------------------------------------------------
diff --git a/digitalocean/README.txt b/digitalocean/README.txt
deleted file mode 100644
index 357023e..0000000
--- a/digitalocean/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-The jclouds provider for DigitalOcean (https://www.digitalocean.com/).
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/digitalocean/pom.xml b/digitalocean/pom.xml
deleted file mode 100644
index 1382502..0000000
--- a/digitalocean/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>jclouds-labs</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <!-- TODO: when out of labs, switch to org.apache.jclouds.provider -->
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>digitalocean</artifactId>
- <name>jclouds DigitalOcean Provider</name>
- <description>ComputeService binding to the DigitalOcean API</description>
- <packaging>bundle</packaging>
-
- <properties>
- <test.digitalocean.endpoint>https://api.digitalocean.com/</test.digitalocean.endpoint>
- <test.digitalocean.api-version></test.digitalocean.api-version>
- <test.digitalocean.identity>FIXME</test.digitalocean.identity>
- <test.digitalocean.credential>FIXME</test.digitalocean.credential>
- <!-- CentOS 6.5 x64 -->
- <test.digitalocean.template>imageId=centos-6-5-x64</test.digitalocean.template>
- <jclouds.osgi.export>org.jclouds.digitalocean*;version="${jclouds.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>
- org.jclouds.compute.internal;version="${jclouds.version}",
- org.jclouds.rest.internal;version="${jclouds.version}",
- org.jclouds*;version="${jclouds.version}",
- *
- </jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-sshj</artifactId>
- <version>${jclouds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.squareup.okhttp</groupId>
- <artifactId>mockwebserver</artifactId>
- <scope>test</scope>
- <exclusions>
- <!-- Already provided by jclouds-sshj -->
- <exclusion>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.google.auto.service</groupId>
- <artifactId>auto-service</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <threadCount>1</threadCount>
- <systemPropertyVariables>
- <test.digitalocean.endpoint>${test.digitalocean.endpoint}</test.digitalocean.endpoint>
- <test.digitalocean.api-version>${test.digitalocean.api-version}</test.digitalocean.api-version>
- <test.digitalocean.build-version>${test.digitalocean.build-version}</test.digitalocean.build-version>
- <test.digitalocean.credential>${test.digitalocean.credential}</test.digitalocean.credential>
- <test.digitalocean.template>${test.digitalocean.template}</test.digitalocean.template>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApi.java
deleted file mode 100644
index 4ff0c00..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApi.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.digitalocean;
-
-import java.io.Closeable;
-
-import org.jclouds.digitalocean.features.DropletApi;
-import org.jclouds.digitalocean.features.EventApi;
-import org.jclouds.digitalocean.features.ImageApi;
-import org.jclouds.digitalocean.features.KeyPairApi;
-import org.jclouds.digitalocean.features.RegionApi;
-import org.jclouds.digitalocean.features.SizesApi;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * Provides synchronous access to DigitalOcean API.
- */
-public interface DigitalOceanApi extends Closeable {
-
- /**
- * Returns the Droplet management API.
- */
- @Delegate
- DropletApi getDropletApi();
-
- /**
- * Returns the Image management API.
- */
- @Delegate
- ImageApi getImageApi();
-
- /**
- * Returns the Sizes management API.
- */
- @Delegate
- SizesApi getSizesApi();
-
- /**
- * Returns the Region management API.
- */
- @Delegate
- RegionApi getRegionApi();
-
- /**
- * Returns the SSH key management API.
- */
- @Delegate
- KeyPairApi getKeyPairApi();
-
- /**
- * Returns the Event API.
- */
- @Delegate
- EventApi getEventApi();
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApiMetadata.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApiMetadata.java b/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApiMetadata.java
deleted file mode 100644
index 611b228..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanApiMetadata.java
+++ /dev/null
@@ -1,90 +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.digitalocean;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.digitalocean.compute.config.DigitalOceanComputeServiceContextModule;
-import org.jclouds.digitalocean.config.DigitalOceanHttpApiModule;
-import org.jclouds.digitalocean.config.DigitalOceanHttpApiModule.DigitalOceanHttpCommandExecutorServiceModule;
-import org.jclouds.digitalocean.config.DigitalOceanParserModule;
-import org.jclouds.rest.internal.BaseHttpApiMetadata;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * Implementation of {@link BaseHttpApiMetadata} for the DigitalOcean API
- */
-public class DigitalOceanApiMetadata extends BaseHttpApiMetadata<DigitalOceanApi> {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public DigitalOceanApiMetadata() {
- this(new Builder());
- }
-
- protected DigitalOceanApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseHttpApiMetadata.defaultProperties();
- return properties;
- }
-
- public static class Builder extends BaseHttpApiMetadata.Builder<DigitalOceanApi, Builder> {
-
- protected Builder() {
- super(DigitalOceanApi.class);
- id("digitalocean")
- .name("DigitalOcean API")
- .identityName("Client Id")
- .credentialName("API Key")
- .documentation(URI.create("https://cloud.digitalocean.com/api_access"))
- .defaultEndpoint("https://api.digitalocean.com")
- .defaultProperties(DigitalOceanApiMetadata.defaultProperties())
- .view(ComputeServiceContext.class)
- .defaultModules(ImmutableSet.<Class<? extends Module>> of(
- DigitalOceanHttpApiModule.class,
- DigitalOceanHttpCommandExecutorServiceModule.class,
- DigitalOceanParserModule.class,
- DigitalOceanComputeServiceContextModule.class));
- }
-
- @Override
- public DigitalOceanApiMetadata build() {
- return new DigitalOceanApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- @Override
- public Builder fromApiMetadata(ApiMetadata in) {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanProviderMetadata.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanProviderMetadata.java b/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanProviderMetadata.java
deleted file mode 100644
index 3dbd814..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/DigitalOceanProviderMetadata.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.digitalocean;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.internal.BaseProviderMetadata;
-
-import com.google.auto.service.AutoService;
-
-/**
- * Implementation of {@link ProviderMetadata} for DigitalOcean.
- */
-@AutoService(ProviderMetadata.class)
-public class DigitalOceanProviderMetadata extends BaseProviderMetadata {
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return builder().fromProviderMetadata(this);
- }
-
- public DigitalOceanProviderMetadata() {
- super(builder());
- }
-
- public DigitalOceanProviderMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = DigitalOceanApiMetadata.defaultProperties();
- return properties;
- }
-
- public static class Builder extends BaseProviderMetadata.Builder {
-
- protected Builder() {
- id("digitalocean")
- .name("DigitalOcean Compute Services")
- .apiMetadata(new DigitalOceanApiMetadata())
- .homepage(URI.create("https://www.digitalocean.com/"))
- .console(URI.create("https://cloud.digitalocean.com/"))
- .endpoint("https://api.digitalocean.com")
- .defaultProperties(DigitalOceanProviderMetadata.defaultProperties());
- }
-
- @Override
- public DigitalOceanProviderMetadata build() {
- return new DigitalOceanProviderMetadata(this);
- }
-
- @Override
- public Builder fromProviderMetadata(ProviderMetadata in) {
- super.fromProviderMetadata(in);
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/config/DigitalOceanComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/config/DigitalOceanComputeServiceContextModule.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/config/DigitalOceanComputeServiceContextModule.java
deleted file mode 100644
index aa68f91..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/config/DigitalOceanComputeServiceContextModule.java
+++ /dev/null
@@ -1,166 +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.digitalocean.compute.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.functions.TemplateOptionsToStatement;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.reference.ComputeServiceConstants.PollPeriod;
-import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
-import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.compute.extensions.DigitalOceanImageExtension;
-import org.jclouds.digitalocean.compute.functions.DropletStatusToStatus;
-import org.jclouds.digitalocean.compute.functions.DropletToNodeMetadata;
-import org.jclouds.digitalocean.compute.functions.ImageToImage;
-import org.jclouds.digitalocean.compute.functions.RegionToLocation;
-import org.jclouds.digitalocean.compute.functions.SizeToHardware;
-import org.jclouds.digitalocean.compute.functions.TemplateOptionsToStatementWithoutPublicKey;
-import org.jclouds.digitalocean.compute.options.DigitalOceanTemplateOptions;
-import org.jclouds.digitalocean.compute.strategy.CreateKeyPairsThenCreateNodes;
-import org.jclouds.digitalocean.compute.strategy.DigitalOceanComputeServiceAdapter;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.domain.Location;
-import org.jclouds.util.Predicates2;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-
-/**
- * Configures the compute service classes for the DigitalOcean API.
- */
-public class DigitalOceanComputeServiceContextModule extends
- ComputeServiceAdapterContextModule<Droplet, Size, Image, Region> {
-
- @Override
- protected void configure() {
- super.configure();
-
- bind(new TypeLiteral<ComputeServiceAdapter<Droplet, Size, Image, Region>>() {
- }).to(DigitalOceanComputeServiceAdapter.class);
-
- bind(new TypeLiteral<Function<Droplet, NodeMetadata>>() {
- }).to(DropletToNodeMetadata.class);
- bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
- }).to(ImageToImage.class);
- bind(new TypeLiteral<Function<Region, Location>>() {
- }).to(RegionToLocation.class);
- bind(new TypeLiteral<Function<Size, Hardware>>() {
- }).to(SizeToHardware.class);
- bind(new TypeLiteral<Function<Droplet.Status, Status>>() {
- }).to(DropletStatusToStatus.class);
-
- install(new LocationsFromComputeServiceAdapterModule<Droplet, Size, Image, Region>() {
- });
-
- bind(CreateNodesInGroupThenAddToSet.class).to(CreateKeyPairsThenCreateNodes.class);
- bind(TemplateOptions.class).to(DigitalOceanTemplateOptions.class);
- bind(TemplateOptionsToStatement.class).to(TemplateOptionsToStatementWithoutPublicKey.class);
-
- bind(new TypeLiteral<ImageExtension>() {
- }).to(DigitalOceanImageExtension.class);
- }
-
- @Override
- protected Optional<ImageExtension> provideImageExtension(Injector i) {
- return Optional.of(i.getInstance(ImageExtension.class));
- }
-
- @Provides
- @Singleton
- @Named(TIMEOUT_NODE_RUNNING)
- protected Predicate<Integer> provideDropletRunningPredicate(final DigitalOceanApi api, Timeouts timeouts,
- PollPeriod pollPeriod) {
- return Predicates2.retry(new EventDonePredicate(api), timeouts.nodeRunning, pollPeriod.pollInitialPeriod,
- pollPeriod.pollMaxPeriod);
- }
-
- @Provides
- @Singleton
- @Named(TIMEOUT_NODE_SUSPENDED)
- protected Predicate<Integer> provideDropletSuspendedPredicate(final DigitalOceanApi api, Timeouts timeouts,
- PollPeriod pollPeriod) {
- return Predicates2.retry(new EventDonePredicate(api), timeouts.nodeSuspended, pollPeriod.pollInitialPeriod,
- pollPeriod.pollMaxPeriod);
- }
-
- @Provides
- @Singleton
- @Named(TIMEOUT_NODE_TERMINATED)
- protected Predicate<Integer> provideDropletTerminatedPredicate(final DigitalOceanApi api, Timeouts timeouts,
- PollPeriod pollPeriod) {
- return Predicates2.retry(new EventDonePredicate(api), timeouts.nodeTerminated, pollPeriod.pollInitialPeriod,
- pollPeriod.pollMaxPeriod);
- }
-
- @Provides
- @Singleton
- @Named(TIMEOUT_IMAGE_AVAILABLE)
- protected Predicate<Integer> provideImageAvailablePredicate(final DigitalOceanApi api, Timeouts timeouts,
- PollPeriod pollPeriod) {
- return Predicates2.retry(new EventDonePredicate(api), timeouts.imageAvailable, pollPeriod.pollInitialPeriod,
- pollPeriod.pollMaxPeriod);
- }
-
- @VisibleForTesting
- static class EventDonePredicate implements Predicate<Integer> {
-
- private final DigitalOceanApi api;
-
- public EventDonePredicate(DigitalOceanApi api) {
- this.api = checkNotNull(api, "api must not be null");
- }
-
- @Override
- public boolean apply(Integer input) {
- Event event = api.getEventApi().get(input);
- switch (event.getStatus()) {
- case DONE:
- return true;
- case PENDING:
- return false;
- case ERROR:
- default:
- throw new IllegalStateException("Resource is in invalid status: " + event.getStatus().name());
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/extensions/DigitalOceanImageExtension.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/extensions/DigitalOceanImageExtension.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/extensions/DigitalOceanImageExtension.java
deleted file mode 100644
index e45523c..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/extensions/DigitalOceanImageExtension.java
+++ /dev/null
@@ -1,132 +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.digitalocean.compute.extensions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.util.concurrent.Futures.immediateFuture;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-
-import java.util.NoSuchElementException;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.CloneImageTemplate;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageTemplate;
-import org.jclouds.compute.domain.ImageTemplateBuilder;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.primitives.Ints;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * The {@link ImageExtension} implementation for the DigitalOcean provider.
- */
-@Singleton
-public class DigitalOceanImageExtension implements ImageExtension {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final DigitalOceanApi api;
- private final Predicate<Integer> imageAvailablePredicate;
- private final Predicate<Integer> nodeStoppedPredicate;
- private final Function<org.jclouds.digitalocean.domain.Image, Image> imageTransformer;
-
- @Inject
- DigitalOceanImageExtension(DigitalOceanApi api,
- @Named(TIMEOUT_IMAGE_AVAILABLE) Predicate<Integer> imageAvailablePredicate,
- @Named(TIMEOUT_NODE_SUSPENDED) Predicate<Integer> nodeStoppedPredicate,
- Function<org.jclouds.digitalocean.domain.Image, Image> imageTransformer) {
- this.api = Preconditions.checkNotNull(api, "api cannot be null");
- this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate cannot be null");
- this.nodeStoppedPredicate = checkNotNull(nodeStoppedPredicate, "nodeStoppedPredicate cannot be null");
- this.imageTransformer = checkNotNull(imageTransformer, "imageTransformer cannot be null");
- }
-
- @Override
- public ImageTemplate buildImageTemplateFromNode(String name, String id) {
- Droplet droplet = api.getDropletApi().get(Integer.parseInt(id));
-
- if (droplet == null) {
- throw new NoSuchElementException("Cannot find droplet with id: " + id);
- }
-
- return new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
- }
-
- @Override
- public ListenableFuture<Image> createImage(ImageTemplate template) {
- checkState(template instanceof CloneImageTemplate, "DigitalOcean only supports creating images through cloning.");
- final CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
-
- // Droplet needs to be stopped
- int powerOffEvent = api.getDropletApi().powerOff(Integer.parseInt(cloneTemplate.getSourceNodeId()));
- nodeStoppedPredicate.apply(powerOffEvent);
-
- int snapshotEvent = api.getDropletApi().snapshot(Integer.parseInt(cloneTemplate.getSourceNodeId()),
- cloneTemplate.getName());
-
- logger.info(">> registered new Image, waiting for it to become available");
-
- // Until the process completes we don't have enough information to build an image to return
- imageAvailablePredicate.apply(snapshotEvent);
-
- org.jclouds.digitalocean.domain.Image snapshot = find(api.getImageApi().list(),
- new Predicate<org.jclouds.digitalocean.domain.Image>() {
- @Override
- public boolean apply(org.jclouds.digitalocean.domain.Image input) {
- return input.getName().equals(cloneTemplate.getName());
- }
- });
-
- return immediateFuture(imageTransformer.apply(snapshot));
- }
-
- @Override
- public boolean deleteImage(String id) {
- try {
- // The id of the image can be an id or a slug. Use the corresponding method of the API depending on what is
- // provided. If it can be parsed as a number, use the method to destroy by ID. Otherwise, destroy by slug.
- Integer imageId = Ints.tryParse(id);
- if (imageId != null) {
- logger.debug(">> image does not have a slug. Using the id to delete the image...");
- api.getImageApi().delete(imageId);
- } else {
- logger.debug(">> image has a slug. Using it to delete the image...");
- api.getImageApi().delete(id);
- }
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatus.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatus.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatus.java
deleted file mode 100644
index 859c694..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatus.java
+++ /dev/null
@@ -1,47 +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.digitalocean.compute.functions;
-
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.digitalocean.domain.Droplet;
-
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Transforms an {@link Status} to the jclouds portable model.
- */
-@Singleton
-public class DropletStatusToStatus implements Function<Droplet.Status, Status> {
-
- private static final Function<Droplet.Status, Status> toPortableStatus = Functions.forMap(
- ImmutableMap.<Droplet.Status, Status> builder()
- .put(Droplet.Status.NEW, Status.PENDING)
- .put(Droplet.Status.ACTIVE, Status.RUNNING)
- .put(Droplet.Status.ARCHIVE, Status.TERMINATED)
- .put(Droplet.Status.OFF, Status.SUSPENDED)
- .build(),
- Status.UNRECOGNIZED);
-
- @Override
- public Status apply(final Droplet.Status input) {
- return toPortableStatus.apply(input);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadata.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadata.java
deleted file mode 100644
index 5be3133..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadata.java
+++ /dev/null
@@ -1,162 +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.digitalocean.compute.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Iterables.tryFind;
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.extractRegionId;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * Transforms an {@link Droplet} to the jclouds portable model.
- */
-@Singleton
-public class DropletToNodeMetadata implements Function<Droplet, NodeMetadata> {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final Supplier<Map<String, ? extends Image>> images;
- private final Supplier<Map<String, ? extends Hardware>> hardwares;
- private final Supplier<Set<? extends Location>> locations;
- private final Function<Droplet.Status, Status> toPortableStatus;
- private final GroupNamingConvention groupNamingConvention;
- private final Map<String, Credentials> credentialStore;
-
- @Inject
- DropletToNodeMetadata(Supplier<Map<String, ? extends Image>> images,
- Supplier<Map<String, ? extends Hardware>> hardwares, @Memoized Supplier<Set<? extends Location>> locations,
- Function<Droplet.Status, Status> toPortableStatus, GroupNamingConvention.Factory groupNamingConvention,
- Map<String, Credentials> credentialStore) {
- this.images = checkNotNull(images, "images cannot be null");
- this.hardwares = checkNotNull(hardwares, "hardwares cannot be null");
- this.locations = checkNotNull(locations, "locations cannot be null");
- this.toPortableStatus = checkNotNull(toPortableStatus, "toPortableStatus cannot be null");
- this.groupNamingConvention = checkNotNull(groupNamingConvention, "groupNamingConvention cannot be null")
- .createWithoutPrefix();
- this.credentialStore = checkNotNull(credentialStore, "credentialStore cannot be null");
- }
-
- @Override
- public NodeMetadata apply(Droplet input) {
- NodeMetadataBuilder builder = new NodeMetadataBuilder();
- builder.ids(String.valueOf(input.getId()));
- builder.name(input.getName());
- builder.hostname(input.getName());
- builder.group(groupNamingConvention.extractGroup(input.getName()));
-
- builder.hardware(getHardware(input.getSizeId()));
- builder.location(getLocation(input.getRegionId()));
-
- Optional<? extends Image> image = findImage(input.getImageId());
- if (image.isPresent()) {
- builder.imageId(image.get().getId());
- builder.operatingSystem(image.get().getOperatingSystem());
- } else {
- logger.info(">> image with id %s for droplet %s was not found. "
- + "This might be because the image that was used to create the droplet has a new id.",
- input.getImageId(), input.getId());
- }
-
- builder.status(toPortableStatus.apply(input.getStatus()));
- builder.backendStatus(input.getStatus().name());
-
- if (input.getIp() != null) {
- builder.publicAddresses(ImmutableSet.of(input.getIp()));
- }
- if (input.getPrivateIp() != null) {
- builder.privateAddresses(ImmutableSet.of(input.getPrivateIp()));
- }
-
- // DigitalOcean does not provide a way to get the credentials.
- // Try to return them from the credential store
- Credentials credentials = credentialStore.get("node#" + input.getId());
- if (credentials instanceof LoginCredentials) {
- builder.credentials(LoginCredentials.class.cast(credentials));
- }
-
- return builder.build();
- }
-
- protected Optional<? extends Image> findImage(Integer id) {
- // Try to find the image by ID in the cache. The cache is indexed by slug (for public images) and by id (for
- // private ones).
- final String imageId = String.valueOf(id);
- Optional<? extends Image> image = Optional.fromNullable(images.get().get(imageId));
- if (!image.isPresent()) {
- // If it is a public image (indexed by slug) but the "int" form of the id was provided, try to find it in the
- // whole list of cached images
- image = tryFind(images.get().values(), new Predicate<Image>() {
- @Override
- public boolean apply(Image input) {
- return input.getProviderId().equals(imageId);
- }
- });
- }
- return image;
- }
-
- protected Hardware getHardware(Integer id) {
- // Hardwares are indexed by slug, but the droplet only provides its ID.
- final String hardwareId = String.valueOf(id);
- return Iterables.find(hardwares.get().values(), new Predicate<Hardware>() {
- @Override
- public boolean apply(Hardware input) {
- return input.getProviderId().equals(hardwareId);
- }
- });
- }
-
- protected Location getLocation(final Integer id) {
- return find(locations.get(), new Predicate<Location>() {
- @Override
- public boolean apply(Location location) {
- return id.equals(extractRegionId(location));
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/ImageToImage.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/ImageToImage.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/ImageToImage.java
deleted file mode 100644
index 46f18d0..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/ImageToImage.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.digitalocean.compute.functions;
-
-import static org.jclouds.compute.domain.OperatingSystem.builder;
-
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.Image.Status;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.OperatingSystem;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Transforms an {@link Image} to the jclouds portable model.
- */
-@Singleton
-public class ImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {
-
- @Override
- public org.jclouds.compute.domain.Image apply(final Image input) {
- String description = input.getOs().getDistribution().getValue() + " " + input.getName();
- ImageBuilder builder = new ImageBuilder();
- // Private images don't have a slug
- builder.id(input.getSlug() != null ? input.getSlug() : String.valueOf(input.getId()));
- builder.providerId(String.valueOf(input.getId()));
- builder.name(input.getName());
- builder.description(description);
- builder.status(Status.AVAILABLE);
-
- OperatingSystem os = input.getOs();
-
- builder.operatingSystem(builder()
- .name(os.getDistribution().getValue())
- .family(os.getDistribution().getOsFamily())
- .description(description)
- .arch(os.getArch())
- .version(os.getVersion())
- .is64Bit(os.is64bit())
- .build());
-
- ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
- metadata.put("publicImage", String.valueOf(input.isPublicImage()));
- builder.userMetadata(metadata.build());
-
- return builder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/RegionToLocation.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/RegionToLocation.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/RegionToLocation.java
deleted file mode 100644
index 9dc0d30..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/RegionToLocation.java
+++ /dev/null
@@ -1,58 +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.digitalocean.compute.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.encodeRegionIdAndName;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.location.suppliers.all.JustProvider;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Transforms an {@link Region} to the jclouds portable model.
- */
-@Singleton
-public class RegionToLocation implements Function<Region, Location> {
-
- private final JustProvider justProvider;
-
- @Inject
- RegionToLocation(JustProvider justProvider) {
- this.justProvider = checkNotNull(justProvider, "justProvider cannot be null");
- }
-
- @Override
- public Location apply(Region input) {
- LocationBuilder builder = new LocationBuilder();
- builder.id(input.getSlug());
- builder.description(encodeRegionIdAndName(input));
- builder.scope(LocationScope.REGION);
- builder.parent(getOnlyElement(justProvider.get()));
- builder.iso3166Codes(ImmutableSet.<String> of());
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/SizeToHardware.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/SizeToHardware.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/SizeToHardware.java
deleted file mode 100644
index 26b8001..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/SizeToHardware.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.digitalocean.compute.functions;
-
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume.Type;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.digitalocean.domain.Size;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Transforms an {@link Size} to the jclouds portable model.
- */
-@Singleton
-public class SizeToHardware implements Function<Size, Hardware> {
-
- @Override
- public Hardware apply(Size input) {
- HardwareBuilder builder = new HardwareBuilder();
- builder.id(input.getSlug());
- builder.providerId(String.valueOf(input.getId()));
- builder.name(input.getName());
- builder.ram(input.getMemory());
- // DigitalOcean does not provide the processor speed. We configure it to
- // make the bigger template the faster.
- builder.processor(new Processor(input.getCpu(), input.getCpu()));
-
- builder.volume(new VolumeBuilder()
- .size(Float.valueOf(input.getDisk()))
- .type(Type.LOCAL)
- .build());
-
- ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
- metadata.put("costPerHour", input.getCostPerHour());
- metadata.put("costPerMonth", input.getCostPerMonth());
- builder.userMetadata(metadata.build());
-
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKey.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKey.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKey.java
deleted file mode 100644
index 5311723..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKey.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.digitalocean.compute.functions;
-
-import javax.inject.Singleton;
-
-import org.jclouds.compute.functions.TemplateOptionsToStatement;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.scriptbuilder.InitScript;
-import org.jclouds.scriptbuilder.domain.Statement;
-import org.jclouds.scriptbuilder.domain.StatementList;
-import org.jclouds.scriptbuilder.statements.ssh.InstallRSAPrivateKey;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Convert the template options into a statement, but ignoring the public key.
- * <p>
- * The {@link org.jclouds.digitalocean.compute.strategy.DigitalOceanComputeServiceAdapter} already takes care of
- * installing it using the {@link org.jclouds.digitalocean.features.KeyPairApi}.
- */
-@Singleton
-public class TemplateOptionsToStatementWithoutPublicKey extends TemplateOptionsToStatement {
-
- @Override
- public Statement apply(TemplateOptions options) {
- ImmutableList.Builder<Statement> builder = ImmutableList.builder();
- if (options.getRunScript() != null) {
- builder.add(options.getRunScript());
- }
- if (options.getPrivateKey() != null) {
- builder.add(new InstallRSAPrivateKey(options.getPrivateKey()));
- }
-
- ImmutableList<Statement> bootstrap = builder.build();
- if (!bootstrap.isEmpty()) {
- if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) {
- options.nameTask("bootstrap");
- }
- return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap);
- }
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptions.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptions.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptions.java
deleted file mode 100644
index 6aa541c..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptions.java
+++ /dev/null
@@ -1,179 +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.digitalocean.compute.options;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Set;
-
-import org.jclouds.compute.options.TemplateOptions;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Custom options for the DigitalOcean API.
- */
-public class DigitalOceanTemplateOptions extends TemplateOptions implements Cloneable {
-
- private Set<Integer> sshKeyIds = ImmutableSet.of();
- private Boolean privateNetworking;
- private Boolean backupsEnabled;
- private boolean autoCreateKeyPair = true;
-
- /**
- * Enables a private network interface if the region supports private networking.
- */
- public DigitalOceanTemplateOptions privateNetworking(boolean privateNetworking) {
- this.privateNetworking = privateNetworking;
- return this;
- }
-
- /**
- * Enabled backups for the droplet.
- */
- public DigitalOceanTemplateOptions backupsEnabled(boolean backupsEnabled) {
- this.backupsEnabled = backupsEnabled;
- return this;
- }
-
- /**
- * Sets the ssh key ids to be added to the droplet.
- */
- public DigitalOceanTemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) {
- this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null"));
- return this;
- }
-
- /**
- * Sets whether an SSH key pair should be created automatically.
- */
- public DigitalOceanTemplateOptions autoCreateKeyPair(boolean autoCreateKeyPair) {
- this.autoCreateKeyPair = autoCreateKeyPair;
- return this;
- }
-
- public Set<Integer> getSshKeyIds() {
- return sshKeyIds;
- }
-
- public Boolean getPrivateNetworking() {
- return privateNetworking;
- }
-
- public Boolean getBackupsEnabled() {
- return backupsEnabled;
- }
-
- public boolean getAutoCreateKeyPair() {
- return autoCreateKeyPair;
- }
-
- @Override
- public DigitalOceanTemplateOptions clone() {
- DigitalOceanTemplateOptions options = new DigitalOceanTemplateOptions();
- copyTo(options);
- return options;
- }
-
- @Override
- public void copyTo(TemplateOptions to) {
- super.copyTo(to);
- if (to instanceof DigitalOceanTemplateOptions) {
- DigitalOceanTemplateOptions eTo = DigitalOceanTemplateOptions.class.cast(to);
- if (privateNetworking != null) {
- eTo.privateNetworking(privateNetworking);
- }
- if (backupsEnabled != null) {
- eTo.backupsEnabled(backupsEnabled);
- }
- eTo.autoCreateKeyPair(autoCreateKeyPair);
- eTo.sshKeyIds(sshKeyIds);
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), backupsEnabled, privateNetworking, autoCreateKeyPair, sshKeyIds);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- DigitalOceanTemplateOptions other = (DigitalOceanTemplateOptions) obj;
- return super.equals(other) && equal(this.backupsEnabled, other.backupsEnabled)
- && equal(this.privateNetworking, other.privateNetworking)
- && equal(this.autoCreateKeyPair, other.autoCreateKeyPair) && equal(this.sshKeyIds, other.sshKeyIds);
- }
-
- @Override
- public ToStringHelper string() {
- ToStringHelper toString = super.string().omitNullValues();
- toString.add("privateNetworking", privateNetworking);
- toString.add("backupsEnabled", backupsEnabled);
- if (!sshKeyIds.isEmpty()) {
- toString.add("sshKeyIds", sshKeyIds);
- }
- toString.add("autoCreateKeyPair", autoCreateKeyPair);
- return toString;
- }
-
- public static class Builder {
-
- /**
- * @see DigitalOceanTemplateOptions#privateNetworking
- */
- public static DigitalOceanTemplateOptions privateNetworking(boolean privateNetworking) {
- DigitalOceanTemplateOptions options = new DigitalOceanTemplateOptions();
- return options.privateNetworking(privateNetworking);
- }
-
- /**
- * @see DigitalOceanTemplateOptions#backupsEnabled
- */
- public static DigitalOceanTemplateOptions backupsEnabled(boolean backupsEnabled) {
- DigitalOceanTemplateOptions options = new DigitalOceanTemplateOptions();
- return options.backupsEnabled(backupsEnabled);
- }
-
- /**
- * @see DigitalOceanTemplateOptions#sshKeyIds
- */
- public static DigitalOceanTemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) {
- DigitalOceanTemplateOptions options = new DigitalOceanTemplateOptions();
- return options.sshKeyIds(sshKeyIds);
- }
-
- /**
- * @see DigitalOceanTemplateOptions#autoCreateKeyPair
- */
- public static DigitalOceanTemplateOptions autoCreateKeyPair(boolean autoCreateKeyPair) {
- DigitalOceanTemplateOptions options = new DigitalOceanTemplateOptions();
- return options.autoCreateKeyPair(autoCreateKeyPair);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/CreateKeyPairsThenCreateNodes.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/CreateKeyPairsThenCreateNodes.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/CreateKeyPairsThenCreateNodes.java
deleted file mode 100644
index 511a314..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/CreateKeyPairsThenCreateNodes.java
+++ /dev/null
@@ -1,205 +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.digitalocean.compute.strategy;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.tryFind;
-
-import java.security.PublicKey;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.compute.config.CustomizationResponse;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
-import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
-import org.jclouds.compute.strategy.ListNodesStrategy;
-import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.compute.options.DigitalOceanTemplateOptions;
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.predicates.SameFingerprint;
-import org.jclouds.digitalocean.strategy.ListSshKeys;
-import org.jclouds.logging.Logger;
-import org.jclouds.ssh.SshKeyPairGenerator;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-
-@Singleton
-public class CreateKeyPairsThenCreateNodes extends CreateNodesWithGroupEncodedIntoNameThenAddToSet {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final DigitalOceanApi api;
- private final SshKeyPairGenerator keyGenerator;
- private final ListSshKeys listSshKeys;
- private final Function<String, PublicKey> sshKeyToPublicKey;
-
- @Inject
- protected CreateKeyPairsThenCreateNodes(
- CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy,
- ListNodesStrategy listNodesStrategy,
- GroupNamingConvention.Factory namingConvention,
- @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
- CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
- DigitalOceanApi api, SshKeyPairGenerator keyGenerator, ListSshKeys.Factory listSshKeysFactory,
- Function<String, PublicKey> sshKeyToPublicKey) {
- super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor,
- customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
- this.api = checkNotNull(api, "api cannot be null");
- this.keyGenerator = checkNotNull(keyGenerator, "keyGenerator cannot be null");
- checkNotNull(listSshKeysFactory, "listSshKeysFactory cannot be null");
- checkNotNull(userExecutor, "userExecutor cannot be null");
- this.listSshKeys = listSshKeysFactory.create(userExecutor);
- this.sshKeyToPublicKey = checkNotNull(sshKeyToPublicKey, "sshKeyToPublicKey cannot be null");
- }
-
- @Override
- public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template,
- Set<NodeMetadata> goodNodes, Map<NodeMetadata, Exception> badNodes,
- Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
-
- DigitalOceanTemplateOptions options = template.getOptions().as(DigitalOceanTemplateOptions.class);
- Set<Integer> generatedSshKeyIds = Sets.newHashSet();
-
- // If no key has been configured and the auto-create option is set, then generate a key pair
- if (options.getSshKeyIds().isEmpty() && options.getAutoCreateKeyPair()
- && Strings.isNullOrEmpty(options.getPublicKey())) {
- generateKeyPairAndAddKeyToSet(options, generatedSshKeyIds);
- }
-
- // If there is a script to run in the node, make sure a pivate key has been configured so jclouds will be able to
- // access the node
- if (options.getRunScript() != null && Strings.isNullOrEmpty(options.getLoginPrivateKey())) {
- logger.warn(">> A runScript has been configured but no SSH key has been provided."
- + " Authentication will delegate to the ssh-agent");
- }
-
- // If there is a key configured, then make sure there is a key pair for it
- if (!Strings.isNullOrEmpty(options.getPublicKey())) {
- createKeyPairForPublicKeyInOptionsAndAddToSet(options, generatedSshKeyIds);
- }
-
- // Set all keys (the provided and the auto-generated) in the options object so the
- // DigitalOceanComputeServiceAdapter adds them all
- options.sshKeyIds(Sets.union(generatedSshKeyIds, options.getSshKeyIds()));
-
- Map<?, ListenableFuture<Void>> responses = super.execute(group, count, template, goodNodes, badNodes,
- customizationResponses);
-
- // Key pairs in DigitalOcean are only required to create the Droplets. They aren't used anymore so it is better
- // to delete the auto-generated key pairs at this point where we know exactly which ones have been
- // auto-generated by jclouds.
- registerAutoGeneratedKeyPairCleanupCallbacks(responses, generatedSshKeyIds);
-
- return responses;
- }
-
- private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOceanTemplateOptions options,
- Set<Integer> generatedSshKeyIds) {
- logger.debug(">> checking if the key pair already exists...");
-
- PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey());
- Optional<SshKey> key = tryFind(listSshKeys.execute(), new SameFingerprint(userKey));
-
- if (!key.isPresent()) {
- logger.debug(">> key pair not found. creating a new one...");
-
- String userFingerprint = SameFingerprint.computeFingerprint(userKey);
- SshKey newKey = api.getKeyPairApi().create(userFingerprint, options.getPublicKey());
-
- generatedSshKeyIds.add(newKey.getId());
- logger.debug(">> key pair created! %s", newKey);
- } else {
- logger.debug(">> key pair found! %s", key.get());
- generatedSshKeyIds.add(key.get().getId());
- }
- }
-
- private void generateKeyPairAndAddKeyToSet(DigitalOceanTemplateOptions options, Set<Integer> generatedSshKeyIds) {
- logger.debug(">> creating default keypair for node...");
-
- Map<String, String> defaultKeys = keyGenerator.get();
-
- PublicKey defaultPublicKey = sshKeyToPublicKey.apply(defaultKeys.get("public"));
- String fingerprint = SameFingerprint.computeFingerprint(defaultPublicKey);
- SshKey defaultKey = api.getKeyPairApi().create(fingerprint, defaultKeys.get("public"));
-
- generatedSshKeyIds.add(defaultKey.getId());
-
- logger.debug(">> keypair created! %s", defaultKey);
-
- // If a private key has not been explicitly set, configure the auto-generated one
- if (Strings.isNullOrEmpty(options.getLoginPrivateKey())) {
- options.overrideLoginPrivateKey(defaultKeys.get("private"));
- }
- }
-
- private void registerAutoGeneratedKeyPairCleanupCallbacks(Map<?, ListenableFuture<Void>> responses,
- final Set<Integer> generatedSshKeyIds) {
- // The Futures.allAsList fails immediately if some of the futures fail. The Futures.successfulAsList, however,
- // returns a list containing the results or 'null' for those futures that failed. We want to wait for all them
- // (even if they fail), so better use the latter form.
- ListenableFuture<List<Void>> aggregatedResponses = Futures.successfulAsList(responses.values());
-
- // Key pairs must be cleaned up after all futures completed (even if some failed).
- Futures.addCallback(aggregatedResponses, new FutureCallback<List<Void>>() {
- @Override
- public void onSuccess(List<Void> result) {
- cleanupAutoGeneratedKeyPairs(generatedSshKeyIds);
- }
-
- @Override
- public void onFailure(Throwable t) {
- cleanupAutoGeneratedKeyPairs(generatedSshKeyIds);
- }
-
- private void cleanupAutoGeneratedKeyPairs(Set<Integer> generatedSshKeyIds) {
- logger.debug(">> cleaning up auto-generated key pairs...");
- for (Integer sshKeyId : generatedSshKeyIds) {
- try {
- api.getKeyPairApi().delete(sshKeyId);
- } catch (Exception ex) {
- logger.warn(">> could not delete key pair %s: %s", sshKeyId, ex.getMessage());
- }
- }
- }
-
- }, userExecutor);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/DigitalOceanComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/DigitalOceanComputeServiceAdapter.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/DigitalOceanComputeServiceAdapter.java
deleted file mode 100644
index db1704c..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/strategy/DigitalOceanComputeServiceAdapter.java
+++ /dev/null
@@ -1,183 +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.digitalocean.compute.strategy;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.contains;
-import static com.google.common.collect.Iterables.filter;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.extractRegionId;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.compute.options.DigitalOceanTemplateOptions;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.digitalocean.domain.options.CreateDropletOptions;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.common.primitives.Ints;
-
-/**
- * Implementation of the Compute Service for the DigitalOcean API.
- */
-public class DigitalOceanComputeServiceAdapter implements ComputeServiceAdapter<Droplet, Size, Image, Region> {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final DigitalOceanApi api;
- private final Predicate<Integer> nodeRunningPredicate;
- private final Predicate<Integer> nodeStoppedPredicate;
- private final Predicate<Integer> nodeTerminatedPredicate;
-
- @Inject
- DigitalOceanComputeServiceAdapter(DigitalOceanApi api,
- @Named(TIMEOUT_NODE_RUNNING) Predicate<Integer> nodeRunningPredicate,
- @Named(TIMEOUT_NODE_SUSPENDED) Predicate<Integer> nodeStoppedPredicate,
- @Named(TIMEOUT_NODE_TERMINATED) Predicate<Integer> nodeTerminatedPredicate) {
- this.api = checkNotNull(api, "api cannot be null");
- this.nodeRunningPredicate = checkNotNull(nodeRunningPredicate, "nodeRunningPredicate cannot be null");
- this.nodeStoppedPredicate = checkNotNull(nodeStoppedPredicate, "nodeStoppedPredicate cannot be null");
- this.nodeTerminatedPredicate = checkNotNull(nodeTerminatedPredicate, "nodeTerminatedPredicate cannot be null");
- }
-
- @Override
- public NodeAndInitialCredentials<Droplet> createNodeWithGroupEncodedIntoName(String group, final String name,
- Template template) {
- DigitalOceanTemplateOptions templateOptions = template.getOptions().as(DigitalOceanTemplateOptions.class);
- CreateDropletOptions.Builder options = CreateDropletOptions.builder();
-
- // DigitalOcean specific options
- if (!templateOptions.getSshKeyIds().isEmpty()) {
- options.addSshKeyIds(templateOptions.getSshKeyIds());
- }
- if (templateOptions.getPrivateNetworking() != null) {
- options.privateNetworking(templateOptions.getPrivateNetworking());
- }
- if (templateOptions.getBackupsEnabled() != null) {
- options.backupsEnabled(templateOptions.getBackupsEnabled());
- }
-
- // Find the location where the Droplet has to be created
- int regionId = extractRegionId(template.getLocation());
-
- DropletCreation dropletCreation = api.getDropletApi().create(name,
- Integer.parseInt(template.getImage().getProviderId()),
- Integer.parseInt(template.getHardware().getProviderId()), regionId, options.build());
-
- // We have to actively wait until the droplet has been provisioned until
- // we can build the entire Droplet object we want to return
- nodeRunningPredicate.apply(dropletCreation.getEventId());
- Droplet droplet = api.getDropletApi().get(dropletCreation.getId());
-
- LoginCredentials defaultCredentials = LoginCredentials.builder().user("root")
- .privateKey(templateOptions.getLoginPrivateKey()).build();
-
- return new NodeAndInitialCredentials<Droplet>(droplet, String.valueOf(droplet.getId()), defaultCredentials);
- }
-
- @Override
- public Iterable<Image> listImages() {
- return api.getImageApi().list();
- }
-
- @Override
- public Iterable<Size> listHardwareProfiles() {
- return api.getSizesApi().list();
- }
-
- @Override
- public Iterable<Region> listLocations() {
- return api.getRegionApi().list();
- }
-
- @Override
- public Iterable<Droplet> listNodes() {
- return api.getDropletApi().list();
- }
-
- @Override
- public Iterable<Droplet> listNodesByIds(final Iterable<String> ids) {
- return filter(listNodes(), new Predicate<Droplet>() {
- @Override
- public boolean apply(Droplet droplet) {
- return contains(ids, String.valueOf(droplet.getId()));
- }
- });
- }
-
- @Override
- public Image getImage(String id) {
- // The id of the image can be an id or a slug. Use the corresponding method of the API depending on what is
- // provided. If it can be parsed as a number, use the method to get by ID. Otherwise, get by slug.
- Integer imageId = Ints.tryParse(id);
- return imageId != null ? api.getImageApi().get(imageId) : api.getImageApi().get(id);
- }
-
- @Override
- public Droplet getNode(String id) {
- return api.getDropletApi().get(Integer.parseInt(id));
- }
-
- @Override
- public void destroyNode(String id) {
- // We have to wait here, as the api does not properly populate the state
- // but fails if there is a pending event
- int event = api.getDropletApi().destroy(Integer.parseInt(id), true);
- nodeTerminatedPredicate.apply(event);
- }
-
- @Override
- public void rebootNode(String id) {
- // We have to wait here, as the api does not properly populate the state
- // but fails if there is a pending event
- int event = api.getDropletApi().reboot(Integer.parseInt(id));
- nodeRunningPredicate.apply(event);
- }
-
- @Override
- public void resumeNode(String id) {
- // We have to wait here, as the api does not properly populate the state
- // but fails if there is a pending event
- int event = api.getDropletApi().powerOn(Integer.parseInt(id));
- nodeRunningPredicate.apply(event);
- }
-
- @Override
- public void suspendNode(String id) {
- // We have to wait here, as the api does not properly populate the state
- // but fails if there is a pending event
- int event = api.getDropletApi().powerOff(Integer.parseInt(id));
- nodeStoppedPredicate.apply(event);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java
deleted file mode 100644
index 13a34b2..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.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.digitalocean.compute.util;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.domain.Location;
-
-/**
- * Utility class to encode and decode the region id and name in a {@link Location}.
- */
-public class LocationNamingUtils {
-
- /**
- * Extracts the region id for the given location.
- *
- * @param location The location to extract the region id from.
- * @return The id of the region.
- */
- public static int extractRegionId(Location location) {
- checkNotNull(location, "location cannot be null");
- String regionIdAndName = location.getDescription();
- int index = regionIdAndName.indexOf('/');
- checkArgument(index >= 0, "location description should be in the form 'regionId/regionName' but was: %s",
- regionIdAndName);
- return Integer.parseInt(regionIdAndName.substring(0, index));
- }
-
- /**
- * Extracts the region name for the given location.
- *
- * @param location The location to extract the region name from.
- * @return The name of the region.
- */
- public static String extractRegionName(Location location) {
- checkNotNull(location, "location cannot be null");
- String regionIdAndName = location.getDescription();
- int index = regionIdAndName.indexOf('/');
- checkArgument(index >= 0, "location description should be in the form 'regionId/regionName' but was: %s",
- regionIdAndName);
- return regionIdAndName.substring(index + 1);
- }
-
- /**
- * Encodes the id and name of the given region into a String so it can be populated in a {@link Location} object.
- *
- * @param region The region to encode.
- * @return The encoded id and name for the given region.
- */
- public static String encodeRegionIdAndName(Region region) {
- checkNotNull(region, "region cannot be null");
- return region.getId() + "/" + region.getName();
- }
-}
[3/5] jclouds-labs git commit: Remove DigitalOcean v1
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/handlers/DigitalOceanErrorHandler.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/handlers/DigitalOceanErrorHandler.java b/digitalocean/src/main/java/org/jclouds/digitalocean/handlers/DigitalOceanErrorHandler.java
deleted file mode 100644
index e223e51..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/handlers/DigitalOceanErrorHandler.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.digitalocean.handlers;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-
-/**
- * Parse the errors in the response and propagate an appropriate exception.
- *
- *
- * @see org.jclouds.digitalocean.http.ResponseStatusFromPayloadHttpCommandExecutorService
- */
-@Singleton
-public class DigitalOceanErrorHandler implements HttpErrorHandler {
-
- @Override
- public void handleError(HttpCommand command, HttpResponse response) {
- Exception exception = null;
-
- try {
- // The response message is already properly populated by the
- // ResponseStatusFromPayloadHttpCommandExecutorService
- switch (response.getStatusCode()) {
- case 401:
- exception = new AuthorizationException(response.getMessage(), exception);
- break;
- case 404:
- exception = new ResourceNotFoundException(response.getMessage(), exception);
- break;
- default:
- exception = new HttpResponseException(response.getMessage(), command, response);
- break;
- }
- } finally {
- command.setException(exception);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorService.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorService.java b/digitalocean/src/main/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorService.java
deleted file mode 100644
index 997709c..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorService.java
+++ /dev/null
@@ -1,131 +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.digitalocean.http;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.io.Payloads.newInputStreamPayload;
-import static org.jclouds.util.Closeables2.closeQuietly;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.Proxy;
-import java.net.URI;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLContext;
-
-import org.jclouds.digitalocean.domain.BaseResponse;
-import org.jclouds.digitalocean.domain.BaseResponse.Status;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpUtils;
-import org.jclouds.http.IOExceptionRetryHandler;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.http.handlers.DelegatingErrorHandler;
-import org.jclouds.http.handlers.DelegatingRetryHandler;
-import org.jclouds.http.internal.HttpWire;
-import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService;
-import org.jclouds.io.ContentMetadataCodec;
-import org.jclouds.io.Payload;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.io.ByteStreams;
-
-/**
- * Custom implementation of the HTTP driver to read the response body in order to get the real response status.
- * <p>
- * The DigitalOcean API always return 200 codes even if a request failed due to some internal error, but populates an
- * <code>ERROR</code> string in the response payload.
- * <p>
- * This class will read the body of the response and populate a 500 status code if an error is found.
- */
-@Singleton
-public class ResponseStatusFromPayloadHttpCommandExecutorService extends JavaUrlHttpCommandExecutorService {
-
- public static final String ACCESS_DENIED = "Access Denied";
- public static final String NOT_FOUND = "Not Found";
-
- private final ParseJson<BaseResponse> errorParser;
-
- @Inject
- ResponseStatusFromPayloadHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
- DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
- DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier,
- @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI,
- ParseJson<BaseResponse> errorParser) throws SecurityException, NoSuchFieldException {
- super(utils, contentMetadataCodec, retryHandler, ioRetryHandler, errorHandler, wire, verifier,
- untrustedSSLContextProvider, proxyForURI);
- this.errorParser = checkNotNull(errorParser, "errorParser cannot be null");
- }
-
- @Override
- protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException {
- HttpResponse original = super.invoke(connection);
- HttpResponse.Builder<?> response = original.toBuilder();
-
- if (hasPayload(original)) {
- // As we need to read the response body to determine if there are errors, but we may need to process the body
- // again later in the response parsers if everything is OK, we buffer the body into an InputStream we can reset
- InputStream in = null;
- InputStream originalInputStream = original.getPayload().openStream();
-
- if (originalInputStream instanceof ByteArrayInputStream) {
- in = originalInputStream;
- } else {
- try {
- in = new ByteArrayInputStream(ByteStreams.toByteArray(originalInputStream));
- } finally {
- closeQuietly(originalInputStream);
- }
- }
-
- // Process the payload and look for errors
- BaseResponse responseContent = errorParser.apply(in);
- if (responseContent != null && responseContent.getStatus() == Status.ERROR) {
- // Yes, this is ugly, but the DigitalOcean API sometimes sets the status code to 200 for these errors and
- // the only way to know what happened is parsing the error message
- String message = responseContent.getMessage();
- if (ACCESS_DENIED.equals(message)) {
- response.statusCode(401);
- } else if (NOT_FOUND.equals(message)) {
- response.statusCode(404);
- } else {
- response.statusCode(500);
- }
- response.message(responseContent.getDetails());
- }
-
- // Reset the input stream and set the payload, so it can be read again
- // by the response and error parsers
- in.reset();
- Payload payload = newInputStreamPayload(in);
- contentMetadataCodec.fromHeaders(payload.getContentMetadata(), original.getHeaders());
- response.payload(payload);
- }
-
- return response.build();
- }
-
- private static boolean hasPayload(final HttpResponse response) {
- return response.getPayload() != null && response.getPayload().getRawContent() != null;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/http/filters/AuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/http/filters/AuthenticationFilter.java b/digitalocean/src/main/java/org/jclouds/digitalocean/http/filters/AuthenticationFilter.java
deleted file mode 100644
index a1dae73..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/http/filters/AuthenticationFilter.java
+++ /dev/null
@@ -1,55 +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.digitalocean.http.filters;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequestFilter;
-import org.jclouds.location.Provider;
-
-import com.google.common.base.Supplier;
-
-/**
- * Adds the authentication query parameters to the requests.
- */
-@Singleton
-public class AuthenticationFilter implements HttpRequestFilter {
-
- public static final String IDENTITY_PARAM = "client_id";
- public static final String CREDENTIAL_PARAM = "api_key";
-
- private final Supplier<Credentials> credentials;
-
- @Inject
- AuthenticationFilter(@Provider final Supplier<Credentials> credentials) {
- this.credentials = checkNotNull(credentials, "credential supplier cannot be null");
- }
-
- @Override
- public HttpRequest filter(HttpRequest request) throws HttpException {
- Credentials creds = credentials.get();
- return request.toBuilder().addQueryParam(IDENTITY_PARAM, creds.identity)
- .addQueryParam(CREDENTIAL_PARAM, creds.credential).build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/predicates/SameFingerprint.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/predicates/SameFingerprint.java b/digitalocean/src/main/java/org/jclouds/digitalocean/predicates/SameFingerprint.java
deleted file mode 100644
index f7d414a..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/predicates/SameFingerprint.java
+++ /dev/null
@@ -1,61 +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.digitalocean.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.security.PublicKey;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.RSAPublicKey;
-
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.ssh.DSAKeys;
-import org.jclouds.ssh.SshKeys;
-
-import com.google.common.base.Predicate;
-
-/**
- * Predicate to compare SSH keys by fingerprint.
- */
-public class SameFingerprint implements Predicate<SshKey> {
-
- public final String fingerprint;
-
- public SameFingerprint(PublicKey key) {
- this.fingerprint = computeFingerprint(checkNotNull(key, "key cannot be null"));
- }
-
- @Override
- public boolean apply(SshKey key) {
- checkNotNull(key, "key cannot be null");
- checkNotNull(key.getPublicKey(), "public key cannot be null");
- return fingerprint.equals(computeFingerprint(key.getPublicKey()));
- }
-
- public static String computeFingerprint(PublicKey key) {
- if (key instanceof RSAPublicKey) {
- RSAPublicKey rsaKey = (RSAPublicKey) key;
- return SshKeys.fingerprint(rsaKey.getPublicExponent(), rsaKey.getModulus());
- } else if (key instanceof DSAPublicKey) {
- DSAPublicKey dsaKey = (DSAPublicKey) key;
- return DSAKeys.fingerprint(dsaKey.getParams().getP(), dsaKey.getParams().getQ(), dsaKey.getParams().getG(),
- dsaKey.getY());
- } else {
- throw new IllegalArgumentException("Only RSA and DSA keys are supported");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/ssh/DSAKeys.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/ssh/DSAKeys.java b/digitalocean/src/main/java/org/jclouds/digitalocean/ssh/DSAKeys.java
deleted file mode 100644
index c13750c..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/ssh/DSAKeys.java
+++ /dev/null
@@ -1,172 +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.digitalocean.ssh;
-
-import static com.google.common.base.Joiner.on;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Splitter.fixedLength;
-import static com.google.common.base.Throwables.propagate;
-import static com.google.common.collect.Iterables.get;
-import static com.google.common.collect.Iterables.size;
-import static com.google.common.io.BaseEncoding.base16;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.util.Strings2.toStringAndClose;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPublicKey;
-import java.security.spec.DSAPublicKeySpec;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Splitter;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.Hashing;
-import com.google.common.io.ByteSource;
-import com.google.common.io.ByteStreams;
-
-/**
- * Utility methods to work with DSA SSH keys.
- * <p>
- * Methods in this class should be moved to the {@link org.jclouds.ssh.SshKeys} class.
- *
- *
- * @see org.jclouds.ssh.SshKeys
- */
-public class DSAKeys {
-
- public static String encodeAsOpenSSH(DSAPublicKey key) {
- DSAParams params = key.getParams();
- byte[] keyBlob = keyBlob(params.getP(), params.getQ(), params.getG(), key.getY());
- return "ssh-dss " + base64().encode(keyBlob);
- }
-
- /**
- * Executes {@link org.jclouds.crypto.Pems#publicKeySpecFromOpenSSH(com.google.common.io.InputSupplier)} on the
- * string which was OpenSSH Base64 Encoded {@code id_rsa.pub}
- *
- * @param idRsaPub formatted {@code ssh-dss AAAAB3NzaC1yc2EAAAADAQABAAAB...}
- * @see org.jclouds.crypto.Pems#publicKeySpecFromOpenSSH(com.google.common.io.InputSupplier)
- */
- public static DSAPublicKeySpec publicKeySpecFromOpenSSH(String idDsaPub) {
- try {
- return publicKeySpecFromOpenSSH(ByteSource.wrap(idDsaPub.getBytes(Charsets.UTF_8)));
- } catch (IOException e) {
- throw propagate(e);
- }
- }
-
- /**
- * Returns {@link DSAPublicKeySpec} which was OpenSSH Base64 Encoded {@code id_rsa.pub}
- *
- * @param supplier the input stream factory, formatted {@code ssh-dss AAAAB3NzaC1yc2EAAAADAQABAAAB...}
- *
- * @return the {@link DSAPublicKeySpec} which was OpenSSH Base64 Encoded {@code id_rsa.pub}
- * @throws IOException if an I/O error occurs
- */
- public static DSAPublicKeySpec publicKeySpecFromOpenSSH(ByteSource supplier) throws IOException {
- InputStream stream = supplier.openStream();
- Iterable<String> parts = Splitter.on(' ').split(toStringAndClose(stream).trim());
- checkArgument(size(parts) >= 2 && "ssh-dss".equals(get(parts, 0)), "bad format, should be: ssh-dss AAAAB3...");
- stream = new ByteArrayInputStream(base64().decode(get(parts, 1)));
- String marker = new String(readLengthFirst(stream));
- checkArgument("ssh-dss".equals(marker), "looking for marker ssh-dss but got %s", marker);
- BigInteger p = new BigInteger(readLengthFirst(stream));
- BigInteger q = new BigInteger(readLengthFirst(stream));
- BigInteger g = new BigInteger(readLengthFirst(stream));
- BigInteger y = new BigInteger(readLengthFirst(stream));
- return new DSAPublicKeySpec(y, p, q, g);
- }
-
- /**
- * @param publicKeyOpenSSH RSA public key in OpenSSH format
- * @return fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9}
- */
- public static String fingerprintPublicKey(String publicKeyOpenSSH) {
- DSAPublicKeySpec publicKeySpec = publicKeySpecFromOpenSSH(publicKeyOpenSSH);
- return fingerprint(publicKeySpec.getP(), publicKeySpec.getQ(), publicKeySpec.getG(), publicKeySpec.getY());
- }
-
- /**
- * Create a fingerprint per the following <a href="http://tools.ietf.org/html/draft-friedl-secsh-fingerprint-00"
- * >spec</a>
- *
- * @return hex fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9}
- */
- public static String fingerprint(BigInteger p, BigInteger q, BigInteger g, BigInteger y) {
- byte[] keyBlob = keyBlob(p, q, g, y);
- return hexColonDelimited(Hashing.md5().hashBytes(keyBlob));
- }
-
- /**
- * @see org.jclouds.ssh.SshKeys
- */
- private static String hexColonDelimited(HashCode hc) {
- return on(':').join(fixedLength(2).split(base16().lowerCase().encode(hc.asBytes())));
- }
-
- /**
- * @see org.jclouds.ssh.SshKeys
- */
- private static byte[] keyBlob(BigInteger p, BigInteger q, BigInteger g, BigInteger y) {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- writeLengthFirst("ssh-dss".getBytes(), out);
- writeLengthFirst(p.toByteArray(), out);
- writeLengthFirst(q.toByteArray(), out);
- writeLengthFirst(g.toByteArray(), out);
- writeLengthFirst(y.toByteArray(), out);
- return out.toByteArray();
- } catch (IOException e) {
- throw propagate(e);
- }
- }
-
- /**
- * @see org.jclouds.ssh.SshKeys
- */
- // http://www.ietf.org/rfc/rfc4253.txt
- private static byte[] readLengthFirst(InputStream in) throws IOException {
- int byte1 = in.read();
- int byte2 = in.read();
- int byte3 = in.read();
- int byte4 = in.read();
- int length = (byte1 << 24) + (byte2 << 16) + (byte3 << 8) + (byte4 << 0);
- byte[] val = new byte[length];
- ByteStreams.readFully(in, val);
- return val;
- }
-
- /**
- * @see org.jclouds.ssh.SshKeys
- */
- // http://www.ietf.org/rfc/rfc4253.txt
- private static void writeLengthFirst(byte[] array, ByteArrayOutputStream out) throws IOException {
- out.write(array.length >>> 24 & 0xFF);
- out.write(array.length >>> 16 & 0xFF);
- out.write(array.length >>> 8 & 0xFF);
- out.write(array.length >>> 0 & 0xFF);
- if (array.length == 1 && array[0] == (byte) 0x00) {
- out.write(new byte[0]);
- } else {
- out.write(array);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/strategy/ListSshKeys.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/strategy/ListSshKeys.java b/digitalocean/src/main/java/org/jclouds/digitalocean/strategy/ListSshKeys.java
deleted file mode 100644
index a51cb60..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/strategy/ListSshKeys.java
+++ /dev/null
@@ -1,80 +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.digitalocean.strategy;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
-import static com.google.common.util.concurrent.Futures.allAsList;
-import static com.google.common.util.concurrent.Futures.getUnchecked;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.features.KeyPairApi;
-
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.inject.assistedinject.Assisted;
-
-/**
- * The {@link org.jclouds.digitalocean.features.KeyPairApi} only returns the id and name of each key but not the actual
- * public key when listing all keys.
- * <p>
- * This strategy provides a helper to get all the keys with all details populated.
- */
-@Singleton
-public class ListSshKeys {
-
- public interface Factory {
- ListSshKeys create(ListeningExecutorService executor);
- }
-
- private final KeyPairApi keyPairApi;
- private final ListeningExecutorService executor;
-
- @Inject
- ListSshKeys(DigitalOceanApi api, @Assisted ListeningExecutorService executor) {
- checkNotNull(api, "api cannot be null");
- this.executor = checkNotNull(executor, "executor cannot be null");
- this.keyPairApi = api.getKeyPairApi();
- }
-
- public List<SshKey> execute() {
- List<SshKey> keys = keyPairApi.list();
-
- ListenableFuture<List<SshKey>> futures = allAsList(transform(keys,
- new Function<SshKey, ListenableFuture<SshKey>>() {
- @Override
- public ListenableFuture<SshKey> apply(final SshKey input) {
- return executor.submit(new Callable<SshKey>() {
- @Override
- public SshKey call() throws Exception {
- return keyPairApi.get(input.getId());
- }
- });
- }
- }));
-
- return getUnchecked(futures);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/DigitalOceanProviderMetadataTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/DigitalOceanProviderMetadataTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/DigitalOceanProviderMetadataTest.java
deleted file mode 100644
index 1354055..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/DigitalOceanProviderMetadataTest.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.digitalocean;
-
-import org.jclouds.providers.internal.BaseProviderMetadataTest;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link DigitalOceanApiMetadata}.
- */
-@Test(groups = "unit", testName = "DigitalOceanProviderMetadataTest")
-public class DigitalOceanProviderMetadataTest extends BaseProviderMetadataTest {
-
- public DigitalOceanProviderMetadataTest() {
- super(new DigitalOceanProviderMetadata(), new DigitalOceanApiMetadata());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanComputeServiceLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanComputeServiceLiveTest.java
deleted file mode 100644
index d52eacf..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanComputeServiceLiveTest.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.digitalocean.compute;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * Live tests for the {@link org.jclouds.compute.ComputeService} integration.
- */
-@Test(groups = "live", singleThreaded = true, testName = "DigitalOceanComputeServiceLiveTest")
-public class DigitalOceanComputeServiceLiveTest extends BaseComputeServiceLiveTest {
-
- public DigitalOceanComputeServiceLiveTest() {
- provider = "digitalocean";
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
- @Override
- public void testOptionToNotBlock() throws Exception {
- // DigitalOcean ComputeService implementation has to block until the node
- // is provisioned, to be able to return it.
- }
-
- @Override
- protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) {
- // DigitalOcean does not support tags
- }
-
- @Override
- protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
- // DigitalOcean does not support user metadata
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanImageExtensionLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanImageExtensionLiveTest.java
deleted file mode 100644
index 56179b3..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/DigitalOceanImageExtensionLiveTest.java
+++ /dev/null
@@ -1,40 +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.digitalocean.compute;
-
-import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Module;
-
-/**
- * Live tests for the {@link org.jclouds.compute.extensions.ImageExtension} integration.
- */
-@Test(groups = "live", singleThreaded = true, testName = "DigitalOceanImageExtensionLiveTest")
-public class DigitalOceanImageExtensionLiveTest extends BaseImageExtensionLiveTest {
-
- public DigitalOceanImageExtensionLiveTest() {
- provider = "digitalocean";
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/config/EventDonePredicateTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/config/EventDonePredicateTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/config/EventDonePredicateTest.java
deleted file mode 100644
index 70ac19e..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/config/EventDonePredicateTest.java
+++ /dev/null
@@ -1,76 +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.digitalocean.compute.config;
-
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import org.easymock.EasyMock;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.compute.config.DigitalOceanComputeServiceContextModule.EventDonePredicate;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.domain.Event.Status;
-import org.jclouds.digitalocean.features.EventApi;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link EventDonePredicate} class.
- */
-@Test(groups = "unit", testName = "EventDonePredicateTest")
-public class EventDonePredicateTest {
-
- public void testEventProgress() {
- EventApi eventApi = EasyMock.createMock(EventApi.class);
- DigitalOceanApi api = EasyMock.createMock(DigitalOceanApi.class);
-
- expect(eventApi.get(1)).andReturn(event(Status.DONE));
- expect(eventApi.get(2)).andReturn(event(Status.PENDING));
- expect(api.getEventApi()).andReturn(eventApi).times(2);
- replay(eventApi, api);
-
- EventDonePredicate predicate = new EventDonePredicate(api);
- assertTrue(predicate.apply(1));
- assertFalse(predicate.apply(2));
- }
-
- public void testEventFailed() {
- EventApi eventApi = EasyMock.createMock(EventApi.class);
- DigitalOceanApi api = EasyMock.createMock(DigitalOceanApi.class);
-
- expect(eventApi.get(anyInt())).andReturn(event(Status.ERROR));
- expect(api.getEventApi()).andReturn(eventApi);
- replay(eventApi, api);
-
- EventDonePredicate predicate = new EventDonePredicate(api);
-
- try {
- predicate.apply(1);
- fail("Method should have thrown an IllegalStateException");
- } catch (IllegalStateException ex) {
- assertEquals(ex.getMessage(), "Resource is in invalid status: ERROR");
- }
- }
-
- private static Event event(Status status) {
- return new Event(0, status, 0, "0", 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatusTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatusTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatusTest.java
deleted file mode 100644
index deddcee..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletStatusToStatusTest.java
+++ /dev/null
@@ -1,39 +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.digitalocean.compute.functions;
-
-import static org.jclouds.compute.domain.NodeMetadata.Status.UNRECOGNIZED;
-import static org.testng.Assert.assertNotEquals;
-
-import org.jclouds.digitalocean.domain.Droplet.Status;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link DropletStatusToStatus} class.
- */
-@Test(groups = "unit", testName = "DropletStatusToStatusTest")
-public class DropletStatusToStatusTest {
-
- @Test
- public void testAllStatesHaveMapping() {
- DropletStatusToStatus function = new DropletStatusToStatus();
- for (Status status : Status.values()) {
- assertNotEquals(function.apply(status), UNRECOGNIZED);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadataTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadataTest.java
deleted file mode 100644
index d55854b..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/DropletToNodeMetadataTest.java
+++ /dev/null
@@ -1,198 +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.digitalocean.compute.functions;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.compute.domain.Image.Status.AVAILABLE;
-import static org.jclouds.compute.domain.NodeMetadata.Status.RUNNING;
-import static org.jclouds.digitalocean.domain.Droplet.Status.ACTIVE;
-import static org.testng.Assert.assertEquals;
-
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume.Type;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.digitalocean.DigitalOceanApiMetadata;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.domain.LoginCredentials;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.name.Names;
-
-/**
- * Unit tests for the {@link DropletToNodeMetadata} class.
- */
-@Test(groups = "unit", testName = "DropletToNodeMetadataTest")
-public class DropletToNodeMetadataTest {
-
- private Set<Hardware> hardwares;
-
- private Set<Image> images;
-
- private Set<Location> locations;
-
- private LoginCredentials credentials;
-
- private DropletToNodeMetadata function;
-
- @BeforeMethod
- public void setup() {
- images = ImmutableSet.of(new ImageBuilder()
- .id("ubuntu-1404-x86")
- .providerId("1")
- .name("mock image")
- .status(AVAILABLE)
- .operatingSystem(
- OperatingSystem.builder().name("Ubuntu 14.04 x86_64").description("Ubuntu").family(OsFamily.UBUNTU)
- .version("10.04").arch("x86_64").is64Bit(true).build()).build());
-
- hardwares = ImmutableSet.of(new HardwareBuilder().id("2gb").providerId("1").name("mock hardware")
- .processor(new Processor(1.0, 1.0)).ram(2048)
- .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()).build());
-
- locations = ImmutableSet.of(new LocationBuilder()
- .id("1")
- .description("1/mock location")
- .scope(LocationScope.REGION)
- .parent(
- new LocationBuilder().id("0").description("mock parent location").scope(LocationScope.PROVIDER)
- .build()).build());
-
- credentials = LoginCredentials.builder().user("foo").password("bar").build();
-
- function = createNodeParser(hardwares, images, locations, ImmutableMap.of("node#1", (Credentials) credentials));
- }
-
- @Test
- public void testConvertDroplet() throws ParseException {
- Droplet droplet = new Droplet(1, "mock-droplet", 1, 1, 1, false, ImmutableList.of(), ImmutableList.of(),
- "84.45.69.3", "192.168.2.5", false, ACTIVE, new Date());
-
- NodeMetadata expected = new NodeMetadataBuilder().ids("1").hardware(getOnlyElement(hardwares))
- .imageId("ubuntu-1404-x86").status(RUNNING).location(getOnlyElement(locations)).name("mock-droplet")
- .hostname("mock-droplet").group("mock").credentials(credentials)
- .publicAddresses(ImmutableSet.of("84.45.69.3")).privateAddresses(ImmutableSet.of("192.168.2.5"))
- .providerId("1").backendStatus(ACTIVE.name()).operatingSystem(getOnlyElement(images).getOperatingSystem())
- .build();
-
- NodeMetadata actual = function.apply(droplet);
- assertNodeEquals(actual, expected);
- }
-
- @Test
- public void testConvertDropletOldImage() throws ParseException {
- // Use an image id that is not in the list of images
- Droplet droplet = new Droplet(1, "mock-droplet", 9999, 1, 1, false, ImmutableList.of(), ImmutableList.of(),
- "84.45.69.3", "192.168.2.5", false, ACTIVE, new Date());
-
- NodeMetadata expected = new NodeMetadataBuilder().ids("1").hardware(getOnlyElement(hardwares)).imageId(null)
- .status(RUNNING).location(getOnlyElement(locations)).name("mock-droplet").hostname("mock-droplet")
- .group("mock").credentials(credentials).publicAddresses(ImmutableSet.of("84.45.69.3"))
- .privateAddresses(ImmutableSet.of("192.168.2.5")).providerId("1").backendStatus(ACTIVE.name())
- .operatingSystem(null).build();
-
- NodeMetadata actual = function.apply(droplet);
- assertNodeEquals(actual, expected);
- }
-
- private static void assertNodeEquals(NodeMetadata actual, NodeMetadata expected) {
- assertEquals(actual, expected);
- // NodeMetadata equals method does not use all fields in equals. It assumes that same ids in same locations
- // determine the equivalence
- assertEquals(actual.getStatus(), expected.getStatus());
- assertEquals(actual.getBackendStatus(), expected.getBackendStatus());
- assertEquals(actual.getLoginPort(), expected.getLoginPort());
- assertEquals(actual.getPublicAddresses(), expected.getPublicAddresses());
- assertEquals(actual.getPrivateAddresses(), expected.getPrivateAddresses());
- assertEquals(actual.getCredentials(), expected.getCredentials());
- assertEquals(actual.getGroup(), expected.getGroup());
- assertEquals(actual.getImageId(), expected.getImageId());
- assertEquals(actual.getHardware(), expected.getHardware());
- assertEquals(actual.getOperatingSystem(), expected.getOperatingSystem());
- assertEquals(actual.getHostname(), expected.getHostname());
- }
-
- private DropletToNodeMetadata createNodeParser(final Set<Hardware> hardware, final Set<Image> images,
- final Set<Location> locations, Map<String, Credentials> credentialStore) {
- Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
- @Override
- public Set<? extends Location> get() {
- return locations;
- }
- };
-
- Supplier<Map<String, ? extends Hardware>> hardwareSupplier = new Supplier<Map<String, ? extends Hardware>>() {
- @Override
- public Map<String, ? extends Hardware> get() {
- return Maps.uniqueIndex(hardware, new Function<Hardware, String>() {
- @Override
- public String apply(Hardware input) {
- return input.getId();
- }
- });
- }
- };
-
- Supplier<Map<String, ? extends Image>> imageSupplier = new Supplier<Map<String, ? extends Image>>() {
- @Override
- public Map<String, ? extends Image> get() {
- return Maps.uniqueIndex(images, new Function<Image, String>() {
- @Override
- public String apply(Image input) {
- return input.getId();
- }
- });
- }
- };
-
- GroupNamingConvention.Factory namingConvention = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- Names.bindProperties(binder(), new DigitalOceanApiMetadata().getDefaultProperties());
- }
- }).getInstance(GroupNamingConvention.Factory.class);
-
- return new DropletToNodeMetadata(imageSupplier, hardwareSupplier, locationSupplier, new DropletStatusToStatus(),
- namingConvention, credentialStore);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/ImageToImageTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/ImageToImageTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/ImageToImageTest.java
deleted file mode 100644
index 0c00b57..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/ImageToImageTest.java
+++ /dev/null
@@ -1,58 +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.digitalocean.compute.functions;
-
-import static org.jclouds.compute.domain.Image.Status.AVAILABLE;
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.digitalocean.domain.Image;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Unit tests for the {@link ImageToImage} class.
- */
-@Test(groups = "unit", testName = "ImageToImageTest")
-public class ImageToImageTest {
-
- @Test
- public void testConvertImage() {
- Image image = new Image(1, "14.04 x64", "Ubuntu", true, "ubuntu-1404-x86", ImmutableList.<Integer> of(),
- ImmutableList.<String> of());
- org.jclouds.compute.domain.Image expected = new ImageBuilder()
- .id("ubuntu-1404-x86")
- .providerId("1")
- .name("14.04 x64")
- .description("Ubuntu 14.04 x64")
- .status(AVAILABLE)
- .operatingSystem(
- OperatingSystem.builder().name("Ubuntu").description("Ubuntu 14.04 x64").family(OsFamily.UBUNTU)
- .version("14.04").arch("x64").is64Bit(true).build())
- .userMetadata(ImmutableMap.of("publicImage", "true")).build();
-
- org.jclouds.compute.domain.Image result = new ImageToImage().apply(image);
- assertEquals(result, expected);
- assertEquals(result.getDescription(), expected.getDescription());
- assertEquals(result.getOperatingSystem(), expected.getOperatingSystem());
- assertEquals(result.getStatus(), expected.getStatus());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/RegionToLocationTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/RegionToLocationTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/RegionToLocationTest.java
deleted file mode 100644
index 17a3fb3..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/RegionToLocationTest.java
+++ /dev/null
@@ -1,54 +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.digitalocean.compute.functions;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.digitalocean.DigitalOceanProviderMetadata;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.location.suppliers.all.JustProvider;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Unit tests for the {@link RegionToLocation} class.
- */
-@Test(groups = "unit", testName = "RegionToLocationTest")
-public class RegionToLocationTest {
-
- @Test
- public void testConvertRegion() {
- DigitalOceanProviderMetadata metadata = new DigitalOceanProviderMetadata();
- JustProvider locationsSupplier = new JustProvider(metadata.getId(), Suppliers.<URI> ofInstance(URI
- .create(metadata.getEndpoint())), ImmutableSet.<String> of());
-
- Region region = new Region(1, "Region 1", "reg1");
- Location expected = new LocationBuilder().id("reg1").description("1/Region 1")
- .parent(getOnlyElement(locationsSupplier.get())).scope(LocationScope.REGION).build();
-
- RegionToLocation function = new RegionToLocation(locationsSupplier);
- assertEquals(function.apply(region), expected);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/SizeToHardwareTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/SizeToHardwareTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/SizeToHardwareTest.java
deleted file mode 100644
index eaf9a45..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/SizeToHardwareTest.java
+++ /dev/null
@@ -1,48 +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.digitalocean.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume.Type;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.digitalocean.domain.Size;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Unit tests for the {@link SizeToHardware} class.
- */
-@Test(groups = "unit", testName = "SizeToHardwareTest")
-public class SizeToHardwareTest {
-
- @Test
- public void testConvertSize() {
- Size size = new Size(1, "Medium", "2gb", 2048, 1, 20, "0.05", "10");
- Hardware expected = new HardwareBuilder().id("2gb").providerId("1").name("Medium")
- .processor(new Processor(1.0, 1.0)).ram(2048)
- .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build())
- .userMetadata(ImmutableMap.of("costPerHour", "0.05", "costPerMonth", "10")).build();
-
- SizeToHardware function = new SizeToHardware();
- assertEquals(function.apply(size), expected);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKeyTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKeyTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKeyTest.java
deleted file mode 100644
index 20e6714..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/functions/TemplateOptionsToStatementWithoutPublicKeyTest.java
+++ /dev/null
@@ -1,75 +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.digitalocean.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.scriptbuilder.domain.Statement;
-import org.jclouds.scriptbuilder.domain.StatementList;
-import org.jclouds.scriptbuilder.statements.ssh.InstallRSAPrivateKey;
-import org.jclouds.ssh.SshKeys;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link TemplateOptionsToStatementWithoutPublicKey} class.
- */
-@Test(groups = "unit", testName = "TemplateOptionsToStatementWithoutPublicKeyTest")
-public class TemplateOptionsToStatementWithoutPublicKeyTest {
-
- @Test
- public void testPublicKeyDoesNotGenerateAuthorizePublicKeyStatementIfOnlyPublicKeyOptionsConfigured() {
- Map<String, String> keys = SshKeys.generate();
- TemplateOptions options = TemplateOptions.Builder.authorizePublicKey(keys.get("public"));
-
- TemplateOptionsToStatementWithoutPublicKey function = new TemplateOptionsToStatementWithoutPublicKey();
- assertNull(function.apply(options));
- }
-
- @Test
- public void testPublicAndRunScriptKeyDoesNotGenerateAuthorizePublicKeyStatementIfRunScriptPresent() {
- Map<String, String> keys = SshKeys.generate();
- TemplateOptions options = TemplateOptions.Builder.authorizePublicKey(keys.get("public")).runScript("uptime");
-
- TemplateOptionsToStatementWithoutPublicKey function = new TemplateOptionsToStatementWithoutPublicKey();
- Statement statement = function.apply(options);
-
- assertEquals(statement.render(OsFamily.UNIX), "uptime\n");
- }
-
- @Test
- public void testPublicAndPrivateKeyAndRunScriptDoesNotGenerateAuthorizePublicKeyStatementIfOtherOptionsPresent() {
- Map<String, String> keys = SshKeys.generate();
- TemplateOptions options = TemplateOptions.Builder.authorizePublicKey(keys.get("public"))
- .installPrivateKey(keys.get("private")).runScript("uptime");
-
- TemplateOptionsToStatementWithoutPublicKey function = new TemplateOptionsToStatementWithoutPublicKey();
- Statement statement = function.apply(options);
-
- assertTrue(statement instanceof StatementList);
- StatementList statements = (StatementList) statement;
-
- assertEquals(statements.size(), 2);
- assertEquals(statements.get(0).render(OsFamily.UNIX), "uptime\n");
- assertTrue(statements.get(1) instanceof InstallRSAPrivateKey);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptionsTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptionsTest.java
deleted file mode 100644
index de60c5e..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/options/DigitalOceanTemplateOptionsTest.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.digitalocean.compute.options;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.compute.options.TemplateOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Unit tests for the {@link DigitalOceanTemplateOptions} class.
- */
-@Test(groups = "unit", testName = "DigitalOceanTemplateOptionsTest")
-public class DigitalOceanTemplateOptionsTest {
-
- @Test
- public void testSShKeyIds() {
- TemplateOptions options = new DigitalOceanTemplateOptions().sshKeyIds(ImmutableSet.of(1, 2, 3));
- assertEquals(options.as(DigitalOceanTemplateOptions.class).getSshKeyIds(), ImmutableSet.of(1, 2, 3));
- }
-
- @Test
- public void testPrivateNetworking() {
- TemplateOptions options = new DigitalOceanTemplateOptions().privateNetworking(true);
- assertEquals(options.as(DigitalOceanTemplateOptions.class).getPrivateNetworking(), Boolean.TRUE);
- }
-
- @Test
- public void testBackupsEnabled() {
- TemplateOptions options = new DigitalOceanTemplateOptions().backupsEnabled(true);
- assertEquals(options.as(DigitalOceanTemplateOptions.class).getBackupsEnabled(), Boolean.TRUE);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java
deleted file mode 100644
index 9f9a0b1..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.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.digitalocean.compute.util;
-
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.encodeRegionIdAndName;
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.extractRegionId;
-import static org.jclouds.digitalocean.compute.util.LocationNamingUtils.extractRegionName;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link LocationNamingUtils} class.
- */
-@Test(groups = "unit", testName = "LocationNamingUtilsTest")
-public class LocationNamingUtilsTest {
-
- @Test
- public void testExtractRegionId() {
- assertEquals(1, extractRegionId(location("1/foo")));
- assertEquals(1, extractRegionId(location("1///foo")));
- assertEquals(1, extractRegionId(location("1/2/3/foo")));
- }
-
- @Test
- public void testExtractRegionIdInvalidEncodedForms() {
- assertInvalidRegionIdFormat("/");
- assertInvalidRegionIdFormat("/foo");
- assertInvalidRegionIdFormat("/1/2/foo");
- }
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "location cannot be null")
- public void testExtractRegionIdNullLocation() {
- extractRegionId(null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName' but was: foobar")
- public void testExtractRegionIdWithoutEncodedForm() {
- extractRegionId(location("foobar"));
- }
-
- @Test
- public void testExtractRegionName() {
- assertEquals("foo", extractRegionName(location("1/foo")));
- assertEquals("//foo", extractRegionName(location("1///foo")));
- assertEquals("2/3/foo", extractRegionName(location("1/2/3/foo")));
- }
-
- @Test
- public void testExtractRegionNameInvalidEncodedForms() {
- assertEquals("", extractRegionName(location("/")));
- assertEquals("foo", extractRegionName(location("/foo")));
- assertEquals("1/2/foo", extractRegionName(location("/1/2/foo")));
- }
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "location cannot be null")
- public void testExtractRegionNameNullLocation() {
- extractRegionId(null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName' but was: foobar")
- public void testExtractRegionNameWithoutEncodedForm() {
- extractRegionId(location("foobar"));
- }
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "region cannot be null")
- public void testEncodeRegionAndNameNullRegion() {
- encodeRegionIdAndName(null);
- }
-
- @Test
- public void testEncodeRegionAndName() {
- assertEquals("1/foo", encodeRegionIdAndName(new Region(1, "foo", "bar")));
- assertEquals("1/1", encodeRegionIdAndName(new Region(1, "1", "1")));
- assertEquals("1///", encodeRegionIdAndName(new Region(1, "//", "1")));
- }
-
- private static void assertInvalidRegionIdFormat(String encoded) {
- try {
- extractRegionId(location(encoded));
- fail("Encoded form [" + encoded + "] shouldn't produce a valid region id");
- } catch (NumberFormatException ex) {
- // Success
- }
- }
-
- private static Location location(String description) {
- return new LocationBuilder().id("location").description(description).scope(LocationScope.REGION).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/domain/OperatingSystemTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/domain/OperatingSystemTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/domain/OperatingSystemTest.java
deleted file mode 100644
index fcd33ad..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/domain/OperatingSystemTest.java
+++ /dev/null
@@ -1,107 +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.digitalocean.domain;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link OperatingSystem} class.
- */
-@Test(groups = "unit", testName = "OperatingSystemTest")
-public class OperatingSystemTest {
-
- public void testParseStandard64bit() {
- OperatingSystem os = OperatingSystem.builder().from("12.10 x64", "Ubuntu").build();
-
- assertEquals(os.getDistribution(), Distribution.UBUNTU);
- assertEquals(os.getVersion(), "12.10");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-
- public void testLongVersionStandard64bit() {
- OperatingSystem os = OperatingSystem.builder().from("12.10.1 x64", "Ubuntu").build();
-
- assertEquals(os.getDistribution(), Distribution.UBUNTU);
- assertEquals(os.getVersion(), "12.10.1");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-
- public void testParseStandard64bitWithPrefix() {
- OperatingSystem os = OperatingSystem.builder().from("Arch Linux 12.10 x64 Desktop", "Arch Linux").build();
-
- assertEquals(os.getDistribution(), Distribution.ARCHLINUX);
- assertEquals(os.getVersion(), "12.10");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-
- public void testParseStandard() {
- OperatingSystem os = OperatingSystem.builder().from("12.10 x32", "Ubuntu").build();
-
- assertEquals(os.getDistribution(), Distribution.UBUNTU);
- assertEquals(os.getVersion(), "12.10");
- assertEquals(os.getArch(), "x32");
- assertFalse(os.is64bit());
-
- os = OperatingSystem.builder().from("6.5 x64", "CentOS").build();
-
- assertEquals(os.getDistribution(), Distribution.CENTOS);
- assertEquals(os.getVersion(), "6.5");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
-
- os = OperatingSystem.builder().from("6.5 x64", "Centos").build();
-
- assertEquals(os.getDistribution(), Distribution.CENTOS);
- assertEquals(os.getVersion(), "6.5");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-
- public void testParseNoArch() {
- OperatingSystem os = OperatingSystem.builder().from("12.10", "Ubuntu").build();
-
- assertEquals(os.getDistribution(), Distribution.UBUNTU);
- assertEquals(os.getVersion(), "12.10");
- assertEquals(os.getArch(), "");
- assertFalse(os.is64bit());
- }
-
- public void testParseNoVersion() {
- OperatingSystem os = OperatingSystem.builder().from("x64", "Ubuntu").build();
-
- assertEquals(os.getDistribution(), Distribution.UBUNTU);
- assertEquals(os.getVersion(), "");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-
- public void testParseUnknownDistribution() {
- OperatingSystem os = OperatingSystem.builder().from("12.04 x64", "Foo").build();
-
- assertEquals(os.getDistribution(), Distribution.UNRECOGNIZED);
- assertEquals(os.getVersion(), "12.04");
- assertEquals(os.getArch(), "x64");
- assertTrue(os.is64bit());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiLiveTest.java
deleted file mode 100644
index e1f1cf7..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiLiveTest.java
+++ /dev/null
@@ -1,205 +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.digitalocean.features;
-
-import static com.google.common.collect.Iterables.tryFind;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-
-/**
- * Live tests for the {@link DropletApi} class.
- */
-@Test(groups = "live", testName = "DropletApiLiveTest")
-public class DropletApiLiveTest extends BaseDigitalOceanLiveTest {
-
- private DropletCreation dropletCreation;
- private DropletCreation dropletCreationUsingSlugs;
- private Droplet droplet;
- private Droplet dropletUsingSlugs;
- private Image snapshot;
-
- @Override
- protected void initialize() {
- super.initialize();
- initializeImageSizeAndRegion();
- }
-
- @AfterClass
- public void cleanup() {
- if (droplet != null) {
- int event = api.getDropletApi().destroy(droplet.getId(), true);
- assertTrue(event > 0, "The event id should not be null");
- }
- if (dropletUsingSlugs != null) {
- int event = api.getDropletApi().destroy(dropletUsingSlugs.getId(), true);
- assertTrue(event > 0, "The event id should not be null");
- }
- if (snapshot != null) {
- api.getImageApi().delete(snapshot.getId());
- }
- }
-
- public void testCreateDroplet() {
- dropletCreation = api.getDropletApi().create("droplettest", defaultImage.getId(), defaultSize.getId(),
- defaultRegion.getId());
-
- assertTrue(dropletCreation.getId() > 0, "Created droplet id should be > 0");
- assertTrue(dropletCreation.getEventId() > 0, "Droplet creation event id should be > 0");
- }
-
- public void testCreateDropletUsingSlugs() {
- dropletCreationUsingSlugs = api.getDropletApi().create("droplettestwithslugs", defaultImage.getSlug(),
- defaultSize.getSlug(), defaultRegion.getSlug());
-
- assertTrue(dropletCreationUsingSlugs.getId() > 0, "Created droplet id should be > 0");
- assertTrue(dropletCreationUsingSlugs.getEventId() > 0, "Droplet creation event id should be > 0");
- }
-
- @Test(dependsOnMethods = { "testCreateDroplet", "testCreateDropletUsingSlugs" })
- public void testGetDroplet() {
- waitForEvent(dropletCreation.getEventId());
- waitForEvent(dropletCreationUsingSlugs.getEventId());
-
- droplet = api.getDropletApi().get(dropletCreation.getId());
- dropletUsingSlugs = api.getDropletApi().get(dropletCreationUsingSlugs.getId());
-
- assertNotNull(droplet, "Created droplet should not be null");
- assertNotNull(dropletUsingSlugs, "Created droplet using slugs should not be null");
- }
-
- @Test(dependsOnMethods = "testGetDroplet")
- public void testListDroplets() {
- List<Droplet> droplets = api.getDropletApi().list();
-
- assertFalse(droplets.isEmpty(), "Droplet list should not be empty");
- }
-
- @Test(dependsOnMethods = "testGetDroplet")
- public void testPowerOffDroplet() {
- int event = api.getDropletApi().powerOff(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testPowerOffDroplet")
- public void testPowerOnDroplet() {
- int event = api.getDropletApi().powerOn(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testPowerOnDroplet")
- public void testRebootDroplet() {
- int event = api.getDropletApi().reboot(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testRebootDroplet")
- public void testPowerCycleDroplet() {
- int event = api.getDropletApi().powerCycle(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testPowerCycleDroplet")
- public void testResetPasswordForDroplet() {
- int event = api.getDropletApi().resetPassword(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testResetPasswordForDroplet")
- public void testRenameDroplet() {
- int event = api.getDropletApi().rename(droplet.getId(), "droplettestupdated");
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- droplet = api.getDropletApi().get(droplet.getId());
- assertEquals(droplet.getName(), "droplettestupdated", "The renamed droplet should have the new name");
- }
-
- @Test(dependsOnMethods = "testRenameDroplet")
- public void testRebuildDroplet() {
- int event = api.getDropletApi().rebuild(droplet.getId(), defaultImage.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testRebuildDroplet")
- public void testRestoreDroplet() {
- int event = api.getDropletApi().restore(droplet.getId(), defaultImage.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-
- @Test(dependsOnMethods = "testRestoreDroplet")
- public void testSnapshotDroplet() {
- // Snapshot requires the droplet to be powered off
- int powerOffEvent = api.getDropletApi().powerOff(droplet.getId());
- assertTrue(powerOffEvent > 0, "The event id should be > 0");
- waitForEvent(powerOffEvent);
-
- int event = api.getDropletApi().snapshot(droplet.getId(), "testsnapshot");
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
-
- Optional<Image> snapshot = tryFind(api.getImageApi().list(), new Predicate<Image>() {
- @Override
- public boolean apply(Image input) {
- return input.getName().equals("testsnapshot");
- }
- });
-
- assertTrue(snapshot.isPresent(), "The created snapshot should exist in the image list");
- this.snapshot = snapshot.get();
- }
-
- @Test(dependsOnMethods = "testSnapshotDroplet")
- public void testResizeDroplet() {
- // Resize requires the droplet to be powered off
- int powerOffEvent = api.getDropletApi().powerOff(droplet.getId());
- assertTrue(powerOffEvent > 0, "The event id should be > 0");
- waitForEvent(powerOffEvent);
-
- Size newSize = sizes.get(1);
- int resizeEvent = api.getDropletApi().resize(droplet.getId(), newSize.getId());
- assertTrue(resizeEvent > 0, "The event id should be > 0");
- waitForEvent(resizeEvent);
- }
-
- @Test(dependsOnMethods = "testResizeDroplet")
- public void testShutdownDroplet() {
- int event = api.getDropletApi().shutdown(droplet.getId());
- assertTrue(event > 0, "The event id should be > 0");
- waitForEvent(event);
- }
-}
[4/5] jclouds-labs git commit: Remove DigitalOcean v1
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanHttpApiModule.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanHttpApiModule.java b/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanHttpApiModule.java
deleted file mode 100644
index 3657198..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanHttpApiModule.java
+++ /dev/null
@@ -1,65 +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.digitalocean.config;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.handlers.DigitalOceanErrorHandler;
-import org.jclouds.digitalocean.http.ResponseStatusFromPayloadHttpCommandExecutorService;
-import org.jclouds.digitalocean.strategy.ListSshKeys;
-import org.jclouds.http.HttpCommandExecutorService;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
-import org.jclouds.http.config.SSLModule;
-import org.jclouds.rest.ConfiguresHttpApi;
-import org.jclouds.rest.config.HttpApiModule;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-
-/**
- * Configures the DigitalOcean connection.
- */
-@ConfiguresHttpApi
-public class DigitalOceanHttpApiModule extends HttpApiModule<DigitalOceanApi> {
-
- @Override
- protected void configure() {
- super.configure();
- install(new FactoryModuleBuilder().build(ListSshKeys.Factory.class));
- }
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(DigitalOceanErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(DigitalOceanErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(DigitalOceanErrorHandler.class);
- }
-
- @ConfiguresHttpCommandExecutorService
- public static class DigitalOceanHttpCommandExecutorServiceModule extends AbstractModule {
- @Override
- protected void configure() {
- install(new SSLModule());
- bind(HttpCommandExecutorService.class).to(ResponseStatusFromPayloadHttpCommandExecutorService.class).in(
- Scopes.SINGLETON);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanParserModule.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanParserModule.java b/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanParserModule.java
deleted file mode 100644
index 9170c8e..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/config/DigitalOceanParserModule.java
+++ /dev/null
@@ -1,141 +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.digitalocean.config;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
-import static com.google.common.collect.Iterables.get;
-import static com.google.common.collect.Iterables.size;
-import static com.google.inject.Scopes.SINGLETON;
-
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.DSAPublicKeySpec;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.RSAPublicKeySpec;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.digitalocean.ssh.DSAKeys;
-import org.jclouds.json.config.GsonModule.DateAdapter;
-import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-import org.jclouds.ssh.SshKeys;
-
-import com.google.common.base.Function;
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-
-/**
- * Custom parser bindings.
- */
-public class DigitalOceanParserModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(Iso8601DateAdapter.class).in(SINGLETON);
- }
-
- @Singleton
- public static class SshPublicKeyAdapter extends TypeAdapter<PublicKey> {
-
- private final Function<PublicKey, String> publicKeyToSshKey;
- private final Function<String, PublicKey> sshKeyToPublicKey;
-
- @Inject
- public SshPublicKeyAdapter(Function<PublicKey, String> publicKeyToSshKey,
- Function<String, PublicKey> sshKeyToPublicKey) {
- this.publicKeyToSshKey = checkNotNull(publicKeyToSshKey, "publicKeyToSshKey cannot be null");
- this.sshKeyToPublicKey = checkNotNull(sshKeyToPublicKey, "sshKeyToPublicKey cannot be null");
- }
-
- @Override
- public void write(JsonWriter out, PublicKey value) throws IOException {
- out.value(publicKeyToSshKey.apply(value));
- }
-
- @Override
- public PublicKey read(JsonReader in) throws IOException {
- return sshKeyToPublicKey.apply(in.nextString().trim());
- }
- }
-
- @Provides
- @Singleton
- public Function<PublicKey, String> publicKeyToSshKey() {
- return new Function<PublicKey, String>() {
- @Override
- public String apply(PublicKey input) {
- if (input instanceof RSAPublicKey) {
- return SshKeys.encodeAsOpenSSH((RSAPublicKey) input);
- } else if (input instanceof DSAPublicKey) {
- return DSAKeys.encodeAsOpenSSH((DSAPublicKey) input);
- } else {
- throw new IllegalArgumentException("Only RSA and DSA keys are supported");
- }
- }
- };
- }
-
- @Provides
- @Singleton
- public Function<String, PublicKey> sshKeyToPublicKey() {
- return new Function<String, PublicKey>() {
- @Override
- public PublicKey apply(String input) {
- Iterable<String> parts = Splitter.on(' ').split(input);
- checkArgument(size(parts) >= 2, "bad format, should be: [ssh-rsa|ssh-dss] AAAAB3...");
- String type = get(parts, 0);
-
- try {
- if ("ssh-rsa".equals(type)) {
- RSAPublicKeySpec spec = SshKeys.publicKeySpecFromOpenSSH(input);
- return KeyFactory.getInstance("RSA").generatePublic(spec);
- } else if ("ssh-dss".equals(type)) {
- DSAPublicKeySpec spec = DSAKeys.publicKeySpecFromOpenSSH(input);
- return KeyFactory.getInstance("DSA").generatePublic(spec);
- } else {
- throw new IllegalArgumentException("bad format, should be: [ssh-rsa|ssh-dss] AAAAB3...");
- }
- } catch (InvalidKeySpecException ex) {
- throw propagate(ex);
- } catch (NoSuchAlgorithmException ex) {
- throw propagate(ex);
- }
- }
- };
- }
-
- @Provides
- @Singleton
- public Map<Type, Object> provideCustomAdapterBindings(SshPublicKeyAdapter sshPublicKeyAdapter) {
- return ImmutableMap.<Type, Object> of(PublicKey.class, sshPublicKeyAdapter);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/BaseResponse.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/BaseResponse.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/BaseResponse.java
deleted file mode 100644
index 8f7915e..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/BaseResponse.java
+++ /dev/null
@@ -1,118 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Enums;
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.inject.name.Named;
-
-/**
- * Information of an error.
- */
-public class BaseResponse {
-
- public static enum Status {
- OK, ERROR;
-
- public static Status fromValue(String value) {
- Optional<Status> status = Enums.getIfPresent(Status.class, value.toUpperCase());
- checkArgument(status.isPresent(), "Expected one of %s but was %s", Joiner.on(',').join(Status.values()), value);
- return status.get();
- }
- }
-
- private final Status status;
- @Named("error_message")
- private final String message;
- @Named("message")
- private final String details;
-
- @ConstructorProperties({ "status", "error_message", "message" })
- public BaseResponse(Status status, @Nullable String message, @Nullable String details) {
- this.status = checkNotNull(status, "status cannot be null");
- this.message = message;
- this.details = details;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public String getMessage() {
- return message;
- }
-
- public String getDetails() {
- return details;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (details == null ? 0 : details.hashCode());
- result = prime * result + (message == null ? 0 : message.hashCode());
- result = prime * result + (status == null ? 0 : status.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- BaseResponse other = (BaseResponse) obj;
- if (details == null) {
- if (other.details != null) {
- return false;
- }
- } else if (!details.equals(other.details)) {
- return false;
- }
- if (message == null) {
- if (other.message != null) {
- return false;
- }
- } else if (!message.equals(other.message)) {
- return false;
- }
- if (status != other.status) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "BaseResponse [status=" + status + ", message=" + message + ", details=" + details + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Distribution.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Distribution.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Distribution.java
deleted file mode 100644
index ef107c4..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Distribution.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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.tryFind;
-import static java.util.Arrays.asList;
-
-import java.util.List;
-
-import org.jclouds.compute.domain.OsFamily;
-
-import com.google.common.base.Predicate;
-
-/**
- * DigitalOcean image distributions.
- */
-public enum Distribution {
- ARCHLINUX(OsFamily.ARCH, "Arch Linux"), CENTOS(OsFamily.CENTOS, "CentOS"), DEBIAN(OsFamily.DEBIAN, "Debian"), FEDORA(
- OsFamily.FEDORA, "Fedora"), UBUNTU(OsFamily.UBUNTU, "Ubuntu"), UNRECOGNIZED(OsFamily.UNRECOGNIZED, "");
-
- private static final List<Distribution> values = asList(Distribution.values());
-
- private final OsFamily osFamily;
- private final String value;
-
- private Distribution(OsFamily osFamily, String value) {
- this.osFamily = checkNotNull(osFamily, "osFamily cannot be null");
- this.value = checkNotNull(value, "value cannot be null");
- }
-
- public OsFamily getOsFamily() {
- return this.osFamily;
- }
-
- public String getValue() {
- return value;
- }
-
- public static Distribution fromValue(String value) {
- return tryFind(values, hasValue(value)).or(UNRECOGNIZED);
- }
-
- private static Predicate<Distribution> hasValue(final String value) {
- return new Predicate<Distribution>() {
- @Override
- public boolean apply(Distribution input) {
- return input.value.equalsIgnoreCase(value);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Droplet.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Droplet.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Droplet.java
deleted file mode 100644
index 7fbdb72..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Droplet.java
+++ /dev/null
@@ -1,250 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.List;
-
-import javax.inject.Named;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Enums;
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-
-/**
- * A droplet.
- */
-public class Droplet {
-
- public enum Status {
- NEW, ACTIVE, ARCHIVE, OFF;
-
- public static Status fromValue(String value) {
- Optional<Status> status = Enums.getIfPresent(Status.class, value.toUpperCase());
- checkArgument(status.isPresent(), "Expected one of %s but was %s", Joiner.on(',').join(Status.values()), value);
- return status.get();
- }
- }
-
- private final int id;
- private final String name;
- @Named("image_id")
- private final int imageId;
- @Named("size_id")
- private final int sizeId;
- @Named("region_id")
- private final int regionId;
- @Named("backups_active")
- private final boolean backupsActive;
- private final List<Object> backups;
- private final List<Object> snapshots;
- @Named("ip_address")
- private final String ip;
- @Named("private_ip_address")
- private final String privateIp;
- private final boolean locked;
- private final Status status;
- @Named("created_at")
- private final Date creationDate;
-
- @ConstructorProperties({ "id", "name", "image_id", "size_id", "region_id", "backups_active", "backups", "snapshots",
- "ip_address", "private_ip_address", "locked", "status", "created_at" })
- public Droplet(int id, String name, int imageId, int sizeId, int regionId, boolean backupsActive,
- @Nullable List<Object> backups, @Nullable List<Object> snapshots, String ip, @Nullable String privateIp,
- boolean locked, Status status, @Nullable Date creationDate) throws ParseException {
- this.id = id;
- this.name = checkNotNull(name, "name cannot be null");
- this.imageId = imageId;
- this.sizeId = sizeId;
- this.regionId = regionId;
- this.backupsActive = backupsActive;
- this.backups = backups != null ? ImmutableList.copyOf(backups) : ImmutableList.of();
- this.snapshots = snapshots != null ? ImmutableList.copyOf(snapshots) : ImmutableList.of();
- this.ip = ip;
- this.privateIp = privateIp;
- this.locked = locked;
- this.status = checkNotNull(status, "status cannot be null");
- this.creationDate = creationDate;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public int getImageId() {
- return imageId;
- }
-
- public int getSizeId() {
- return sizeId;
- }
-
- public int getRegionId() {
- return regionId;
- }
-
- public boolean isBackupsActive() {
- return backupsActive;
- }
-
- public List<Object> getBackups() {
- return backups;
- }
-
- public List<Object> getSnapshots() {
- return snapshots;
- }
-
- public String getIp() {
- return ip;
- }
-
- public String getPrivateIp() {
- return privateIp;
- }
-
- public boolean isLocked() {
- return locked;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public Date getCreationDate() {
- return creationDate;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (backups == null ? 0 : backups.hashCode());
- result = prime * result + (backupsActive ? 1231 : 1237);
- result = prime * result + (creationDate == null ? 0 : creationDate.hashCode());
- result = prime * result + id;
- result = prime * result + imageId;
- result = prime * result + (ip == null ? 0 : ip.hashCode());
- result = prime * result + (locked ? 1231 : 1237);
- result = prime * result + (name == null ? 0 : name.hashCode());
- result = prime * result + (privateIp == null ? 0 : privateIp.hashCode());
- result = prime * result + regionId;
- result = prime * result + sizeId;
- result = prime * result + (snapshots == null ? 0 : snapshots.hashCode());
- result = prime * result + (status == null ? 0 : status.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Droplet other = (Droplet) obj;
- if (backups == null) {
- if (other.backups != null) {
- return false;
- }
- } else if (!backups.equals(other.backups)) {
- return false;
- }
- if (backupsActive != other.backupsActive) {
- return false;
- }
- if (creationDate == null) {
- if (other.creationDate != null) {
- return false;
- }
- } else if (!creationDate.equals(other.creationDate)) {
- return false;
- }
- if (id != other.id) {
- return false;
- }
- if (imageId != other.imageId) {
- return false;
- }
- if (ip == null) {
- if (other.ip != null) {
- return false;
- }
- } else if (!ip.equals(other.ip)) {
- return false;
- }
- if (locked != other.locked) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (privateIp == null) {
- if (other.privateIp != null) {
- return false;
- }
- } else if (!privateIp.equals(other.privateIp)) {
- return false;
- }
- if (regionId != other.regionId) {
- return false;
- }
- if (sizeId != other.sizeId) {
- return false;
- }
- if (snapshots == null) {
- if (other.snapshots != null) {
- return false;
- }
- } else if (!snapshots.equals(other.snapshots)) {
- return false;
- }
- if (status != other.status) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "Droplet [id=" + id + ", name=" + name + ", imageId=" + imageId + ", sizeId=" + sizeId + ", regionId="
- + regionId + ", backupsActive=" + backupsActive + ", backups=" + backups + ", snapshots=" + snapshots
- + ", ip=" + ip + ", privateIp=" + privateIp + ", locked=" + locked + ", status=" + status
- + ", creationDate=" + creationDate + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/DropletCreation.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/DropletCreation.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/DropletCreation.java
deleted file mode 100644
index d7793c8..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/DropletCreation.java
+++ /dev/null
@@ -1,120 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-
-import com.google.inject.name.Named;
-
-/**
- * An DropletCreation response.
- */
-public class DropletCreation {
-
- private final int id;
- private final String name;
- @Named("image_id")
- private final int imageId;
- @Named("size_id")
- private final int sizeId;
- @Named("event_id")
- private final int eventId;
-
- @ConstructorProperties({ "id", "name", "image_id", "size_id", "event_id" })
- public DropletCreation(int id, String name, int imageId, int sizeId, int eventId) {
- this.id = id;
- this.name = checkNotNull(name, "name cannot be null");
- this.imageId = imageId;
- this.sizeId = sizeId;
- this.eventId = eventId;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public int getImageId() {
- return imageId;
- }
-
- public int getSizeId() {
- return sizeId;
- }
-
- public int getEventId() {
- return eventId;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + eventId;
- result = prime * result + id;
- result = prime * result + imageId;
- result = prime * result + (name == null ? 0 : name.hashCode());
- result = prime * result + sizeId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- DropletCreation other = (DropletCreation) obj;
- if (eventId != other.eventId) {
- return false;
- }
- if (id != other.id) {
- return false;
- }
- if (imageId != other.imageId) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (sizeId != other.sizeId) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "DropletCreation [id=" + id + ", name=" + name + ", imageId=" + imageId + ", sizeId=" + sizeId
- + ", eventId=" + eventId + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Event.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Event.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Event.java
deleted file mode 100644
index 607e320..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Event.java
+++ /dev/null
@@ -1,141 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.primitives.Ints.tryParse;
-
-import java.beans.ConstructorProperties;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Enums;
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.inject.name.Named;
-
-/**
- * An Event.
- */
-public class Event {
-
- public enum Status {
- DONE, PENDING, ERROR;
-
- public static Status fromValue(String value) {
- // DigitalOcean return a 'null' status when the operation is still in
- // progress
- if (value == null) {
- return PENDING;
- }
- Optional<Status> status = Enums.getIfPresent(Status.class, value.toUpperCase());
- checkArgument(status.isPresent(), "Expected one of %s but was", Joiner.on(',').join(Status.values()), value);
- return status.get();
- }
- }
-
- private final int id;
- @Named("action_status")
- private final Status status;
- @Named("event_type_id")
- private final int typeId;
- private final Integer percentage;
- @Named("droplet_id")
- private final int dropletId;
-
- @ConstructorProperties({ "id", "action_status", "event_type_id", "percentage", "droplet_id" })
- public Event(int id, @Nullable Status status, int typeId, @Nullable String percentage, int dropletId) {
- this.id = id;
- this.status = status == null ? Status.PENDING : status;
- this.typeId = typeId;
- this.percentage = percentage == null ? null : tryParse(percentage);
- this.dropletId = dropletId;
- }
-
- public int getId() {
- return id;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public int getTypeId() {
- return typeId;
- }
-
- public Integer getPercentage() {
- return percentage;
- }
-
- public int getDropletId() {
- return dropletId;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + dropletId;
- result = prime * result + id;
- result = prime * result + (percentage == null ? 0 : percentage.hashCode());
- result = prime * result + (status == null ? 0 : status.hashCode());
- result = prime * result + typeId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Event other = (Event) obj;
- if (dropletId != other.dropletId) {
- return false;
- }
- if (id != other.id) {
- return false;
- }
- if (percentage == null) {
- if (other.percentage != null) {
- return false;
- }
- } else if (!percentage.equals(other.percentage)) {
- return false;
- }
- if (status != other.status) {
- return false;
- }
- if (typeId != other.typeId) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "Event [id=" + id + ", status=" + status + ", typeId=" + typeId + ", percentage=" + percentage
- + ", dropletId=" + dropletId + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Image.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Image.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Image.java
deleted file mode 100644
index 1ce92c2..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Image.java
+++ /dev/null
@@ -1,160 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.util.List;
-
-import javax.inject.Named;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * An Image.
- */
-public class Image {
- private final int id;
- private final String name;
- private final OperatingSystem os;
- private final boolean publicImage;
- private final String slug;
- @Named("regions")
- private final List<Integer> regionIds;
- @Named("region_slugs")
- private final List<String> regionSlugs;
-
- @ConstructorProperties({ "id", "name", "distribution", "public", "slug", "regions", "region_slugs" })
- public Image(int id, String name, String distribution, boolean publicImage, @Nullable String slug,
- List<Integer> regionIds, List<String> regionSlugs) {
- this.id = id;
- this.name = checkNotNull(name, "name");
- this.os = OperatingSystem.builder().from(name, checkNotNull(distribution, "distribution")).build();
- this.publicImage = publicImage;
- this.slug = slug;
- this.regionIds = ImmutableList.copyOf(checkNotNull(regionIds, "regionIds"));
- this.regionSlugs = ImmutableList.copyOf(checkNotNull(regionSlugs, "regionSlugs"));
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public OperatingSystem getOs() {
- return os;
- }
-
- public boolean isPublicImage() {
- return publicImage;
- }
-
- public String getSlug() {
- return slug;
- }
-
- public List<Integer> getRegionIds() {
- return regionIds;
- }
-
- public List<String> getRegionSlugs() {
- return regionSlugs;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- result = prime * result + (name == null ? 0 : name.hashCode());
- result = prime * result + (os == null ? 0 : os.hashCode());
- result = prime * result + (publicImage ? 1231 : 1237);
- result = prime * result + (slug == null ? 0 : slug.hashCode());
- result = prime * result + (regionIds == null ? 0 : regionIds.hashCode());
- result = prime * result + (regionSlugs == null ? 0 : regionSlugs.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Image other = (Image) obj;
- if (id != other.id) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (os == null) {
- if (other.os != null) {
- return false;
- }
- } else if (!os.equals(other.os)) {
- return false;
- }
- if (publicImage != other.publicImage) {
- return false;
- }
- if (slug == null) {
- if (other.slug != null) {
- return false;
- }
- } else if (!slug.equals(other.slug)) {
- return false;
- }
- if (regionIds == null) {
- if (other.regionIds != null) {
- return false;
- }
- } else if (!regionIds.equals(other.regionIds)) {
- return false;
- }
- if (regionSlugs == null) {
- if (other.regionSlugs != null) {
- return false;
- }
- } else if (!regionSlugs.equals(other.regionSlugs)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "Image [id=" + id + ", name=" + name + ", os=" + os + ", publicImage=" + publicImage + ", slug=" + slug
- + ", regionIds=" + regionIds + ", regionSlugs=" + regionSlugs + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/OperatingSystem.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/OperatingSystem.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/OperatingSystem.java
deleted file mode 100644
index 09d6267..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/OperatingSystem.java
+++ /dev/null
@@ -1,135 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.nullToEmpty;
-import static java.util.regex.Pattern.compile;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * The operating system of an image.
- * <p>
- * This class parses the <code>name</code> string (e.g. "12.10 x64") of the images and properly sets each field to the
- * right value.
- */
-public class OperatingSystem {
-
- // Parse something like "12.10 x64" or "Ubuntu 12.10.1 x64" and matches the version and architecture
- private static final Pattern VERSION_PATTERN = compile("(?:[a-zA-Z\\s]*\\s+)?(\\d+(?:\\.?\\d+)*)?(?:\\s*(x\\d{2}))?.*");
- private static final String IS_64_BIT = "x64";
-
- private final Distribution distribution;
- private final String version;
- private final String arch;
-
- private OperatingSystem(String distribution, String version, String arch) {
- this.distribution = checkNotNull(Distribution.fromValue(distribution), "distribution cannot be null");
- this.version = checkNotNull(version, "version cannot be null");
- this.arch = checkNotNull(arch, "arch cannot be null");
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getArch() {
- return arch;
- }
-
- public boolean is64bit() {
- return IS_64_BIT.equals(arch);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String name;
- private String distribution;
-
- public Builder from(String name, String distribution) {
- this.name = checkNotNull(name, "name cannot be null");
- this.distribution = checkNotNull(distribution, "distribution cannot be null");
- return this;
- }
-
- public OperatingSystem build() {
- return new OperatingSystem(distribution, match(VERSION_PATTERN, name, 1), match(VERSION_PATTERN, name, 2));
- }
- }
-
- private static String match(final Pattern pattern, final String input, int group) {
- Matcher m = pattern.matcher(input);
- return m.matches() ? nullToEmpty(m.group(group)) : "";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (arch == null ? 0 : arch.hashCode());
- result = prime * result + (distribution == null ? 0 : distribution.hashCode());
- result = prime * result + (version == null ? 0 : version.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- OperatingSystem other = (OperatingSystem) obj;
- if (arch == null) {
- if (other.arch != null) {
- return false;
- }
- } else if (!arch.equals(other.arch)) {
- return false;
- }
- if (distribution != other.distribution) {
- return false;
- }
- if (version == null) {
- if (other.version != null) {
- return false;
- }
- } else if (!version.equals(other.version)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "OperatingSystem [distribution=" + distribution + ", version=" + version + ", arch=" + arch + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Region.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Region.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Region.java
deleted file mode 100644
index 60a374e..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Region.java
+++ /dev/null
@@ -1,98 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-
-/**
- * A Region.
- */
-public class Region {
-
- private final int id;
- private final String name;
- private final String slug;
-
- @ConstructorProperties({ "id", "name", "slug" })
- public Region(int id, String name, String slug) {
- this.id = id;
- this.name = checkNotNull(name, "name cannot be null");
- this.slug = checkNotNull(slug, "slug cannot be null");
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSlug() {
- return slug;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- result = prime * result + (name == null ? 0 : name.hashCode());
- result = prime * result + (slug == null ? 0 : slug.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Region other = (Region) obj;
- if (id != other.id) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (slug == null) {
- if (other.slug != null) {
- return false;
- }
- } else if (!slug.equals(other.slug)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "Region [id=" + id + ", name=" + name + ", slug=" + slug + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Size.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Size.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Size.java
deleted file mode 100644
index 6f4cf9a..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/Size.java
+++ /dev/null
@@ -1,161 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-
-import javax.inject.Named;
-
-/**
- * A Size.
- */
-public class Size {
-
- private final int id;
- private final String name;
- private final String slug;
- private final int memory;
- private final int cpu;
- private final int disk;
- @Named("cost_per_hour")
- private final String costPerHour;
- @Named("cost_per_month")
- private final String costPerMonth;
-
- @ConstructorProperties({ "id", "name", "slug", "memory", "cpu", "disk", "cost_per_hour", "cost_per_month" })
- public Size(int id, String name, String slug, int memory, int cpu, int disk, String costPerHour, String costPerMonth) {
- this.id = id;
- this.name = checkNotNull(name, "name cannot be null");
- this.slug = checkNotNull(slug, "slug");
- this.memory = memory;
- this.cpu = cpu;
- this.disk = disk;
- this.costPerHour = checkNotNull(costPerHour, "costPerHour cannot be null");
- this.costPerMonth = checkNotNull(costPerMonth, "costPerMonth cannot be null");
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSlug() {
- return slug;
- }
-
- public int getMemory() {
- return memory;
- }
-
- public int getCpu() {
- return cpu;
- }
-
- public int getDisk() {
- return disk;
- }
-
- public String getCostPerHour() {
- return costPerHour;
- }
-
- public String getCostPerMonth() {
- return costPerMonth;
- }
-
- @Override
- public int hashCode() {
- int prime = 31;
- int result = 1;
- result = prime * result + (costPerHour == null ? 0 : costPerHour.hashCode());
- result = prime * result + (costPerMonth == null ? 0 : costPerMonth.hashCode());
- result = prime * result + cpu;
- result = prime * result + disk;
- result = prime * result + id;
- result = prime * result + memory;
- result = prime * result + (name == null ? 0 : name.hashCode());
- result = prime * result + (slug == null ? 0 : slug.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Size other = (Size) obj;
- if (costPerHour == null) {
- if (other.costPerHour != null) {
- return false;
- }
- } else if (!costPerHour.equals(other.costPerHour)) {
- return false;
- }
- if (costPerMonth == null) {
- if (other.costPerMonth != null) {
- return false;
- }
- } else if (!costPerMonth.equals(other.costPerMonth)) {
- return false;
- }
- if (cpu != other.cpu) {
- return false;
- }
- if (disk != other.disk) {
- return false;
- }
- if (id != other.id) {
- return false;
- }
- if (memory != other.memory) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (slug == null) {
- if (other.slug != null) {
- return false;
- }
- } else if (!slug.equals(other.slug)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "Size [id=" + id + ", name=" + name + ", slug=" + slug + ", memory=" + memory + ", cpu=" + cpu + ", disk="
- + disk + ", costPerHour=" + costPerHour + ", costPerMonth=" + costPerMonth + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/SshKey.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/SshKey.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/SshKey.java
deleted file mode 100644
index d7b034f..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/SshKey.java
+++ /dev/null
@@ -1,96 +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.digitalocean.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.security.PublicKey;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.inject.name.Named;
-
-/**
- * A SSH Key.
- */
-public class SshKey {
-
- private final int id;
- private final String name;
- @Named("ssh_pub_key")
- private final PublicKey publicKey;
-
- @ConstructorProperties({ "id", "name", "ssh_pub_key" })
- public SshKey(int id, String name, @Nullable PublicKey publicKey) {
- this.id = id;
- this.name = checkNotNull(name, "name cannot be null");
- this.publicKey = publicKey;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public PublicKey getPublicKey() {
- return publicKey;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- result = prime * result + (name == null ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SshKey other = (SshKey) obj;
- if (id != other.id) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "SshKey [id=" + id + ", name=" + name + ", publicKey=" + publicKey + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/domain/options/CreateDropletOptions.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/options/CreateDropletOptions.java b/digitalocean/src/main/java/org/jclouds/digitalocean/domain/options/CreateDropletOptions.java
deleted file mode 100644
index 18c573a..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/domain/options/CreateDropletOptions.java
+++ /dev/null
@@ -1,161 +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.digitalocean.domain.options;
-
-import java.util.Set;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Options to customize droplet creation.
- */
-public class CreateDropletOptions extends BaseHttpRequestOptions {
-
- private final Set<Integer> sshKeyIds;
- private final Boolean privateNetworking;
- private final Boolean backupsEnabled;
-
- public CreateDropletOptions(Set<Integer> sshKeyIds, Boolean privateNetworking, Boolean backupsEnabled) {
- this.sshKeyIds = sshKeyIds;
- this.privateNetworking = privateNetworking;
- this.backupsEnabled = backupsEnabled;
-
- if (!sshKeyIds.isEmpty()) {
- queryParameters.put("ssh_key_ids", Joiner.on(',').join(sshKeyIds));
- }
- if (privateNetworking != null) {
- queryParameters.put("private_networking", privateNetworking.toString());
- }
- if (backupsEnabled != null) {
- queryParameters.put("backups_enabled", backupsEnabled.toString());
- }
- }
-
- public Iterable<Integer> getSshKeyIds() {
- return sshKeyIds;
- }
-
- public Boolean getPrivateNetworking() {
- return privateNetworking;
- }
-
- public Boolean getBackupsEnabled() {
- return backupsEnabled;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + (backupsEnabled == null ? 0 : backupsEnabled.hashCode());
- result = prime * result + (privateNetworking == null ? 0 : privateNetworking.hashCode());
- result = prime * result + (sshKeyIds == null ? 0 : sshKeyIds.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CreateDropletOptions other = (CreateDropletOptions) obj;
- if (backupsEnabled == null) {
- if (other.backupsEnabled != null) {
- return false;
- }
- } else if (!backupsEnabled.equals(other.backupsEnabled)) {
- return false;
- }
- if (privateNetworking == null) {
- if (other.privateNetworking != null) {
- return false;
- }
- } else if (!privateNetworking.equals(other.privateNetworking)) {
- return false;
- }
- if (sshKeyIds == null) {
- if (other.sshKeyIds != null) {
- return false;
- }
- } else if (!sshKeyIds.equals(other.sshKeyIds)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "CreateDropletOptions [sshKeyIds=" + sshKeyIds + ", privateNetworking=" + privateNetworking
- + ", backupsEnabled=" + backupsEnabled + "]";
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private ImmutableSet.Builder<Integer> sshKeyIds = ImmutableSet.builder();
- private Boolean privateNetworking;
- private Boolean backupsEnabled;
-
- /**
- * Adds a set of ssh key ids to be added to the droplet.
- */
- public Builder addSshKeyIds(Iterable<Integer> sshKeyIds) {
- this.sshKeyIds.addAll(sshKeyIds);
- return this;
- }
-
- /**
- * Adds an ssh key id to be added to the droplet.
- */
- public Builder addSshKeyId(int sshKeyId) {
- this.sshKeyIds.add(sshKeyId);
- return this;
- }
-
- /**
- * Enables a private network interface if the region supports private
- * networking.
- */
- public Builder privateNetworking(boolean privateNetworking) {
- this.privateNetworking = privateNetworking;
- return this;
- }
-
- /**
- * Enabled backups for the droplet.
- */
- public Builder backupsEnabled(boolean backupsEnabled) {
- this.backupsEnabled = backupsEnabled;
- return this;
- }
-
- public CreateDropletOptions build() {
- return new CreateDropletOptions(sshKeyIds.build(), privateNetworking, backupsEnabled);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/DropletApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/DropletApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/DropletApi.java
deleted file mode 100644
index d471588..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/DropletApi.java
+++ /dev/null
@@ -1,327 +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.digitalocean.features;
-
-import java.io.Closeable;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.options.CreateDropletOptions;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the Droplet management features.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/droplets")
-public interface DropletApi extends Closeable {
-
- /**
- * Lists all existing droplets.
- *
- * @return The list of all existing droplets.
- */
- @Named("droplet:list")
- @GET
- @SelectJson("droplets")
- List<Droplet> list();
-
- /**
- * Gets the details of the given droplet.
- *
- * @param id The id of the droplet to get.
- * @return The details of the droplet or <code>null</code> if no droplet exists with the given id.
- */
- @Named("droplet:get")
- @GET
- @Path("/{id}")
- @SelectJson("droplet")
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- Droplet get(@PathParam("id") int id);
-
- /**
- * Creates a new droplet.
- *
- * @param name The name for the new droplet.
- * @param imageId The id of the image to use to create the droplet.
- * @param sizeId The size to use to create the droplet.
- * @param regionId The region where the droplet must be created.
- * @return The created droplet.
- *
- * @see #create(String, String, String, String)
- */
- @Named("droplet:create")
- @GET
- @Path("/new")
- @SelectJson("droplet")
- DropletCreation create(@QueryParam("name") String name, @QueryParam("image_id") int imageId,
- @QueryParam("size_id") int sizeId, @QueryParam("region_id") int regionId);
-
- /**
- * Creates a new droplet.
- *
- * @param name The name for the new droplet.
- * @param imageId The id of the image to use to create the droplet.
- * @param sizeId The size to use to create the droplet.
- * @param regionId The region where the droplet must be created.
- * @param options Custom options to create the droplet.
- * @return The created droplet.
- *
- * @see #create(String, String, String, String, CreateDropletOptions)
- */
- @Named("droplet:create")
- @GET
- @Path("/new")
- @SelectJson("droplet")
- DropletCreation create(@QueryParam("name") String name, @QueryParam("image_id") int imageId,
- @QueryParam("size_id") int sizeId, @QueryParam("region_id") int regionId, CreateDropletOptions options);
-
- /**
- * Creates a new droplet.
- *
- * @param name The name for the new droplet.
- * @param imageSlug The slug of the image to use to create the droplet.
- * @param sizeSlug The slug of the size to use to create the droplet.
- * @param regionSlug The slug region where the droplet must be created.
- * @return The created droplet.
- *
- * @see #create(String, int, int, int)
- */
- @Named("droplet:create")
- @GET
- @Path("/new")
- @SelectJson("droplet")
- DropletCreation create(@QueryParam("name") String name, @QueryParam("image_slug") String imageSlug,
- @QueryParam("size_slug") String sizeSlug, @QueryParam("region_slug") String regionSlug);
-
- /**
- * Creates a new droplet.
- *
- * @param name The name for the new droplet.
- * @param imageSlug The slug of the image to use to create the droplet.
- * @param sizeSlug The slug of the size to use to create the droplet.
- * @param regionSlug The slug region where the droplet must be created.
- * @param options Custom options to create the droplet.
- * @return The created droplet.
- *
- * @see #create(String, int, int, int, CreateDropletOptions)
- */
- @Named("droplet:create")
- @GET
- @Path("/new")
- @SelectJson("droplet")
- DropletCreation create(@QueryParam("name") String name, @QueryParam("image_slug") String imageSlug,
- @QueryParam("size_slug") String sizeSlug, @QueryParam("region_slug") String regionSlug,
- CreateDropletOptions options);
-
- /**
- * Reboots the given droplet.
- *
- * @param id The id of the droplet to reboot.
- * @return The id of the event to track the reboot process.
- */
- @Named("droplet:reboot")
- @GET
- @Path("/{id}/reboot")
- @SelectJson("event_id")
- int reboot(@PathParam("id") int id);
-
- /**
- * Power cycles the given droplet.
- *
- * @param id The id of the droplet to power cycle.
- * @return The id of the event to track the power cycle process.
- */
- @Named("droplet:powercycle")
- @GET
- @Path("/{id}/power_cycle")
- @SelectJson("event_id")
- int powerCycle(@PathParam("id") int id);
-
- /**
- * Shuts down the given droplet.
- *
- * @param id The id of the droplet to shutdown.
- * @return The id of the event to track the shutdown process.
- */
- @Named("droplet:shutdown")
- @GET
- @Path("/{id}/shutdown")
- @SelectJson("event_id")
- int shutdown(@PathParam("id") int id);
-
- /**
- * Powers off the given droplet.
- *
- * @param id The id of the droplet to power off.
- * @return The id of the event to track the power off process.
- */
- @Named("droplet:poweroff")
- @GET
- @Path("/{id}/power_off")
- @SelectJson("event_id")
- int powerOff(@PathParam("id") int id);
-
- /**
- * Powers on the given droplet.
- *
- * @param id The id of the droplet to power on.
- * @return The id of the event to track the power on process.
- */
- @Named("droplet:poweron")
- @GET
- @Path("/{id}/power_on")
- @SelectJson("event_id")
- int powerOn(@PathParam("id") int id);
-
- /**
- * Resets the password for the given droplet.
- *
- * @param id The id of the droplet to reset the password to.
- * @return The id of the event to track the password reset process.
- */
- @Named("droplet:resetpassword")
- @GET
- @Path("/{id}/password_reset")
- @SelectJson("event_id")
- int resetPassword(@PathParam("id") int id);
-
- /**
- * Changes the size for the given droplet.
- *
- * @param id The id of the droplet to change the size to.
- * @param sizeId The id of the new size for the droplet.
- * @return The id of the event to track the resize process.
- */
- @Named("droplet:resize")
- @GET
- @Path("/{id}/resize")
- @SelectJson("event_id")
- int resize(@PathParam("id") int id, @QueryParam("size_id") int sizeId);
-
- /**
- * Takes a snapshot of the droplet once it has been powered off.
- *
- * @param id The id of the droplet to take the snapshot of.
- * @return The id of the event to track the snapshot process.
- */
- @Named("droplet:snapshot")
- @GET
- @Path("/{id}/snapshot")
- @SelectJson("event_id")
- int snapshot(@PathParam("id") int id);
-
- /**
- * Takes a snapshot of the droplet once it has been powered off.
- *
- * @param id The id of the droplet to take the snapshot of.
- * @param name The name for the snapshot.
- * @return The id of the event to track the snapshot process.
- */
- @Named("droplet:snapshot")
- @GET
- @Path("/{id}/snapshot")
- @SelectJson("event_id")
- int snapshot(@PathParam("id") int id, @QueryParam("name") String name);
-
- /**
- * Restores a droplet with a previous image or snapshot.
- * <p>
- * This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary
- * information prior to restore.
- *
- * @param id The id of the droplet to restore.
- * @param imageId The id of the image or snapshot to use to restore the droplet.
- * @return The id of the event to track the restore process.
- */
- @Named("droplet:restore")
- @GET
- @Path("/{id}/restore")
- @SelectJson("event_id")
- int restore(@PathParam("id") int id, @QueryParam("image_id") int imageId);
-
- /**
- * Rebuilds a droplet with a default image.
- * <p>
- * This is useful if you want to start again but retain the same IP address for your droplet.
- *
- * @param id The id of the droplet to rebuild.
- * @param imageId The id of the image or snapshot to use to restore the droplet.
- * @return The id of the event to track the restore process.
- */
- @Named("droplet:rebuild")
- @GET
- @Path("/{id}/rebuild")
- @SelectJson("event_id")
- int rebuild(@PathParam("id") int id, @QueryParam("image_id") int imageId);
-
- /**
- * Renames a droplet to the specified name.
- *
- * @param id The id of the droplet to rename.
- * @param name The new name for the droplet.
- * @return The id of the event to track the rename process.
- */
- @Named("droplet:rename")
- @GET
- @Path("/{id}/rename")
- @SelectJson("event_id")
- int rename(@PathParam("id") int id, @QueryParam("name") String name);
-
- /**
- * Destroys the given droplet.
- *
- * @param id The id of the droplet to destroy.
- * @return The id of the event to track the destroy process.
- */
- @Named("droplet:destroy")
- @GET
- @Path("/{id}/destroy")
- @SelectJson("event_id")
- int destroy(@PathParam("id") int id);
-
- /**
- * Destroys the given droplet.
- *
- * @param id The id of the droplet to destroy.
- * @param scrubData If true this will strictly write 0s to your prior partition to ensure that all data is completely
- * erased.
- * @return The id of the event to track the destroy process.
- */
- @Named("droplet:destroy")
- @GET
- @Path("/{id}/destroy")
- @SelectJson("event_id")
- int destroy(@PathParam("id") int id, @QueryParam("scrub_data") boolean scrubData);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/EventApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/EventApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/EventApi.java
deleted file mode 100644
index 518cfe3..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/EventApi.java
+++ /dev/null
@@ -1,58 +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.digitalocean.features;
-
-import java.io.Closeable;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the Event API.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/events")
-public interface EventApi extends Closeable {
-
- /**
- * Gets the details of a given event.
- *
- * @param The id of the event to get.
- * @return The details of the event or <code>null</code> if no event exists with the given id.
- */
- @Named("event:get")
- @GET
- @Path("/{id}")
- @Fallback(NullOnNotFoundOr404.class)
- @SelectJson("event")
- @Nullable
- Event get(@PathParam("id") int id);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/ImageApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/ImageApi.java
deleted file mode 100644
index 8ae9abc..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/ImageApi.java
+++ /dev/null
@@ -1,140 +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.digitalocean.features;
-
-import java.io.Closeable;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the Image management features.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/images")
-public interface ImageApi extends Closeable {
-
- /**
- * Lists all available images.
- *
- * @return The list of all available images.
- */
- @Named("image:list")
- @GET
- @SelectJson("images")
- List<Image> list();
-
- /**
- * Gets the details of the given image.
- * <p>
- * Note that Image IDs can change. The recommended way to get an image is using the {@link #get(String)} method.
- *
- * @param id The id of the image to get.
- * @return The details of the image or <code>null</code> if no image exists with the given id.
- *
- * @see #get(String)
- */
- @Named("image:get")
- @GET
- @Path("/{id}")
- @SelectJson("image")
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- Image get(@PathParam("id") int id);
-
- /**
- * Gets the details of the given image.
- *
- * @param slug The slug of the image to get.
- * @return The details of the image or <code>null</code> if no image exists with the given slug.
- *
- * @see #get(int)
- */
- @Named("image:get")
- @GET
- @Path("/{slug}")
- @SelectJson("image")
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- Image get(@PathParam("slug") String slug);
-
- /**
- * Deletes an existing image.
- *
- * @param id The id of the key pair.
- */
- @Named("image:delete")
- @GET
- @Path("/{id}/destroy")
- void delete(@PathParam("id") int id);
-
- /**
- * Deletes an existing image.
- *
- * @param slug The slug of the key pair.
- */
- @Named("image:delete")
- @GET
- @Path("/{slug}/destroy")
- void delete(@PathParam("slug") String slug);
-
- /**
- * Transfers the image to the given region.
- *
- * @param id The id of the image to transfer.
- * @param regionId The id of the region to which the image will be transferred.
- * @return The id of the event to track the transfer process.
- *
- * @see #transfer(String, int)
- */
- @Named("image:transfer")
- @GET
- @Path("/{id}/transfer")
- @SelectJson("event_id")
- int transfer(@PathParam("id") int id, @QueryParam("region_id") int regionId);
-
- /**
- * Transfers the image to the given region.
- *
- * @param slug The slug of the image to transfer.
- * @param regionId The id of the region to which the image will be transferred.
- * @return The id of the event to track the transfer process.
- *
- * @see #transfer(int, int)
- */
- @Named("image:transfer")
- @GET
- @Path("/{slug}/transfer")
- @SelectJson("event_id")
- int transfer(@PathParam("slug") String slug, @QueryParam("region_id") int regionId);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/KeyPairApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/KeyPairApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/KeyPairApi.java
deleted file mode 100644
index 629a179..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/KeyPairApi.java
+++ /dev/null
@@ -1,106 +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.digitalocean.features;
-
-import java.io.Closeable;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the SSH key pair management features.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/ssh_keys")
-public interface KeyPairApi extends Closeable {
-
- /**
- * Lists all existing SSH key pairs.
- *
- * @return The list of all existing SSH key pairs.
- */
- @Named("key:list")
- @GET
- @SelectJson("ssh_keys")
- List<SshKey> list();
-
- /**
- * Gets the details of an existing SSH key pair.
- *
- * @param id The id of the SSH key pair.
- * @return The details of the SSH key pair or <code>null</code> if no key exists with the given id.
- */
- @Named("key:get")
- @GET
- @Path("/{id}")
- @SelectJson("ssh_key")
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- SshKey get(@PathParam("id") int id);
-
- /**
- * Creates a new SSH key pair.
- *
- * @param name The name of the key pair.
- * @param publicKey The public key.
- * @return The details of the created key pair.
- */
- @Named("key:create")
- @GET
- @Path("/new")
- @SelectJson("ssh_key")
- SshKey create(@QueryParam("name") String name, @QueryParam("ssh_pub_key") String publicKey);
-
- /**
- * Changes the SSH key for the given key pair.
- *
- * @param id The id of the key pair.
- * @param newPublicKey The new public key.
- * @return The details of the modified key pair.
- */
- @Named("key:edit")
- @GET
- @Path("/{id}/edit")
- @SelectJson("ssh_key")
- SshKey edit(@PathParam("id") int id, @QueryParam("ssh_pub_key") String newPublicKey);
-
- /**
- * Deletes an existing SSH key pair.
- *
- * @param id The id of the key pair.
- */
- @Named("key:delete")
- @GET
- @Path("/{id}/destroy")
- void delete(@PathParam("id") int id);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/RegionApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/RegionApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/RegionApi.java
deleted file mode 100644
index 9fc6d94..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/RegionApi.java
+++ /dev/null
@@ -1,51 +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.digitalocean.features;
-
-import java.io.Closeable;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the Region management features.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/regions")
-public interface RegionApi extends Closeable {
-
- /**
- * Lists all available regions.
- *
- * @return The list of all available regions.
- */
- @Named("region:list")
- @GET
- @SelectJson("regions")
- List<Region> list();
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/main/java/org/jclouds/digitalocean/features/SizesApi.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/features/SizesApi.java b/digitalocean/src/main/java/org/jclouds/digitalocean/features/SizesApi.java
deleted file mode 100644
index 433523e..0000000
--- a/digitalocean/src/main/java/org/jclouds/digitalocean/features/SizesApi.java
+++ /dev/null
@@ -1,51 +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.digitalocean.features;
-
-import java.io.Closeable;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.digitalocean.http.filters.AuthenticationFilter;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.inject.name.Named;
-
-/**
- * Provides access to the Size management features.
- */
-@RequestFilters(AuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Path("/sizes")
-public interface SizesApi extends Closeable {
-
- /**
- * Lists all available sizes.
- *
- * @return The list of all available sizes.
- */
- @Named("size:list")
- @GET
- @SelectJson("sizes")
- List<Size> list();
-}
[2/5] jclouds-labs git commit: Remove DigitalOcean v1
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiMockTest.java
deleted file mode 100644
index f5feff5..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/DropletApiMockTest.java
+++ /dev/null
@@ -1,770 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Droplet;
-import org.jclouds.digitalocean.domain.Droplet.Status;
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.options.CreateDropletOptions;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link DropletApi} class.
- */
-@Test(groups = "unit", testName = "DropletApiMockTest")
-public class DropletApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testListDroplets() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplets.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- List<Droplet> sizes = dropletApi.list();
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets");
- assertEquals(sizes.size(), 1);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplet.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- Droplet droplet = dropletApi.get(100823);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/100823");
- assertNotNull(droplet);
- assertNotNull(droplet.getBackups());
- assertNotNull(droplet.getSnapshots());
- assertEquals(droplet.getName(), "test222");
- assertEquals(droplet.getStatus(), Status.ACTIVE);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- Droplet droplet = dropletApi.get(100823);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/100823");
- assertNull(droplet);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testCreateDropletUsingSlugs() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplet-creation.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- DropletCreation droplet = dropletApi.create("test", "img-1", "size-1", "region-1");
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/new", ImmutableMultimap.of("name", "test",
- "image_slug", "img-1", "size_slug", "size-1", "region_slug", "region-1"));
-
- assertNotNull(droplet);
- assertEquals(droplet.getName(), "test");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testCreateDropletUsingSlugsWithOptions() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplet-creation.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- CreateDropletOptions options = CreateDropletOptions.builder().addSshKeyId(5).addSshKeyId(4)
- .privateNetworking(true).backupsEnabled(false).build();
- DropletCreation droplet = dropletApi.create("test", "img-1", "size-1", "region-1", options);
-
- ImmutableMultimap.Builder<String, String> params = ImmutableMultimap.builder();
- params.put("name", "test");
- params.put("image_slug", "img-1");
- params.put("size_slug", "size-1");
- params.put("region_slug", "region-1");
- params.put("ssh_key_ids", "5,4");
- params.put("private_networking", "true");
- params.put("backups_enabled", "false");
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/new", params.build());
-
- assertNotNull(droplet);
- assertEquals(droplet.getName(), "test");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testCreateDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplet-creation.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- DropletCreation droplet = dropletApi.create("test", 419, 32, 1);
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/new",
- ImmutableMultimap.of("name", "test", "image_id", "419", "size_id", "32", "region_id", "1"));
-
- assertNotNull(droplet);
- assertEquals(droplet.getName(), "test");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testCreateDropletWithOptions() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/droplet-creation.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- CreateDropletOptions options = CreateDropletOptions.builder().addSshKeyId(5).addSshKeyId(4)
- .privateNetworking(true).backupsEnabled(false).build();
- DropletCreation droplet = dropletApi.create("test", 419, 32, 1, options);
-
- ImmutableMultimap.Builder<String, String> params = ImmutableMultimap.builder();
- params.put("name", "test");
- params.put("image_id", "419");
- params.put("size_id", "32");
- params.put("region_id", "1");
- params.put("ssh_key_ids", "5,4");
- params.put("private_networking", "true");
- params.put("backups_enabled", "false");
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/new", params.build());
-
- assertNotNull(droplet);
- assertEquals(droplet.getName(), "test");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRebootDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.reboot(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/reboot");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRebootNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.reboot(1);
- fail("Reboot droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/reboot");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerCycleDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.powerCycle(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_cycle");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerCycleNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.powerCycle(1);
- fail("Power cycle droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_cycle");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testShutdownDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.shutdown(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/shutdown");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testShutdownNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.shutdown(1);
- fail("Shutdown droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/shutdown");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerOffDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.powerOff(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_off");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerOffNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.powerOff(1);
- fail("Power off droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_off");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerOnDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.powerOn(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_on");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testPowerOnNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.powerOn(1);
- fail("Power on droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/power_on");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testResetPasswordForDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.resetPassword(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/password_reset");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testResetPasswordForNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.resetPassword(1);
- fail("Reset password for droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/password_reset");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testResizeDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.resize(1, 3);
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/resize", ImmutableMultimap.of("size_id", "3"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testResizeNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.resize(1, 3);
- fail("Resize droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/resize", ImmutableMultimap.of("size_id", "3"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testSnapshotDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.snapshot(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/snapshot");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testSnapshotNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.snapshot(1);
- fail("Snapshot droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/snapshot");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testSnapshotWithNameDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.snapshot(1, "foo");
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/snapshot", ImmutableMultimap.of("name", "foo"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testSnapshotWithNameNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.snapshot(1, "foo");
- fail("Snapshot droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/snapshot", ImmutableMultimap.of("name", "foo"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRestoreDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.restore(1, 3);
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/restore", ImmutableMultimap.of("image_id", "3"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRestoreNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.restore(1, 3);
- fail("Restore droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/restore", ImmutableMultimap.of("image_id", "3"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRebuildDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.rebuild(1, 3);
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/rebuild", ImmutableMultimap.of("image_id", "3"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRebuildNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.rebuild(1, 3);
- fail("Rebuild droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/rebuild", ImmutableMultimap.of("image_id", "3"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRenameDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.rename(1, "foo");
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/rename", ImmutableMultimap.of("name", "foo"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testRenameNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.rename(1, "foo");
- fail("Rename droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/rename", ImmutableMultimap.of("name", "foo"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDestroyDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.destroy(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/destroy");
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDestroyNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.destroy(1);
- fail("Destroy droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/droplets/1/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDestroyWithOptionsDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- int event = dropletApi.destroy(1, true);
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/destroy",
- ImmutableMultimap.of("scrub_data", "true"));
- assertTrue(event > 0);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDestroyWithOptionsNonexistentDroplet() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- DropletApi dropletApi = api.getDropletApi();
-
- try {
- try {
- dropletApi.destroy(1, true);
- fail("Destroy droplet should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/droplets/1/destroy",
- ImmutableMultimap.of("scrub_data", "true"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiLiveTest.java
deleted file mode 100644
index 21785d3..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiLiveTest.java
+++ /dev/null
@@ -1,56 +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.digitalocean.features;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Live tests for the {@link EventApi} class.
- */
-@Test(groups = "live", testName = "EventApiLiveTest")
-public class EventApiLiveTest extends BaseDigitalOceanLiveTest {
-
- @Override
- protected void initialize() {
- super.initialize();
- initializeImageSizeAndRegion();
- }
-
- public void testGetEvent() {
- DropletCreation droplet = null;
-
- try {
- droplet = api.getDropletApi().create("eventtest", defaultImage.getId(), defaultSize.getId(),
- defaultRegion.getId());
- Event event = api.getEventApi().get(droplet.getEventId());
- assertNotNull(event, "Droplet creation event should not be null");
- assertTrue(event.getId() > 0, "Event id should be > 0");
- } finally {
- if (droplet != null) {
- waitForEvent(droplet.getEventId());
- api.getDropletApi().destroy(droplet.getId(), true);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiMockTest.java
deleted file mode 100644
index 648030d..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/EventApiMockTest.java
+++ /dev/null
@@ -1,93 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.domain.Event.Status;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link EventApi} class.
- */
-@Test(groups = "unit", testName = "EventApiMockTest")
-public class EventApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testGetEvent() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/event.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- EventApi eventApi = api.getEventApi();
-
- try {
- Event event = eventApi.get(7499);
-
- assertRequestHasCommonFields(server.takeRequest(), "/events/7499");
- assertNotNull(event);
- assertEquals(event.getStatus(), Status.DONE);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetPendingEvent() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/event-pending.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- EventApi eventApi = api.getEventApi();
-
- try {
- Event event = eventApi.get(7499);
-
- assertRequestHasCommonFields(server.takeRequest(), "/events/7499");
- assertNotNull(event);
- assertEquals(event.getStatus(), Status.PENDING);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetUnexistingEvent() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- EventApi eventApi = api.getEventApi();
-
- try {
- Event event = eventApi.get(7499);
-
- assertRequestHasCommonFields(server.takeRequest(), "/events/7499");
- assertNull(event);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiLiveTest.java
deleted file mode 100644
index 4027a89..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,139 +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.digitalocean.features;
-
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Iterables.tryFind;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.digitalocean.domain.DropletCreation;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-
-/**
- * Live tests for the {@link ImageApi} class.
- */
-@Test(groups = "live", testName = "ImageApiLiveTest")
-public class ImageApiLiveTest extends BaseDigitalOceanLiveTest {
-
- private Image snapshot;
- private Image snapshotUsingSlug;
- private DropletCreation droplet;
- private DropletCreation dropletUsingSlug;
-
- @Override
- protected void initialize() {
- super.initialize();
- initializeImageSizeAndRegion();
- }
-
- @AfterClass
- public void cleanup() {
- try {
- if (droplet != null) {
- api.getDropletApi().destroy(droplet.getId(), true);
- }
- if (dropletUsingSlug != null) {
- api.getDropletApi().destroy(dropletUsingSlug.getId(), true);
- }
- } finally {
- if (snapshot != null) {
- api.getImageApi().delete(snapshot.getId());
- assertFalse(tryFind(api.getImageApi().list(), byName(snapshot.getName())).isPresent(),
- "Snapshot should not exist after delete");
- }
- if (snapshotUsingSlug != null) {
- api.getImageApi().delete(snapshotUsingSlug.getId());
- assertFalse(tryFind(api.getImageApi().list(), byName(snapshotUsingSlug.getName())).isPresent(),
- "Snapshot should not exist after delete");
- }
- }
- }
-
- public void testGetImage() {
- assertNotNull(api.getImageApi().get(defaultImage.getId()), "The image should not be null");
- }
-
- public void testGetImageBySlug() {
- assertNotNull(api.getImageApi().get(defaultImage.getSlug()), "The image should not be null");
- }
-
- public void testGetImageNotFound() {
- assertNull(api.getImageApi().get(-1));
- }
-
- public void testTransferImage() {
- droplet = api.getDropletApi().create("imagetransferdroplet", defaultImage.getId(), defaultSize.getId(),
- defaultRegion.getId());
-
- assertTrue(droplet.getId() > 0, "Created droplet id should be > 0");
- assertTrue(droplet.getEventId() > 0, "Droplet creation event id should be > 0");
-
- waitForEvent(droplet.getEventId());
- int powerOffEvent = api.getDropletApi().powerOff(droplet.getId());
- waitForEvent(powerOffEvent);
-
- int snapshotEvent = api.getDropletApi().snapshot(droplet.getId(), "imagetransfersnapshot");
- waitForEvent(snapshotEvent);
-
- snapshot = find(api.getImageApi().list(), byName("imagetransfersnapshot"));
-
- Region newRegion = regions.get(1);
- int transferEvent = api.getImageApi().transfer(snapshot.getId(), newRegion.getId());
- assertTrue(transferEvent > 0, "Transfer event id should be > 0");
- waitForEvent(transferEvent);
- }
-
- public void testTransferImageUsingSlug() {
- dropletUsingSlug = api.getDropletApi().create("imagetransferdropletusingslug", defaultImage.getSlug(),
- defaultSize.getSlug(), defaultRegion.getSlug());
-
- assertTrue(dropletUsingSlug.getId() > 0, "Created droplet id should be > 0");
- assertTrue(dropletUsingSlug.getEventId() > 0, "Droplet creation event id should be > 0");
-
- waitForEvent(dropletUsingSlug.getEventId());
- int powerOffEvent = api.getDropletApi().powerOff(dropletUsingSlug.getId());
- waitForEvent(powerOffEvent);
-
- int snapshotEvent = api.getDropletApi().snapshot(dropletUsingSlug.getId(), "imagetransfersnapshotusingslug");
- waitForEvent(snapshotEvent);
-
- snapshotUsingSlug = find(api.getImageApi().list(), byName("imagetransfersnapshotusingslug"));
-
- Region newRegion = regions.get(1);
- int transferEvent = api.getImageApi().transfer(snapshotUsingSlug.getId(), newRegion.getId());
- assertTrue(transferEvent > 0, "Transfer event id should be > 0");
- waitForEvent(transferEvent);
- }
-
- private static Predicate<Image> byName(final String name) {
- return new Predicate<Image>() {
- @Override
- public boolean apply(Image input) {
- return input.getName().equals(name);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiMockTest.java
deleted file mode 100644
index 2129408..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/ImageApiMockTest.java
+++ /dev/null
@@ -1,262 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Distribution;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link ImageApi} class.
- */
-@Test(groups = "unit", testName = "ImageApiMockTest")
-public class ImageApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testListImages() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/images.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- List<Image> images = imageApi.list();
-
- assertRequestHasCommonFields(server.takeRequest(), "/images");
- assertEquals(images.size(), 3);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetImage() throws Exception {
- MockWebServer server = mockWebServer();
- String[] imageJsons = new String[] { "/image1.json", "/image2.json", "/image3.json", "/image2.json" };
-
- for (String imageJson : imageJsons) {
- server.enqueue(new MockResponse().setBody(payloadFromResource(imageJson)));
- }
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- Image image = imageApi.get(1);
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/1");
- assertNotNull(image);
- assertEquals(image.getId(), 1);
- assertEquals(image.getOs().getDistribution(), Distribution.ARCHLINUX);
- assertEquals(image.getOs().getVersion(), "2013.05");
- assertEquals(image.getOs().getArch(), "x32");
- assertEquals(image.getName(), "Arch Linux 2013.05 x32");
- assertTrue(image.isPublicImage());
- assertEquals(image.getSlug(), "arch-linux-x32");
-
- image = imageApi.get(2);
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/2");
- assertNotNull(image);
- assertEquals(image.getId(), 2);
- assertEquals(image.getOs().getDistribution(), Distribution.FEDORA);
- assertEquals(image.getOs().getVersion(), "17");
- assertEquals(image.getOs().getArch(), "x64");
- assertEquals(image.getName(), "Fedora 17 x64 Desktop");
- assertTrue(image.isPublicImage());
- assertEquals(image.getSlug(), "fedora-17-x64");
-
- image = imageApi.get(3);
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/3");
- assertNotNull(image);
- assertNull(image.getSlug());
- assertEquals(image.getId(), 3);
- assertEquals(image.getOs().getDistribution(), Distribution.UBUNTU);
- assertEquals(image.getOs().getVersion(), "13.04");
- assertEquals(image.getOs().getArch(), "");
- assertEquals(image.getName(), "Dokku on Ubuntu 13.04 0.2.0rc3");
- assertTrue(image.isPublicImage());
- assertNull(image.getSlug());
-
- image = imageApi.get("fedora-17-x64");
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/fedora-17-x64");
- assertNotNull(image);
- assertEquals(image.getId(), 2);
- assertEquals(image.getOs().getDistribution(), Distribution.FEDORA);
- assertEquals(image.getOs().getVersion(), "17");
- assertEquals(image.getOs().getArch(), "x64");
- assertEquals(image.getName(), "Fedora 17 x64 Desktop");
- assertTrue(image.isPublicImage());
- assertEquals(image.getSlug(), "fedora-17-x64");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetUnexistingImage() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- Image image = imageApi.get(15);
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/15");
- assertNull(image);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDeleteImage() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse());
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- imageApi.delete(15);
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/15/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDeleteImageUsingSlug() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse());
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- imageApi.delete("img-15");
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/img-15/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testDeleteUnexistingImage() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- try {
- imageApi.delete(15);
- fail("Delete image should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/images/15/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testTransferUnexistingImage() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- try {
- imageApi.transfer(47, 23);
- fail("Transfer image should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/images/47/transfer",
- ImmutableMultimap.of("region_id", "23"));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testTransferImage() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- int eventId = imageApi.transfer(47, 23);
-
- assertRequestHasParameters(server.takeRequest(), "/images/47/transfer",
- ImmutableMultimap.of("region_id", "23"));
- assertEquals(eventId, 7499);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testTransferImageUsingSlug() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/eventid.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- int eventId = imageApi.transfer("img-47", 23);
-
- assertRequestHasParameters(server.takeRequest(), "/images/img-47/transfer",
- ImmutableMultimap.of("region_id", "23"));
- assertEquals(eventId, 7499);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiLiveTest.java
deleted file mode 100644
index a22ce46..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiLiveTest.java
+++ /dev/null
@@ -1,76 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-/**
- * Live tests for the {@link ImageApi} class.
- */
-@Test(groups = "live", testName = "ImageApiLiveTest")
-public class KeyPairApiLiveTest extends BaseDigitalOceanLiveTest {
-
- private SshKey key;
-
- public void testCreateKey() throws IOException {
- String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- key = api.getKeyPairApi().create("foo", publicKey);
-
- assertNotNull(key);
- assertNotNull(key.getId());
- assertEquals(key.getName(), "foo");
- assertNotNull(key.getPublicKey());
- assertEquals(key.getPublicKey().getAlgorithm(), "RSA");
- }
-
- @Test(dependsOnMethods = "testCreateKey")
- public void testListKeys() {
- List<SshKey> keys = api.getKeyPairApi().list();
- assertFalse(keys.isEmpty(), "SSH key list should not be empty");
- }
-
- @Test(dependsOnMethods = "testCreateKey")
- public void testGetKey() {
- assertNotNull(api.getKeyPairApi().get(key.getId()), "The SSH key should not be null");
- }
-
- @Test(dependsOnMethods = "testCreateKey")
- public void testEditKey() throws IOException {
- String newKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
- SshKey updated = api.getKeyPairApi().edit(key.getId(), newKey);
-
- assertNotNull(updated.getPublicKey(), "The SSH key should have a public key");
- assertEquals(updated.getPublicKey().getAlgorithm(), "DSA");
- }
-
- @Test(dependsOnMethods = { "testListKeys", "testGetKey", "testEditKey" })
- public void testDeleteKey() throws IOException {
- api.getKeyPairApi().delete(key.getId());
- assertNull(api.getKeyPairApi().get(key.getId()), "The SSH key should not exist after deleting it");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiMockTest.java
deleted file mode 100644
index 1b13765..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/KeyPairApiMockTest.java
+++ /dev/null
@@ -1,213 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.SshKey;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link KeyPairApi} class.
- */
-@Test(groups = "unit", testName = "KeyPairApiMockTest")
-public class KeyPairApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testListKeys() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/keys.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- List<SshKey> keys = keyPairApi.list();
-
- assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys");
- assertEquals(keys.size(), 1);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/key.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- SshKey key = keyPairApi.get(47);
-
- assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47");
- assertEquals(key.getId(), 47);
- assertEquals(key.getName(), "my_key");
- assertNotNull(key.getPublicKey());
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testGetUnexistingKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- SshKey key = keyPairApi.get(47);
-
- assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47");
- assertNull(key);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- @Test
- public void testCreateKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/key.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- SshKey key = keyPairApi.create("my_key", publicKey);
-
- assertRequestHasParameters(server.takeRequest(), "/ssh_keys/new",
- ImmutableMultimap.of("name", "my_key", "ssh_pub_key", publicKey));
-
- assertEquals(key.getId(), 47);
- assertEquals(key.getName(), "my_key");
- assertNotNull(key.getPublicKey());
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- @Test
- public void testEditKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/key.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
- SshKey key = keyPairApi.edit(47, publicKey);
-
- assertRequestHasParameters(server.takeRequest(), "/ssh_keys/47/edit",
- ImmutableMultimap.of("ssh_pub_key", publicKey));
-
- assertEquals(key.getId(), 47);
- assertEquals(key.getName(), "my_key");
- assertNotNull(key.getPublicKey());
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- @Test
- public void testEditUnexistingKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
-
- try {
- keyPairApi.edit(47, publicKey);
- fail("Edit key should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasParameters(server.takeRequest(), "/ssh_keys/47/edit",
- ImmutableMultimap.of("ssh_pub_key", publicKey));
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- @Test
- public void testDeleteKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse());
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- keyPairApi.delete(47);
-
- assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- @Test
- public void testDeleteUnexistingKey() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- KeyPairApi keyPairApi = api.getKeyPairApi();
-
- try {
- try {
- keyPairApi.delete(47);
- fail("Delete key should fail on 404");
- } catch (ResourceNotFoundException ex) {
- // Expected exception
- }
-
- assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47/destroy");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiLiveTest.java
deleted file mode 100644
index ab32689..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiLiveTest.java
+++ /dev/null
@@ -1,46 +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.digitalocean.features;
-
-import static org.testng.Assert.assertFalse;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Live tests for the {@link RegionApi} class.
- */
-@Test(groups = "live", testName = "RegionApiLiveTest")
-public class RegionApiLiveTest extends BaseDigitalOceanLiveTest {
-
- private RegionApi regionApi;
-
- @Override
- protected void initialize() {
- super.initialize();
- regionApi = api.getRegionApi();
- }
-
- public void testListRegions() {
- List<Region> regions = regionApi.list();
-
- assertFalse(regions.isEmpty(), "Region list should not be empty");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiMockTest.java
deleted file mode 100644
index 376fbef..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/RegionApiMockTest.java
+++ /dev/null
@@ -1,54 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link RegionApi} class.
- */
-@Test(groups = "unit", testName = "RegionApiMockTest")
-public class RegionApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testListRegions() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/regions.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- RegionApi regionApi = api.getRegionApi();
-
- try {
- List<Region> regions = regionApi.list();
-
- assertRequestHasCommonFields(server.takeRequest(), "/regions");
- assertEquals(regions.size(), 4);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizeApiLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizeApiLiveTest.java
deleted file mode 100644
index a7ba6d0..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizeApiLiveTest.java
+++ /dev/null
@@ -1,46 +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.digitalocean.features;
-
-import static org.testng.Assert.assertFalse;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Live tests for the {@link SizesApi} class.
- */
-@Test(groups = "live", testName = "SizeApiLiveTest")
-public class SizeApiLiveTest extends BaseDigitalOceanLiveTest {
-
- private SizesApi sizesApi;
-
- @Override
- protected void initialize() {
- super.initialize();
- sizesApi = api.getSizesApi();
- }
-
- public void testListSizes() {
- List<Size> sizes = sizesApi.list();
-
- assertFalse(sizes.isEmpty(), "Size list should not be empty");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizesApiMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizesApiMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizesApiMockTest.java
deleted file mode 100644
index 4e054b6..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/features/SizesApiMockTest.java
+++ /dev/null
@@ -1,54 +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.digitalocean.features;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link SizesApi} class.
- */
-@Test(groups = "unit", testName = "SizesApiMockTest")
-public class SizesApiMockTest extends BaseDigitalOceanMockTest {
-
- public void testListSizes() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/sizes.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- SizesApi sizesApi = api.getSizesApi();
-
- try {
- List<Size> sizes = sizesApi.list();
-
- assertRequestHasCommonFields(server.takeRequest(), "/sizes");
- assertEquals(sizes.size(), 4);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java
deleted file mode 100644
index 6017c61..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java
+++ /dev/null
@@ -1,112 +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.digitalocean.http;
-
-import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
-import static org.jclouds.digitalocean.http.ResponseStatusFromPayloadHttpCommandExecutorService.ACCESS_DENIED;
-import static org.jclouds.digitalocean.http.ResponseStatusFromPayloadHttpCommandExecutorService.NOT_FOUND;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.Properties;
-
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.features.ImageApi;
-import org.jclouds.digitalocean.internal.BaseDigitalOceanMockTest;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-/**
- * Mock tests for the {@link ResponseStatusFromPayloadHttpCommandExecutorService} class.
- */
-@Test(groups = "unit", testName = "ResponseStatusFromPayloadHttpCommandExecutorServiceTest")
-public class ResponseStatusFromPayloadHttpCommandExecutorServiceTest extends BaseDigitalOceanMockTest {
-
- @Override
- protected Properties setupProperties() {
- Properties properties = super.setupProperties();
- properties.setProperty(PROPERTY_MAX_RETRIES, "1");
- return properties;
- }
-
- public void testAccessDenied() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- imageApi.list();
- fail("Request should have failed");
- } catch (Exception ex) {
- assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException");
- assertEquals(ex.getMessage(), ACCESS_DENIED);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testNotFound() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/not-found.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- imageApi.list();
- fail("Request should have failed");
- } catch (Exception ex) {
- assertTrue(ex instanceof ResourceNotFoundException, "Exception should be a ResourceNotFoundException");
- assertEquals(ex.getMessage(), NOT_FOUND);
- } finally {
- api.close();
- server.shutdown();
- }
- }
-
- public void testInternalServerError() throws Exception {
- MockWebServer server = mockWebServer();
- server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
- // Response to be sent for the retried request
- server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
-
- DigitalOceanApi api = api(server.getUrl("/"));
- ImageApi imageApi = api.getImageApi();
-
- try {
- imageApi.list();
- fail("Request should have failed after retrying");
- } catch (Exception ex) {
- assertTrue(ex instanceof HttpResponseException, "Exception should be an HttpResponseException");
- HttpResponseException exception = HttpResponseException.class.cast(ex);
- assertEquals(exception.getResponse().getStatusCode(), 500);
- assertEquals(exception.getMessage(), "No Image Found");
- } finally {
- api.close();
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/http/filters/AuthenticationFilterTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/http/filters/AuthenticationFilterTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/http/filters/AuthenticationFilterTest.java
deleted file mode 100644
index 5ce5078..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/http/filters/AuthenticationFilterTest.java
+++ /dev/null
@@ -1,58 +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.digitalocean.http.filters;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.digitalocean.http.filters.AuthenticationFilter.CREDENTIAL_PARAM;
-import static org.jclouds.digitalocean.http.filters.AuthenticationFilter.IDENTITY_PARAM;
-import static org.jclouds.http.utils.Queries.queryParser;
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Multimap;
-
-/**
- * Unit tests for the {@link AuthenticationFilter} class.
- */
-@Test(groups = "unit", testName = "AuthenticationFilterTest")
-public class AuthenticationFilterTest {
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "credential supplier cannot be null")
- public void testFilterWithoutCredentials() {
- new AuthenticationFilter(null);
- }
-
- public void testFilterWithCredentials() {
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost/foo").build();
- Credentials credentials = LoginCredentials.builder().identity("foo").credential("bar").build();
- AuthenticationFilter filter = new AuthenticationFilter(Suppliers.ofInstance(credentials));
-
- HttpRequest filtered = filter.filter(request);
-
- String queryLine = filtered.getRequestLine().trim()
- .substring(filtered.getRequestLine().indexOf('?') + 1, filtered.getRequestLine().lastIndexOf(' '));
- Multimap<String, String> params = queryParser().apply(queryLine);
-
- assertEquals(getOnlyElement(params.get(IDENTITY_PARAM)), "foo");
- assertEquals(getOnlyElement(params.get(CREDENTIAL_PARAM)), "bar");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanLiveTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanLiveTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanLiveTest.java
deleted file mode 100644
index 366a95b..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanLiveTest.java
+++ /dev/null
@@ -1,90 +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.digitalocean.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.jclouds.apis.BaseApiLiveTest;
-import org.jclouds.digitalocean.DigitalOceanApi;
-import org.jclouds.digitalocean.domain.Event;
-import org.jclouds.digitalocean.domain.Image;
-import org.jclouds.digitalocean.domain.Region;
-import org.jclouds.digitalocean.domain.Size;
-import org.jclouds.util.Predicates2;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ComparisonChain;
-import com.google.common.collect.Ordering;
-
-/**
- * Base class for the DigitalOcean live tests.
- */
-public class BaseDigitalOceanLiveTest extends BaseApiLiveTest<DigitalOceanApi> {
-
- protected static final int DEFAULT_TIMEOUT_SECONDS = 600;
- protected static final int DEFAULT_POLL_SECONDS = 1;
- protected static final String DEFAULT_IMAGE = "ubuntu-14-04-x64";
-
- protected List<Size> sizes;
- protected List<Region> regions;
-
- protected Size defaultSize;
- protected Image defaultImage;
- protected Region defaultRegion;
-
- public BaseDigitalOceanLiveTest() {
- provider = "digitalocean";
- }
-
- protected void initializeImageSizeAndRegion() {
- sizes = sortedSizes().sortedCopy(api.getSizesApi().list());
- regions = api.getRegionApi().list();
-
- assertTrue(sizes.size() > 1, "There must be at least two sizes");
- assertTrue(regions.size() > 1, "There must be at least two regions");
-
- defaultImage = api.getImageApi().get(DEFAULT_IMAGE);
- checkNotNull(defaultImage, "Image %s not found", DEFAULT_IMAGE);
-
- defaultSize = sizes.get(0);
- defaultRegion = regions.get(0);
- }
-
- protected void waitForEvent(Integer eventId) {
- Predicates2.retry(new Predicate<Integer>() {
- @Override
- public boolean apply(Integer input) {
- Event event = api.getEventApi().get(input);
- return Event.Status.DONE == event.getStatus();
- }
- }, DEFAULT_TIMEOUT_SECONDS, DEFAULT_POLL_SECONDS, TimeUnit.SECONDS).apply(eventId);
- }
-
- protected static Ordering<Size> sortedSizes() {
- return new Ordering<Size>() {
- @Override
- public int compare(Size left, Size right) {
- return ComparisonChain.start().compare(left.getCpu(), right.getCpu())
- .compare(left.getMemory(), right.getMemory()).compare(left.getDisk(), right.getDisk()).result();
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/114b3528/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanMockTest.java
----------------------------------------------------------------------
diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanMockTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanMockTest.java
deleted file mode 100644
index 02022ae..0000000
--- a/digitalocean/src/test/java/org/jclouds/digitalocean/internal/BaseDigitalOceanMockTest.java
+++ /dev/null
@@ -1,107 +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.digitalocean.internal;
-
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
-import static org.jclouds.digitalocean.http.filters.AuthenticationFilter.CREDENTIAL_PARAM;
-import static org.jclouds.digitalocean.http.filters.AuthenticationFilter.IDENTITY_PARAM;
-import static org.jclouds.http.utils.Queries.encodeQueryLine;
-import static org.jclouds.util.Strings2.toStringAndClose;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.concurrent.config.ExecutorServiceModule;
-import org.jclouds.digitalocean.DigitalOceanApi;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-import com.google.common.net.HttpHeaders;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
-
-/**
- * Base class for all DigitalOcean mock tests.
- */
-public class BaseDigitalOceanMockTest {
- private final Set<Module> modules = ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(),
- sameThreadExecutor()));
-
- protected String provider;
-
- public BaseDigitalOceanMockTest() {
- provider = "digitalocean";
- }
-
- public DigitalOceanApi api(URL url) {
- return ContextBuilder.newBuilder(provider)
- .credentials("clientid", "apikey")
- .endpoint(url.toString())
- .modules(modules)
- .overrides(setupProperties())
- .buildApi(DigitalOceanApi.class);
- }
-
- protected Properties setupProperties() {
- return new Properties();
- }
-
- public static MockWebServer mockWebServer() throws IOException {
- MockWebServer server = new MockWebServer();
- server.play();
- return server;
- }
-
- public byte[] payloadFromResource(String resource) {
- try {
- return toStringAndClose(getClass().getResourceAsStream(resource)).getBytes(Charsets.UTF_8);
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- protected static void assertRequestHasCommonFields(final RecordedRequest request, final String path)
- throws InterruptedException {
- assertRequestHasParameters(request, path, ImmutableMultimap.<String, String> of());
- }
-
- protected static void assertRequestHasParameters(final RecordedRequest request, final String path,
- Multimap<String, String> parameters) throws InterruptedException {
- Multimap<String, String> allparams = ImmutableMultimap.<String, String> builder()
- .putAll(parameters)
- .put(IDENTITY_PARAM, "clientid")
- .put(CREDENTIAL_PARAM, "apikey")
- .build();
-
- assertRequestHasAcceptHeader(request);
- assertEquals(request.getRequestLine(), "GET " + path + "?" + encodeQueryLine(allparams) + " HTTP/1.1");
- }
-
- protected static void assertRequestHasAcceptHeader(final RecordedRequest request) throws InterruptedException {
- assertEquals(request.getHeader(HttpHeaders.ACCEPT), MediaType.APPLICATION_JSON);
- }
-}