From f2364eab2667bf4bad9fe9fd218bb3db0affd2cc Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 29 Dec 2012 10:51:53 -0800 Subject: [PATCH] Issue #1106: remove deltacloud --- allcompute/pom.xml | 5 - apis/deltacloud/README.txt | 84 ----- apis/deltacloud/pom.xml | 131 ------- .../deltacloud/DeltacloudApiMetadata.java | 91 ----- .../deltacloud/DeltacloudAsyncClient.java | 179 --------- .../jclouds/deltacloud/DeltacloudClient.java | 144 -------- .../deltacloud/DeltacloudFallbacks.java | 52 --- .../collections/HardwareProfiles.java | 39 -- .../deltacloud/collections/Images.java | 39 -- .../collections/InstanceStates.java | 39 -- .../deltacloud/collections/Instances.java | 39 -- .../deltacloud/collections/Realms.java | 39 -- ...DeltacloudComputeServiceContextModule.java | 61 ---- .../functions/DeltacloudImageToImage.java | 54 --- .../DeltacloudImageToOperatingSystem.java | 89 ----- .../functions/HardwareProfileToHardware.java | 60 ---- .../functions/InstanceToNodeMetadata.java | 163 --------- .../compute/functions/RealmToLocation.java | 62 ---- .../DeltacloudComputeServiceAdapter.java | 176 --------- .../config/DeltacloudRestClientModule.java | 158 -------- .../deltacloud/domain/Architecture.java | 28 -- .../domain/DeltacloudCollection.java | 100 ------ .../domain/EnumHardwareProperty.java | 54 --- .../jclouds/deltacloud/domain/Feature.java | 67 ---- .../domain/FixedHardwareProperty.java | 33 -- .../deltacloud/domain/HardwareParameter.java | 122 ------- .../deltacloud/domain/HardwareProfile.java | 128 ------- .../deltacloud/domain/HardwareProperty.java | 78 ---- .../org/jclouds/deltacloud/domain/Image.java | 163 --------- .../jclouds/deltacloud/domain/Instance.java | 281 --------------- .../deltacloud/domain/KeyAuthentication.java | 70 ---- .../domain/ParameterizedHardwareProperty.java | 76 ---- .../domain/PasswordAuthentication.java | 72 ---- .../domain/RangeHardwareProperty.java | 91 ----- .../org/jclouds/deltacloud/domain/Realm.java | 172 --------- .../jclouds/deltacloud/domain/Transition.java | 27 -- .../domain/TransitionAutomatically.java | 67 ---- .../deltacloud/domain/TransitionOnAction.java | 76 ---- .../domain/internal/BaseHardwareProperty.java | 119 ------ .../handlers/DeltacloudErrorHandler.java | 100 ------ .../DeltacloudRedirectionRetryHandler.java | 50 --- .../options/CreateInstanceOptions.java | 101 ------ .../predicates/InstanceFinished.java | 47 --- .../predicates/InstanceRunning.java | 47 --- .../deltacloud/predicates/InstanceState.java | 67 ---- .../xml/DeltacloudCollectionHandler.java | 69 ---- .../xml/DeltacloudCollectionsHandler.java | 67 ---- .../xml/HardwareProfileHandler.java | 102 ------ .../xml/HardwareProfilesHandler.java | 68 ---- .../xml/HardwarePropertyHandler.java | 119 ------ .../jclouds/deltacloud/xml/ImageHandler.java | 86 ----- .../jclouds/deltacloud/xml/ImagesHandler.java | 68 ---- .../deltacloud/xml/InstanceHandler.java | 171 --------- .../deltacloud/xml/InstanceStatesHandler.java | 82 ----- .../deltacloud/xml/InstancesHandler.java | 68 ---- .../jclouds/deltacloud/xml/RealmHandler.java | 82 ----- .../jclouds/deltacloud/xml/RealmsHandler.java | 68 ---- .../services/org.jclouds.apis.ApiMetadata | 1 - .../deltacloud/DeltacloudApiMetadataTest.java | 34 -- .../deltacloud/DeltacloudAsyncClientTest.java | 339 ------------------ .../deltacloud/DeltacloudClientLiveTest.java | 159 -------- .../ReadOnlyDeltacloudClientLiveTest.java | 167 --------- .../DeltacloudComputeServiceLiveTest.java | 88 ----- .../DeltacloudTemplateBuilderLiveTest.java | 85 ----- .../handlers/DeltacloudErrorHandlerTest.java | 125 ------- ...DeltacloudRedirectionRetryHandlerTest.java | 83 ----- .../options/CreateInstanceOptionsTest.java | 66 ---- .../xml/DeltacloudCollectionsHandlerTest.java | 61 ---- .../xml/HardwareProfileHandlerTest.java | 79 ---- .../xml/HardwareProfilesHandlerTest.java | 79 ---- .../deltacloud/xml/ImageHandlerTest.java | 63 ---- .../deltacloud/xml/ImagesHandlerTest.java | 54 --- .../deltacloud/xml/InstanceHandlerTest.java | 99 ----- .../xml/InstanceStatesHandlerTest.java | 58 --- .../deltacloud/xml/InstancesHandlerTest.java | 57 --- .../deltacloud/xml/RealmHandlerTest.java | 64 ---- .../deltacloud/xml/RealmsHandlerTest.java | 51 --- apis/deltacloud/src/test/resources/links.xml | 23 -- apis/deltacloud/src/test/resources/log4j.xml | 151 -------- .../resources/test_get_hardware_profile.xml | 18 - .../src/test/resources/test_get_image.xml | 7 - .../src/test/resources/test_get_instance.xml | 20 -- .../test/resources/test_get_instance_key.xml | 24 -- .../resources/test_get_instance_nokey.xml | 24 -- .../test/resources/test_get_instance_pw.xml | 27 -- .../src/test/resources/test_get_realm.xml | 5 - .../src/test/resources/test_get_states.xml | 18 - .../resources/test_list_hardware_profiles.xml | 46 --- .../src/test/resources/test_list_images.xml | 20 -- .../test/resources/test_list_instances.xml | 22 -- .../src/test/resources/test_list_realms.xml | 12 - apis/pom.xml | 1 - 92 files changed, 7220 deletions(-) delete mode 100644 apis/deltacloud/README.txt delete mode 100644 apis/deltacloud/pom.xml delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudFallbacks.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/HardwareProfiles.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Images.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/InstanceStates.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Instances.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Realms.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToImage.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToOperatingSystem.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/HardwareProfileToHardware.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/RealmToLocation.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Architecture.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/DeltacloudCollection.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/EnumHardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Feature.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/FixedHardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareParameter.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProfile.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Image.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Instance.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/KeyAuthentication.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/ParameterizedHardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/PasswordAuthentication.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/RangeHardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Realm.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Transition.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionAutomatically.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionOnAction.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/internal/BaseHardwareProperty.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/options/CreateInstanceOptions.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceFinished.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceRunning.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceState.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfileHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfilesHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImageHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImagesHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstancesHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmHandler.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmsHandler.java delete mode 100644 apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfileHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfilesHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImageHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImagesHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstancesHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmHandlerTest.java delete mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmsHandlerTest.java delete mode 100644 apis/deltacloud/src/test/resources/links.xml delete mode 100644 apis/deltacloud/src/test/resources/log4j.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_hardware_profile.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_image.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_instance.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_instance_key.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_instance_nokey.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_instance_pw.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_realm.xml delete mode 100644 apis/deltacloud/src/test/resources/test_get_states.xml delete mode 100644 apis/deltacloud/src/test/resources/test_list_hardware_profiles.xml delete mode 100644 apis/deltacloud/src/test/resources/test_list_images.xml delete mode 100644 apis/deltacloud/src/test/resources/test_list_instances.xml delete mode 100644 apis/deltacloud/src/test/resources/test_list_realms.xml diff --git a/allcompute/pom.xml b/allcompute/pom.xml index c89196929c..80ed52c40f 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -35,11 +35,6 @@ greenhousedata-element-vcloud ${project.version} - - org.jclouds.api - deltacloud - ${project.version} - org.jclouds.provider aws-ec2 diff --git a/apis/deltacloud/README.txt b/apis/deltacloud/README.txt deleted file mode 100644 index 4798829a9b..0000000000 --- a/apis/deltacloud/README.txt +++ /dev/null @@ -1,84 +0,0 @@ -==== - Licensed to jclouds, Inc. (jclouds) under one or more - contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. jclouds licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -==== - -jclouds binding to deltacloud requires a minimum server version of 0.1.0. - -The identity and credential specified in jclouds will pass through deltacloud to -the backend, such as gogrid. - -To install deltacloud, do the following: - * OS/X and jruby - # use homebrew or equiv to install jruby - * brew install jruby - * note testing took place w/ 1.6.0 - # install and configure openssl to avoid "certificate verify failed" errors - # install and link openssl - * brew install openssl - * brew link openssl - # install jruby ssl - * jruby -S gem install jruby-openssl - # setup cert directory - * mkdir $HOME/certs - * curl -o $HOME/certs/cacert.pem http://curl.haxx.se/ca/cacert.pem - # rehash cert directory - * export SSL_CERT_DIR=$HOME/certs - * export SSL_CERT_FILE=$HOME/certs/cacert.pem - * c_rehash - # test - * jruby -ropen-uri -e 'p open("https://encrypted.google.com")' - * should see something like # - # install specific version of rack that doesn't conflict with deltacloud - * jruby -S gem install rack --version 1.1.0 - # install net-ssh - * jruby -S gem install net-ssh - # install deltacloud core - * jruby -S gem install deltacloud-core - -To run a local deltacloud server, do the following: - * jruby - # export SSL_CERT_DIR=$HOME/certs - # export SSL_CERT_FILE=$HOME/certs/cacert.pem - # jruby -S deltacloudd -i mock - * or if you are running from a src tree: jruby -S ./server/bin/deltacloudd -i - -Here are some notes about specific cloud providers - * terremark - # install fog gem - * jruby -S gem install fog - * rackspace - # install cloudfiles, cloudservers gem - * jruby -S gem install cloudservers - * jruby -S gem install cloudfiles - * ec2 - * using jruby --1.8, 'gem install aws' will fail with ArrayIndexOutOfBoundsException per http://jira.codehaus.org/browse/JRUBY-5581 - * using jruby --1.9, 'gem install aws' works, but running './server/bin/deltacloudd -i ec2' fails per http://jira.codehaus.org/browse/JRUBY-5529 - # install i18n, aws gem - * jruby -S gem install i18n - * jruby -S gem install aws - -Local Development of Delta - * jruby -S gem install rack-test cucumber - - * What tests are available - * jruby -S rake -T - * server/tests/drivers - * specific tests to a particular driver - * Running tests - * jruby -S rake test - diff --git a/apis/deltacloud/pom.xml b/apis/deltacloud/pom.xml deleted file mode 100644 index 9470789a81..0000000000 --- a/apis/deltacloud/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.6.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.api - deltacloud - jclouds deltacloud core - jclouds components to access deltacloud - bundle - - - - - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - - - - - http://localhost:3001/api - 0.3.0 - - mockuser - mockpassword - - org.jclouds.deltacloud*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - org.jclouds - jclouds-compute - ${project.version} - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.deltacloud.endpoint} - ${test.deltacloud.api-version} - ${test.deltacloud.build-version} - ${test.deltacloud.identity} - ${test.deltacloud.credential} - ${test.deltacloud.template} - - - - - - - - - - - diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java deleted file mode 100644 index df9ca77bc3..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; -import org.jclouds.deltacloud.config.DeltacloudRestClientModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Apache Deltacloud API - * - * @author Adrian Cole - */ -public class DeltacloudApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public DeltacloudApiMetadata() { - this(new Builder()); - } - - protected DeltacloudApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - return BaseRestApiMetadata.defaultProperties(); - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(DeltacloudClient.class, DeltacloudAsyncClient.class); - id("deltacloud") - .name("Apache Deltacloud API") - .identityName("Username") - .credentialName("Password") - .documentation(URI.create("http://deltacloud.apache.org/api.html")) - .version("0.3.0") - .defaultEndpoint("http://localhost:3001/api") - .defaultProperties(DeltacloudApiMetadata.defaultProperties()) - .view(TypeToken.of(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class)); - } - - @Override - public DeltacloudApiMetadata build() { - return new DeltacloudApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(ApiMetadata in) { - super.fromApiMetadata(in); - return this; - } - - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java deleted file mode 100644 index f1b188e10f..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import java.net.URI; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyMultimapOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.deltacloud.DeltacloudFallbacks.VoidOnRedirectedDelete; -import org.jclouds.deltacloud.collections.HardwareProfiles; -import org.jclouds.deltacloud.collections.Images; -import org.jclouds.deltacloud.collections.InstanceStates; -import org.jclouds.deltacloud.collections.Instances; -import org.jclouds.deltacloud.collections.Realms; -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.options.CreateInstanceOptions; -import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler; -import org.jclouds.deltacloud.xml.HardwareProfileHandler; -import org.jclouds.deltacloud.xml.HardwareProfilesHandler; -import org.jclouds.deltacloud.xml.ImageHandler; -import org.jclouds.deltacloud.xml.ImagesHandler; -import org.jclouds.deltacloud.xml.InstanceHandler; -import org.jclouds.deltacloud.xml.InstanceStatesHandler; -import org.jclouds.deltacloud.xml.InstancesHandler; -import org.jclouds.deltacloud.xml.RealmHandler; -import org.jclouds.deltacloud.xml.RealmsHandler; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to deltacloud via their REST API. - *

- * - * @see DeltacloudClient - * @see - * @author Adrian Cole - */ -@RequestFilters(BasicAuthentication.class) -@Consumes(MediaType.APPLICATION_XML) -public interface DeltacloudAsyncClient { - - /** - * @see DeltacloudClient#getCollections - */ - @GET - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(DeltacloudCollectionsHandler.class) - ListenableFuture> getCollections(); - - /** - * @see DeltacloudClient#getInstanceStates - */ - @GET - @Endpoint(InstanceStates.class) - @Fallback(EmptyMultimapOnNotFoundOr404.class) - @XMLResponseParser(InstanceStatesHandler.class) - ListenableFuture> getInstanceStates(); - - /** - * @see DeltacloudClient#listRealms - */ - @GET - @Endpoint(Realms.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(RealmsHandler.class) - ListenableFuture> listRealms(); - - /** - * @see DeltacloudClient#getRealm - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @XMLResponseParser(RealmHandler.class) - ListenableFuture getRealm(@EndpointParam URI realmHref); - - /** - * @see DeltacloudClient#listImages - */ - @GET - @Endpoint(Images.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(ImagesHandler.class) - ListenableFuture> listImages(); - - /** - * @see DeltacloudClient#getImage - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @XMLResponseParser(ImageHandler.class) - ListenableFuture getImage(@EndpointParam URI imageHref); - - /** - * @see DeltacloudClient#listHardwareProfiles - */ - @GET - @Endpoint(HardwareProfiles.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(HardwareProfilesHandler.class) - ListenableFuture> listHardwareProfiles(); - - /** - * @see DeltacloudClient#getHardwareProfile - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @XMLResponseParser(HardwareProfileHandler.class) - ListenableFuture getHardwareProfile(@EndpointParam URI profileHref); - - /** - * @see DeltacloudClient#listInstances - */ - @GET - @Endpoint(Instances.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(InstancesHandler.class) - ListenableFuture> listInstances(); - - /** - * @see DeltacloudClient#getInstance - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @XMLResponseParser(InstanceHandler.class) - ListenableFuture getInstance(@EndpointParam URI instanceHref); - - /** - * @see DeltacloudClient#createInstance - */ - @POST - @Endpoint(Instances.class) - @XMLResponseParser(InstanceHandler.class) - ListenableFuture createInstance(@FormParam("image_id") String imageId, CreateInstanceOptions... options); - - /** - * @see DeltacloudClient#performInstanceAction - */ - @Fallback(VoidOnRedirectedDelete.class) - ListenableFuture performAction(HttpRequest action); - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java deleted file mode 100644 index 39f4da8db7..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import java.net.URI; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.concurrent.Timeout; -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.deltacloud.options.CreateInstanceOptions; -import org.jclouds.http.HttpRequest; - -import com.google.common.collect.Multimap; - -/** - * Provides synchronous access to deltacloud. - *

- * - * @see DeltacloudAsyncClient - * @see - * @author Adrian Cole - */ -@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) -public interface DeltacloudClient { - /** - * The result of this entry-point is a set of entry-points into other collections, such as - * images, instances, hardware profiles and realms, among others. - * - * @return named links to available collections, or empty set, if no collections are found - */ - Set getCollections(); - - /** - * - * @return The possible states of an instance, and how to traverse between them - */ - Multimap getInstanceStates(); - - /** - * The realms collection will return a set of all realms available to the current user. - * - * @return realms viewable to the user or empty set - */ - Set listRealms(); - - /** - * - * @param realmHref - * @return realm or null, if not found - */ - Realm getRealm(URI realmHref); - - /** - * The images collection will return a set of all images available to the current user. - * - * @return images viewable to the user or empty set - */ - Set listImages(); - - /** - * - * @param imageHref - * @return image or null, if not found - */ - Image getImage(URI imageHref); - - /** - * The hardware profiles collection will return a set of all hardware profiles available to the - * current user. - * - * @return hardware profiles viewable to the user or empty set - */ - Set listHardwareProfiles(); - - /** - * - * @param profileHref - * @return hardware profile or null, if not found - */ - HardwareProfile getHardwareProfile(URI profileHref); - - /** - * The instances collection will return a set of all instances available to the current user. - * - * @return instances viewable to the user or empty set - */ - Set listInstances(); - - /** - * - * @param instanceHref - * @return instance or null, if not found - */ - Instance getInstance(URI instanceHref); - - /** - * Create a new Instance - * - *

Note

- * - * If options realmId or hardwareProfileName are not specified, the provider must select - * reasonable defaults. The architecture of the selected hardware profile must match the - * architecture of the specified image. - * - * @param imageId - * The identifier (not URL) of the image from which to base the instance - * @param options - * includes realm, hardware profile, etc. - * @return newly-created instance including a URL to retrieve the instance in the future. - */ - Instance createInstance(String imageId, CreateInstanceOptions... options); - - /** - * perform a specific action. - * - * @param action - * reference from {@link Instance#getActions()} - */ - void performAction(HttpRequest action); - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudFallbacks.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudFallbacks.java deleted file mode 100644 index 8e75fcb6ff..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudFallbacks.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.Futures.immediateFuture; -import static org.jclouds.util.Throwables2.getFirstThrowableOfType; - -import javax.ws.rs.HttpMethod; - -import org.jclouds.http.HttpResponseException; - -import com.google.common.util.concurrent.FutureFallback; -import com.google.common.util.concurrent.ListenableFuture; - -public final class DeltacloudFallbacks { - private DeltacloudFallbacks() { - } - - /** - * When a delete operation is performed, Deltacloud returns 302. - * - * @author Adrian Cole - */ - public static final class VoidOnRedirectedDelete implements FutureFallback { - @Override - public ListenableFuture create(final Throwable t) { - HttpResponseException exception = getFirstThrowableOfType(t, HttpResponseException.class); - if (exception != null && exception.getCommand().getCurrentRequest().getMethod().equals(HttpMethod.DELETE) - && exception.getResponse().getStatusCode() == 302) { - return immediateFuture(null); - } - throw propagate(t); - } - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/HardwareProfiles.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/HardwareProfiles.java deleted file mode 100644 index 7ed996d0f3..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/HardwareProfiles.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.collections; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * The images collection will return a set of all hardware profiles available to the current user. - * - * @author Adrian Cole - * - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface HardwareProfiles { - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Images.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Images.java deleted file mode 100644 index fd16dbb386..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Images.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.collections; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * The images collection will return a set of all images available to the current user. - * - * @author Adrian Cole - * - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Images { - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/InstanceStates.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/InstanceStates.java deleted file mode 100644 index b387de8ac9..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/InstanceStates.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.collections; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * The realms collection will return a set of all instance states available to the current user. - * - * @author Adrian Cole - * - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface InstanceStates { - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Instances.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Instances.java deleted file mode 100644 index 937f33bf4d..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Instances.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.collections; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * The instances collection will return a set of all instances available to the current user. - * - * @author Adrian Cole - * - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Instances { - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Realms.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Realms.java deleted file mode 100644 index 706d293dbd..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/collections/Realms.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.collections; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * The realms collection will return a set of all realms available to the current user. - * - * @author Adrian Cole - * - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Realms { - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java deleted file mode 100644 index 34d21cb1af..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.config; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage; -import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware; -import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata; -import org.jclouds.deltacloud.compute.functions.RealmToLocation; -import org.jclouds.deltacloud.compute.strategy.DeltacloudComputeServiceAdapter; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.domain.Location; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -public class DeltacloudComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @Override - protected void configure() { - super.configure(); - bind( - new TypeLiteral>() { - }).to(DeltacloudComputeServiceAdapter.class); - bind(new TypeLiteral>() { - }).to(InstanceToNodeMetadata.class); - bind(new TypeLiteral>() { - }).to(DeltacloudImageToImage.class); - bind(new TypeLiteral>() { - }).to(HardwareProfileToHardware.class); - bind(new TypeLiteral>() { - }).to(RealmToLocation.class); - // to have the compute service adapter override default locations - install(new LocationsFromComputeServiceAdapterModule(){}); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToImage.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToImage.java deleted file mode 100644 index b8ad9edd0a..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToImage.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.Image.Status; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class DeltacloudImageToImage implements Function { - private final DeltacloudImageToOperatingSystem imageToOperatingSystem; - - @Inject - public DeltacloudImageToImage(DeltacloudImageToOperatingSystem imageToOperatingSystem) { - this.imageToOperatingSystem = imageToOperatingSystem; - } - - @Override - public Image apply(org.jclouds.deltacloud.domain.Image from) { - ImageBuilder builder = new ImageBuilder(); - builder.id(from.getHref().toASCIIString()); - builder.providerId(from.getId()); - builder.uri(from.getHref()); - builder.name(from.getName()); - builder.description(from.getDescription()); - builder.operatingSystem(imageToOperatingSystem.apply(from)); - builder.status(Status.AVAILABLE); - return builder.build(); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToOperatingSystem.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToOperatingSystem.java deleted file mode 100644 index f55e71e4e9..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/DeltacloudImageToOperatingSystem.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.functions; - -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class DeltacloudImageToOperatingSystem implements Function { - public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)"); - // Windows Server 2008 R2 x64 - public static final Pattern WINDOWS_PATTERN = Pattern.compile("Windows (.*) (x[86][64])"); - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final Map> osVersionMap; - - @Inject - public DeltacloudImageToOperatingSystem(Map> osVersionMap) { - this.osVersionMap = osVersionMap; - } - - public OperatingSystem apply(org.jclouds.deltacloud.domain.Image from) { - OsFamily osFamily = null; - String osName = null; - String osArch = null; - String osVersion = null; - String osDescription = from.getName(); - boolean is64Bit = true; - if (from.getName().indexOf("Red Hat EL") != -1) { - osFamily = OsFamily.RHEL; - } else if (from.getName().indexOf("Oracle EL") != -1) { - osFamily = OsFamily.OEL; - } else if (from.getName().indexOf("Windows") != -1) { - osFamily = OsFamily.WINDOWS; - Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); - if (matcher.find()) { - osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); - is64Bit = matcher.group(2).equals("x64"); - } - } else { - Matcher matcher = DEFAULT_PATTERN.matcher(from.getName()); - if (matcher.find()) { - try { - osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase()); - } catch (IllegalArgumentException e) { - logger.debug("<< didn't match os(%s)", matcher.group(2)); - } - osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); - } - } - return new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/HardwareProfileToHardware.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/HardwareProfileToHardware.java deleted file mode 100644 index 28b643299c..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/HardwareProfileToHardware.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.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; -import org.jclouds.compute.domain.VolumeBuilder; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.HardwareProperty; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; - -/** - * @author Adrian Cole - */ -@Singleton -public class HardwareProfileToHardware implements Function { - - @Override - public Hardware apply(HardwareProfile from) { - HardwareBuilder builder = new HardwareBuilder(); - builder.ids(from.getId()); - builder.name(from.getName()); - builder.uri(from.getHref()); - - for (HardwareProperty property : from.getProperties()) { - if (property.getName().equals("memory")) { - builder.ram(Integer.parseInt(property.getValue().toString())); - } else if (property.getName().equals("storage")) { - Float gigs = new Float(property.getValue().toString()); - builder.processors(ImmutableList.of(new Processor(gigs / 10.0, 1.0))); - builder.volume(new VolumeBuilder().type(Volume.Type.LOCAL).device("/").size(gigs).bootDevice(true).durable( - true).build()); - } - } - - return builder.build(); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java deleted file mode 100644 index 188ce1d2a2..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; -import java.util.NoSuchElementException; -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.NodeMetadataBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Singleton -public class InstanceToNodeMetadata implements Function { - - public static final Map instanceToNodeStatus = ImmutableMap - . builder().put(Instance.State.STOPPED, Status.SUSPENDED) - .put(Instance.State.RUNNING, Status.RUNNING).put(Instance.State.PENDING, Status.PENDING) - .put(Instance.State.UNRECOGNIZED, Status.UNRECOGNIZED).put(Instance.State.SHUTTING_DOWN, Status.PENDING) - .put(Instance.State.START, Status.PENDING).build(); - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - protected final Supplier> locations; - protected final Supplier> images; - protected final Supplier> hardwares; - protected final GroupNamingConvention nodeNamingConvention; - - private static class FindImageForInstance implements Predicate { - private final Instance instance; - - private FindImageForInstance(Instance instance) { - this.instance = instance; - } - - @Override - public boolean apply(Image input) { - return input.getUri().equals(instance.getImage()); - } - } - - private static class FindHardwareForInstance implements Predicate { - private final Instance instance; - - private FindHardwareForInstance(Instance instance) { - this.instance = instance; - } - - @Override - public boolean apply(Hardware input) { - return input.getUri().equals(instance.getHardwareProfile()); - } - } - - protected Hardware parseHardware(Instance from) { - try { - return Iterables.find(hardwares.get(), new FindHardwareForInstance(from)); - } catch (NoSuchElementException e) { - logger.debug("could not find a matching hardware for instance %s", from); - } - return null; - } - - protected OperatingSystem parseOperatingSystem(Instance from) { - try { - return Iterables.find(images.get(), new FindImageForInstance(from)).getOperatingSystem(); - } catch (NoSuchElementException e) { - logger.debug("could not find a matching image for instance %s", from); - } - return null; - } - - private static class FindLocationForInstance implements Predicate { - private final Instance instance; - - private FindLocationForInstance(Instance instance) { - this.instance = instance; - } - - @Override - public boolean apply(Location input) { - return input.getId().equals(instance.getRealm().toASCIIString()); - } - } - - protected Location parseLocation(Instance from) { - try { - return Iterables.find(locations.get(), new FindLocationForInstance(from)); - } catch (NoSuchElementException e) { - logger.debug("could not find a matching realm for instance %s", from); - } - return null; - } - - @Inject - InstanceToNodeMetadata(@Memoized Supplier> locations, - @Memoized Supplier> images, @Memoized Supplier> hardwares, - GroupNamingConvention.Factory namingConvention) { - this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.images = checkNotNull(images, "images"); - this.locations = checkNotNull(locations, "locations"); - this.hardwares = checkNotNull(hardwares, "hardwares"); - } - - @Override - public NodeMetadata apply(org.jclouds.deltacloud.domain.Instance from) { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.ids(from.getHref().toASCIIString()); - builder.name(from.getName()); - builder.location(parseLocation(from)); - builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); - builder.imageId(from.getImage().toASCIIString()); - builder.operatingSystem(parseOperatingSystem(from)); - builder.hardware(parseHardware(from)); - builder.status(instanceToNodeStatus.get(from.getState())); - builder.publicAddresses(from.getPublicAddresses()); - builder.privateAddresses(from.getPrivateAddresses()); - return builder.build(); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/RealmToLocation.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/RealmToLocation.java deleted file mode 100644 index 1c0ce6a36d..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/RealmToLocation.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.location.Iso3166; -import org.jclouds.location.Provider; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * @author Adrian Cole - */ -@Singleton -public class RealmToLocation implements Function { - - private final String providerName; - private final Supplier endpoint; - private final Set isoCodes; - - @Inject - public RealmToLocation(@Iso3166 Set isoCodes, @Provider String providerName, @Provider Supplier endpoint) { - this.providerName = checkNotNull(providerName, "providerName"); - this.endpoint = checkNotNull(endpoint, "endpoint"); - this.isoCodes = checkNotNull(isoCodes, "isoCodes"); - } - - @Override - public Location apply(Realm from) { - return new LocationBuilder().scope(LocationScope.ZONE).id(from.getHref().toASCIIString()).description(from.getName()).parent( - new LocationBuilder().scope(LocationScope.PROVIDER).iso3166Codes(isoCodes).id(providerName).description( - endpoint.get().toASCIIString()).parent(null).build()).build(); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java deleted file mode 100644 index ba00cae38a..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.concurrent.TimeUnit; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.deltacloud.DeltacloudClient; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.PasswordAuthentication; -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.domain.TransitionOnAction; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.deltacloud.options.CreateInstanceOptions; -import org.jclouds.deltacloud.predicates.InstanceFinished; -import org.jclouds.deltacloud.predicates.InstanceRunning; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.logging.Logger; -import org.jclouds.predicates.RetryablePredicate; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; - -/** - * defines the connection between the {@link DeltacloudClient} implementation - * and the jclouds {@link ComputeService} - * - */ -@Singleton -public class DeltacloudComputeServiceAdapter implements - ComputeServiceAdapter { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final org.jclouds.deltacloud.DeltacloudClient client; - private final ImmutableMap> stateChanges; - - @Inject - public DeltacloudComputeServiceAdapter(DeltacloudClient client) { - this.client = checkNotNull(client, "client"); - // TODO: parameterize - stateChanges = ImmutableMap.> of(// - Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, - TimeUnit.SECONDS),// - Instance.State.FINISH, new RetryablePredicate(new InstanceFinished(client), 30, 1, - TimeUnit.SECONDS)// - ); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String tag, String name, - Template template) { - Instance instance = client.createInstance(template.getImage().getProviderId(), CreateInstanceOptions.Builder - .named(name).hardwareProfile(template.getHardware().getId()).realm(template.getLocation().getId())); - LoginCredentials creds = null; - if (instance.getAuthentication() != null && instance.getAuthentication() instanceof PasswordAuthentication) { - creds = PasswordAuthentication.class.cast(instance.getAuthentication()).getLoginCredentials(); - } - return new NodeAndInitialCredentials(instance, instance.getId(), creds); - } - - @Override - public Iterable listHardwareProfiles() { - return client.listHardwareProfiles(); - } - - @Override - public Iterable listImages() { - return client.listImages(); - } - - @Override - public Iterable listNodes() { - return client.listInstances(); - } - - @Override - public Iterable listLocations() { - return client.listRealms(); - } - - @Override - public org.jclouds.deltacloud.domain.Instance getNode(String id) { - return client.getInstance(URI.create(checkNotNull(id, "id"))); - } - - @Override - public org.jclouds.deltacloud.domain.Image getImage(String id) { - return client.getImage(URI.create(checkNotNull(id, "id"))); - } - - @Override - public void destroyNode(String id) { - Instance instance = getNode(id); - for (Transition transition : findChainTo(Instance.State.FINISH, instance.getState(), client.getInstanceStates())) { - instance = getNode(id); - if (instance == null) - break; - if (transition instanceof TransitionOnAction) { - client.performAction(instance.getActions().get(TransitionOnAction.class.cast(transition).getAction())); - } - Predicate stateTester = stateChanges.get(transition.getTo()); - if (stateTester != null) - stateTester.apply(instance); - else - logger.debug(String.format("no state tester for: %s", transition)); - } - } - - Iterable findChainTo(Instance.State desired, Instance.State currentState, - Multimap states) { - for (Transition transition : states.get(currentState)) { - if (currentState.ordinal() >= transition.getTo().ordinal()) - continue; - if (transition.getTo() == desired) - return ImmutableSet. of(transition); - Iterable transitions = findChainTo(desired, transition.getTo(), states); - if (Iterables.size(transitions) > 0) - return Iterables.concat(ImmutableSet.of(transition), transitions); - } - return ImmutableSet. of(); - } - - @Override - public void rebootNode(String id) { - HttpRequest rebootUri = getNode(id).getActions().get(Instance.Action.REBOOT); - if (rebootUri != null) { - client.performAction(rebootUri); - } else { - throw new UnsupportedOperationException(); - } - } - - @Override - public void resumeNode(String id) { - throw new UnsupportedOperationException(); - } - - @Override - public void suspendNode(String id) { - throw new UnsupportedOperationException(); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java deleted file mode 100644 index fbc2fc9083..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.config; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; - -import java.net.URI; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; -import org.jclouds.deltacloud.collections.HardwareProfiles; -import org.jclouds.deltacloud.collections.Images; -import org.jclouds.deltacloud.collections.InstanceStates; -import org.jclouds.deltacloud.collections.Instances; -import org.jclouds.deltacloud.collections.Realms; -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.handlers.DeltacloudErrorHandler; -import org.jclouds.deltacloud.handlers.DeltacloudRedirectionRetryHandler; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.util.Suppliers2; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.Atomics; -import com.google.inject.Provides; - -/** - * Configures the deltacloud connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class DeltacloudRestClientModule extends RestClientModule { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(DeltacloudErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(DeltacloudErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(DeltacloudErrorHandler.class); - } - - @Override - protected void bindRetryHandlers() { - bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(DeltacloudRedirectionRetryHandler.class); - } - - protected AtomicReference authException = Atomics.newReference(); - - @Provides - @Singleton - protected Supplier> provideCollections( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final DeltacloudClient client) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create( - authException, new Supplier>() { - @Override - public Set get() { - return client.getCollections(); - } - @Override - public String toString() { - return Objects.toStringHelper(client).add("method", "getCollections").toString(); - } - }, seconds, TimeUnit.SECONDS); - } - - /** - * since the supplier is memoized, and there are no objects created here, this doesn't need to be - * singleton. - */ - @Provides - @Images - protected Supplier provideImageCollection(Supplier> collectionSupplier) { - return Suppliers2.compose(new FindCollectionWithRelAndReturnHref("images"), collectionSupplier); - } - - public static class FindCollectionWithRelAndReturnHref implements Function, URI> { - private final String rel; - - public FindCollectionWithRelAndReturnHref(String rel) { - this.rel = rel; - } - - @Override - public URI apply(Set arg0) { - try { - return Iterables.find(arg0, new Predicate() { - - @Override - public boolean apply(DeltacloudCollection arg0) { - return arg0.getRel().equals(rel); - } - - }).getHref(); - } catch (NoSuchElementException e) { - throw new NoSuchElementException("could not find rel " + rel + " in collections " + arg0); - } - } - - } - - @Provides - @HardwareProfiles - protected Supplier provideHardwareProfileCollection(Supplier> collectionSupplier) { - return Suppliers2.compose(new FindCollectionWithRelAndReturnHref("hardware_profiles"), collectionSupplier); - } - - @Provides - @Instances - protected Supplier provideInstanceCollection(Supplier> collectionSupplier) { - return Suppliers2.compose(new FindCollectionWithRelAndReturnHref("instances"), collectionSupplier); - } - - @Provides - @Realms - protected Supplier provideRealmCollection(Supplier> collectionSupplier) { - return Suppliers2.compose(new FindCollectionWithRelAndReturnHref("realms"), collectionSupplier); - } - - @Provides - @InstanceStates - protected Supplier provideInstanceStateCollection(Supplier> collectionSupplier) { - return Suppliers2.compose(new FindCollectionWithRelAndReturnHref("instance_states"), collectionSupplier); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Architecture.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Architecture.java deleted file mode 100644 index 2c41976e1b..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Architecture.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -/** - * - * @author Adrian Cole - */ -public interface Architecture { - public static final String I386 = "i386"; - public static final String X86_64 = "x86_64"; -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/DeltacloudCollection.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/DeltacloudCollection.java deleted file mode 100644 index bfb9f575f2..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/DeltacloudCollection.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class DeltacloudCollection { - private final URI href; - private final String rel; - private final Set features; - - public DeltacloudCollection(URI href, String rel) { - this(href, rel, ImmutableSet. of()); - } - - public DeltacloudCollection(URI href, String rel, Set features) { - this.href = checkNotNull(href, "href"); - this.rel = checkNotNull(rel, "rel"); - this.features = ImmutableSet.copyOf(checkNotNull(features, "features")); - } - - public URI getHref() { - return href; - } - - public String getRel() { - return rel; - } - - public Set getFeatures() { - return features; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((features == null) ? 0 : features.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((rel == null) ? 0 : rel.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; - DeltacloudCollection other = (DeltacloudCollection) obj; - if (features == null) { - if (other.features != null) - return false; - } else if (!features.equals(other.features)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (rel == null) { - if (other.rel != null) - return false; - } else if (!rel.equals(other.rel)) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + href + ", rel=" + rel + ", features=" + features + "]"; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/EnumHardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/EnumHardwareProperty.java deleted file mode 100644 index 3de1d06d24..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/EnumHardwareProperty.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class EnumHardwareProperty extends ParameterizedHardwareProperty { - - private final Set availableValues; - - public EnumHardwareProperty(String name, String unit, Object value, HardwareParameter param, - Set availableValues) { - super(Kind.FIXED, name, unit, value, param); - this.availableValues = ImmutableSet.copyOf(checkNotNull(availableValues, "availableValues")); - } - - /** - * - * @return a set of available values - */ - public Set getAvailableValues() { - return availableValues; - } - - @Override - public String toString() { - return "[kind=" + getKind() + ", name=" + getName() + ", unit=" + getUnit() + ", value=" + getValue() - + ", param=" + getParam() + ", availableValues=" + availableValues + "]"; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Feature.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Feature.java deleted file mode 100644 index f3e56016c6..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Feature.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public class Feature { - private final String name; - - public Feature(String name) { - this.name = checkNotNull(name, "name"); - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "[name=" + name + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - 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; - Feature other = (Feature) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/FixedHardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/FixedHardwareProperty.java deleted file mode 100644 index 150a009413..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/FixedHardwareProperty.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import org.jclouds.deltacloud.domain.internal.BaseHardwareProperty; - -/** - * - * @author Adrian Cole - */ -public class FixedHardwareProperty extends BaseHardwareProperty { - - public FixedHardwareProperty(String name, String unit, Object value) { - super(Kind.FIXED, name, unit, value); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareParameter.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareParameter.java deleted file mode 100644 index b4511b4e6f..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareParameter.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -/** - * A parameter corresponding to a hardware option. - * - * @author Adrian Cole - */ -public class HardwareParameter { - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((method == null) ? 0 : method.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((operation == null) ? 0 : operation.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; - HardwareParameter other = (HardwareParameter) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (method == null) { - if (other.method != null) - return false; - } else if (!method.equals(other.method)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (operation == null) { - if (other.operation != null) - return false; - } else if (!operation.equals(other.operation)) - return false; - return true; - } - - private final URI href; - private final String method; - private final String name; - private final String operation; - - public HardwareParameter(URI href, String method, String name, String operation) { - this.href = checkNotNull(href, "href"); - this.method = checkNotNull(method, "method"); - this.name = checkNotNull(name, "name"); - this.operation = checkNotNull(operation, "operation"); - } - - /** - * - * @return URI of the action this applies to - */ - public URI getHref() { - return href; - } - - /** - * - * @return HTTP method of the action this applies to - */ - public String getMethod() { - return method; - } - - /** - * - * @return name of the HTTP request parameter related to this - */ - public String getName() { - return name; - } - - /** - * - * @return name of the action this applies to - */ - public String getOperation() { - return operation; - } - - @Override - public String toString() { - return "[href=" + href + ", method=" + method + ", name=" + name + ", operation=" + operation + "]"; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProfile.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProfile.java deleted file mode 100644 index 7fe1594708..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProfile.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * A hardware profile represents a configuration of resources upon which a machine may be deployed. - * It defines aspects such as local disk storage, available RAM, and architecture. Each provider is - * free to define as many (or as few) hardware profiles as desired. - * - * @author Adrian Cole - */ -public class HardwareProfile { - private final URI href; - private final String id; - private final String name; - private final Set properties; - - public HardwareProfile(URI href, String id, String name, Set properties) { - this.href = checkNotNull(href, "href"); - this.id = checkNotNull(id, "id"); - this.name = checkNotNull(name, "name"); - this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties")); - } - - /** - * - * @return URL to manipulate a specific profile - */ - public URI getHref() { - return href; - } - - /** - * - * @return A unique identifier for the profile - */ - public String getId() { - return id; - } - - /** - * - * @return A short label - */ - public String getName() { - return name; - } - - /** - * - * @return properties included in this hardware profile - */ - public Set getProperties() { - return properties; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((properties == null) ? 0 : properties.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; - HardwareProfile other = (HardwareProfile) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (properties == null) { - if (other.properties != null) - return false; - } else if (!properties.equals(other.properties)) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + href + ", id=" + id + ", name=" + name + ", properties=" + properties + "]"; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProperty.java deleted file mode 100644 index b753d7228d..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/HardwareProperty.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public interface HardwareProperty { - public static enum Kind { - /** - * only the value specified in the property is available - */ - FIXED, - /** - * a list of available values is provided - */ - ENUM, - /** - * available values are described by a numeric range - */ - RANGE, - /** - * type returned as something besides the above. - */ - UNRECOGNIZED; - - public static HardwareProperty.Kind fromValue(String kind) { - try { - return valueOf(checkNotNull(kind, "kind").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - /** - * - * @return describes the values to chose from. - */ - HardwareProperty.Kind getKind(); - - /** - * - * @return the type of the property: e.g. memory or storage - */ - String getName(); - - /** - * - * @return the units in which the value is specified: MB, GB, count or label - */ - String getUnit(); - - /** - * - * @return the actual value of the property. It depends on the specified unit: 1024, 2 on x86_64 - */ - Object getValue(); -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Image.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Image.java deleted file mode 100644 index c3c0756982..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Image.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.javax.annotation.Nullable; - -/** - * An image is a platonic form of a machine. Images are not directly executable, but are a template - * for creating actual instances of machines. - * - * @author Adrian Cole - */ -public class Image { - private final URI href; - private final String id; - private final String ownerId; - @Nullable - private final String name; - @Nullable - private final String description; - private final String architecture; - - public Image(URI href, String id, String ownerId, @Nullable String name, String description, String architecture) { - this.href = checkNotNull(href, "href"); - this.id = checkNotNull(id, "id"); - this.ownerId = checkNotNull(ownerId, "ownerId"); - this.name = name; - this.description = description; - this.architecture = checkNotNull(architecture, "architecture"); - } - - /** - * - * @return URL to manipulate a specific image - */ - public URI getHref() { - return href; - } - - /** - * - * @return A unique identifier for the image - */ - public String getId() { - return id; - } - - /** - * - * @return An opaque identifier which indicates the owner of an image - */ - public String getOwnerId() { - return ownerId; - } - - /** - * - * @return An optional short label describing the image - */ - @Nullable - public String getName() { - return name; - } - - /** - * - * @return An optional description describing the image more fully - */ - @Nullable - public String getDescription() { - return description; - } - - /** - * - * @return A description of the machine architecture of the image which may contain values such - * as: i386, x86_64 - */ - public String getArchitecture() { - return architecture; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((architecture == null) ? 0 : architecture.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((ownerId == null) ? 0 : ownerId.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 (architecture == null) { - if (other.architecture != null) - return false; - } else if (!architecture.equals(other.architecture)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (ownerId == null) { - if (other.ownerId != null) - return false; - } else if (!ownerId.equals(other.ownerId)) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + href + ", id=" + id + ", ownerId=" + ownerId + ", name=" + name + ", description=" - + description + ", architecture=" + architecture + "]"; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Instance.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Instance.java deleted file mode 100644 index a2d3c3f902..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Instance.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.jclouds.http.HttpRequest; -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * An instance is a concrete machine realized from an image. - * - * @author Adrian Cole - */ -public class Instance { - public static interface Authentication { - - } - - public static enum State { - /** - * initial state, before instance is created. - */ - START, - /** - * the instance is in the process of being launched - */ - PENDING, - /** - * the instance launched (although the boot process might not be completed) - */ - RUNNING, - /** - * the instance is shutting down - */ - SHUTTING_DOWN, - /** - * the instance is stopped - */ - STOPPED, - /** - * the instance is terminated - */ - FINISH, - /** - * state returned as something besides the above. - */ - UNRECOGNIZED; - - public static State fromValue(String state) { - try { - return valueOf(checkNotNull(state, "state").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static enum Action { - - CREATE, - - RUN, - - REBOOT, - - START, - - STOP, - - DESTROY, - - UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static Action fromValue(String action) { - try { - return valueOf(checkNotNull(action, "action").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - private final URI href; - private final String id; - private final String ownerId; - @Nullable - private final String name; - private final URI image; - private final URI hardwareProfile; - private final URI realm; - private final State state; - private final Map actions; - @Nullable - private final Authentication authentication; - private final Set publicAddresses; - private final Set privateAddresses; - - public Instance(URI href, String id, String ownerId, @Nullable String name, URI image, URI hardwareProfile, - URI realm, State state, Map actions, @Nullable Authentication authentication, - Set publicAddresses, Set privateAddresses) { - this.href = checkNotNull(href, "href"); - this.id = checkNotNull(id, "id"); - this.ownerId = checkNotNull(ownerId, "ownerId"); - this.name = name; - this.image = checkNotNull(image, "image"); - this.hardwareProfile = checkNotNull(hardwareProfile, "hardwareProfile"); - this.realm = checkNotNull(realm, "realm"); - this.state = checkNotNull(state, "state"); - this.actions = ImmutableMap.copyOf(checkNotNull(actions, "actions")); - this.authentication = authentication; - this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses")); - this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses")); - } - - /** - * - * @return URL to manipulate a specific instance - */ - public URI getHref() { - return href; - } - - /** - * - * @return A unique identifier for the instance - */ - public String getId() { - return id; - } - - /** - * - * @return An opaque identifier which indicates the owner of an instance - */ - public String getOwnerId() { - return ownerId; - } - - /** - * - * @return An optional short label describing the instance - */ - @Nullable - public String getName() { - return name; - } - - /** - * - * @return - */ - public URI getImage() { - return image; - } - - /** - * - * @return a link to the hardware profile in use by the instance - */ - public URI getHardwareProfile() { - return hardwareProfile; - } - - /** - * - * @return a link to the realm where the instance is deployed - */ - public URI getRealm() { - return realm; - } - - /** - * - * @return indicator of the instance's current state - */ - public State getState() { - return state; - } - - /** - * - * @return valid actions for the instance, along with the URL which may be used to perform the - * action - */ - public Map getActions() { - return actions; - } - - /** - * - * @return authentication of the instance or null - */ - @Nullable - public Authentication getAuthentication() { - return authentication; - } - - /** - * - * @return publicly routable IP addresses or names for the instance - */ - public Set getPublicAddresses() { - return publicAddresses; - } - - /** - * - * @return Private network IP addresses or names for the instance - */ - public Set getPrivateAddresses() { - return privateAddresses; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((href == null) ? 0 : href.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; - Instance other = (Instance) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - return true; - } - - @Override - public String toString() { - return String - .format( - "[id=%s, href=%s, image=%s, name=%s, state=%s, realm=%s, ownerId=%s, hardwareProfile=%s, actions=%s, authentication=%s, privateAddresses=%s, publicAddresses=%s]", - id, href, image, name, state, realm, ownerId, hardwareProfile, actions, authentication, - privateAddresses, publicAddresses); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/KeyAuthentication.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/KeyAuthentication.java deleted file mode 100644 index a6960725ca..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/KeyAuthentication.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - - -/** - * - * @author Adrian Cole - */ -public class KeyAuthentication implements Instance.Authentication { - - private final String keyName; - - public KeyAuthentication(String keyName) { - this.keyName = checkNotNull(keyName, "keyName"); - } - - public String getKeyName() { - return keyName; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((keyName == null) ? 0 : keyName.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; - KeyAuthentication other = (KeyAuthentication) obj; - if (keyName == null) { - if (other.keyName != null) - return false; - } else if (!keyName.equals(other.keyName)) - return false; - return true; - } - - @Override - public String toString() { - return String.format("[keyName=%s]", keyName); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/ParameterizedHardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/ParameterizedHardwareProperty.java deleted file mode 100644 index 0ae5e253b4..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/ParameterizedHardwareProperty.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.deltacloud.domain.internal.BaseHardwareProperty; - -/** - * - * @author Adrian Cole - */ -public class ParameterizedHardwareProperty extends BaseHardwareProperty { - - private final HardwareParameter param; - - public ParameterizedHardwareProperty(Kind kind, String name, String unit, Object value, HardwareParameter param) { - super(kind, name, unit, value); - this.param = checkNotNull(param, "param"); - } - - /** - * - * @return how to associate a non-default value with a request against an instance. - */ - public HardwareParameter getParam() { - return param; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((param == null) ? 0 : param.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; - ParameterizedHardwareProperty other = (ParameterizedHardwareProperty) obj; - if (param == null) { - if (other.param != null) - return false; - } else if (!param.equals(other.param)) - return false; - return true; - } - - @Override - public String toString() { - return "[kind=" + getKind() + ", name=" + getName() + ", unit=" + getUnit() + ", value=" + getValue() - + ", param=" + getParam() + "]"; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/PasswordAuthentication.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/PasswordAuthentication.java deleted file mode 100644 index 3c4d2b77b3..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/PasswordAuthentication.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - - -import org.jclouds.domain.LoginCredentials; - -/** - * - * @author Adrian Cole - */ -public class PasswordAuthentication implements Instance.Authentication { - - private final LoginCredentials login; - - public PasswordAuthentication(LoginCredentials login) { - this.login = checkNotNull(login, "login"); - } - - public LoginCredentials getLoginCredentials() { - return login; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((login == null) ? 0 : login.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; - PasswordAuthentication other = (PasswordAuthentication) obj; - if (login == null) { - if (other.login != null) - return false; - } else if (!login.equals(other.login)) - return false; - return true; - } - - @Override - public String toString() { - return String.format("[login=%s]", login); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/RangeHardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/RangeHardwareProperty.java deleted file mode 100644 index f5ce06c2c2..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/RangeHardwareProperty.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public class RangeHardwareProperty extends ParameterizedHardwareProperty { - - private final Number first; - private final Number last; - - public RangeHardwareProperty(String name, String unit, Number value, HardwareParameter param, Number first, - Number last) { - super(Kind.FIXED, name, unit, value, param); - this.first = checkNotNull(first, "first"); - this.last = checkNotNull(last, "last"); - } - - /** - * - * @return minimum value - */ - public Number getFirst() { - return first; - } - - /** - * - * @return maximum value - */ - public Number getLast() { - return last; - } - - @Override - public String toString() { - return "[kind=" + getKind() + ", name=" + getName() + ", unit=" + getUnit() + ", value=" + getValue() - + ", param=" + getParam() + ", first=" + first + ", last=" + last + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((first == null) ? 0 : first.hashCode()); - result = prime * result + ((last == null) ? 0 : last.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; - RangeHardwareProperty other = (RangeHardwareProperty) obj; - if (first == null) { - if (other.first != null) - return false; - } else if (!first.equals(other.first)) - return false; - if (last == null) { - if (other.last != null) - return false; - } else if (!last.equals(other.last)) - return false; - return true; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Realm.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Realm.java deleted file mode 100644 index 4c9c3de174..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Realm.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.javax.annotation.Nullable; - -/** - * Within a cloud provider a realm represents a boundary containing resources. The exact definition - * of a realm is left to the cloud provider. In some cases, a realm may represent different - * datacenters, different continents, or different pools of resources within a single datacenter. A - * cloud provider may insist that resources must all exist within a single realm in order to - * cooperate. For instance, storage volumes may only be allowed to be mounted to instances within - * the same realm. - * - * @author Adrian Cole - */ -public class Realm { - public enum State { - - /** - * the realm is available - */ - AVAILABLE, - - /** - * the realm is unavailable - */ - UNAVAILABLE, - - /** - * state returned as something besides the above. - */ - UNRECOGNIZED; - - public static State fromValue(String state) { - try { - return valueOf(checkNotNull(state, "state")); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - private final URI href; - private final String id; - @Nullable - private final String limit; - private final String name; - private final State state; - - public Realm(URI href, String id, String name, @Nullable String limit, State state) { - this.href = checkNotNull(href, "href"); - this.id = checkNotNull(id, "id"); - this.name = checkNotNull(name, "name"); - this.limit = limit; - this.state = checkNotNull(state, "state"); - } - - /** - * - * @return URL to manipulate a specific realm - */ - public URI getHref() { - return href; - } - - /** - * - * @return A unique identifier for the realm - */ - public String getId() { - return id; - } - - /** - * - * @return A short label - */ - public String getName() { - return name; - } - - /** - * for example limitation of how many machine you can launch in given region / how much computing - * power is available for you. - * - * @return Limits applicable for the current requester - */ - @Nullable - public String getLimit() { - return limit; - } - - /** - * - * @return indicator of the realm's current state - */ - public State getState() { - return state; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((limit == null) ? 0 : limit.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((state == null) ? 0 : state.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; - Realm other = (Realm) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (limit == null) { - if (other.limit != null) - return false; - } else if (!limit.equals(other.limit)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (state != other.state) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + href + ", id=" + id + ", limit=" + limit + ", name=" + name + ", state=" + state + "]"; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Transition.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Transition.java deleted file mode 100644 index cbe83c045f..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/Transition.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -/** - * - * @author Adrian Cole - */ -public interface Transition { - Instance.State getTo(); -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionAutomatically.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionAutomatically.java deleted file mode 100644 index 881e2a9665..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionAutomatically.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public class TransitionAutomatically implements Transition { - private final Instance.State to; - - public TransitionAutomatically(Instance.State to) { - this.to = checkNotNull(to, "to"); - } - - public Instance.State getTo() { - return to; - } - - @Override - public String toString() { - return "[to=" + to + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((to == null) ? 0 : to.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; - TransitionAutomatically other = (TransitionAutomatically) obj; - if (to == null) { - if (other.to != null) - return false; - } else if (!to.equals(other.to)) - return false; - return true; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionOnAction.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionOnAction.java deleted file mode 100644 index 65ccb849ad..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/TransitionOnAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public class TransitionOnAction implements Transition { - private final Instance.Action action; - private final Instance.State to; - - public TransitionOnAction(Instance.Action action, Instance.State to) { - this.to = checkNotNull(to, "to"); - this.action = checkNotNull(action, "action"); - } - - public Instance.State getTo() { - return to; - } - - public Instance.Action getAction() { - return action; - } - - @Override - public String toString() { - return "[action=" + action + ", to=" + to + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((action == null) ? 0 : action.hashCode()); - result = prime * result + ((to == null) ? 0 : to.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; - TransitionOnAction other = (TransitionOnAction) obj; - if (action == null) { - if (other.action != null) - return false; - } else if (!action.equals(other.action)) - return false; - if (to != other.to) - return false; - return true; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/internal/BaseHardwareProperty.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/internal/BaseHardwareProperty.java deleted file mode 100644 index 5bc39afea9..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/domain/internal/BaseHardwareProperty.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.deltacloud.domain.HardwareProperty; - -/** - * - * @author Adrian Cole - */ -public class BaseHardwareProperty implements HardwareProperty { - private final Kind kind; - private final String name; - private final String unit; - private final Object value; - - public BaseHardwareProperty(Kind kind, String name, String unit, Object value) { - this.kind = checkNotNull(kind, "kind"); - this.name = checkNotNull(name, "name"); - this.unit = checkNotNull(unit, "unit"); - this.value = checkNotNull(value, "value"); - } - - /** - * {@inheritDoc} - */ - @Override - public Kind getKind() { - return kind; - } - - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - @Override - public String getUnit() { - return unit; - } - - /** - * {@inheritDoc} - */ - @Override - public Object getValue() { - return value; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((kind == null) ? 0 : kind.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((unit == null) ? 0 : unit.hashCode()); - result = prime * result + ((value == null) ? 0 : value.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; - BaseHardwareProperty other = (BaseHardwareProperty) obj; - if (kind != other.kind) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (unit == null) { - if (other.unit != null) - return false; - } else if (!unit.equals(other.unit)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "[kind=" + kind + ", name=" + name + ", unit=" + unit + ", value=" + value + "]"; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java deleted file mode 100644 index 0978ba4920..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.handlers; - -import java.io.IOException; - -import javax.annotation.Resource; -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.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; -import com.google.common.io.Closeables; - -/** - * - * @author Adrian Cole - * - */ -@Singleton -public class DeltacloudErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - String message = parseMessage(response); - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - try { - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - if (message.indexOf("ItemNotFound") != -1) { - exception = new ResourceNotFoundException(message, exception); - } else { - switch (response.getStatusCode()) { - case 400: - exception = new IllegalArgumentException(message, exception); - break; - case 401: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 405: - exception = new IllegalArgumentException(message, exception); - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - } - } finally { - Closeables.closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - public String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toString(response.getPayload()); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - response.getPayload().getInput().close(); - } catch (IOException e) { - Throwables.propagate(e); - } - } - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandler.java deleted file mode 100644 index 9d72a44a3c..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.handlers; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.handlers.BackoffLimitedRetryHandler; -import org.jclouds.http.handlers.RedirectionRetryHandler; - -/** - * Handles Retryable responses with error codes in the 3xx range - * - * @author Adrian Cole - */ -@Singleton -public class DeltacloudRedirectionRetryHandler extends RedirectionRetryHandler { - - @Inject - public DeltacloudRedirectionRetryHandler(BackoffLimitedRetryHandler backoffHandler) { - super(backoffHandler); - } - - @Override - public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { - if (command.getCurrentRequest().getMethod().equals("DELETE")) { - return false; - } else { - return super.shouldRetryRequest(command, response); - } - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/options/CreateInstanceOptions.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/options/CreateInstanceOptions.java deleted file mode 100644 index 33e489305d..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/options/CreateInstanceOptions.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Contains options supported in the Deltacloud API for the Create Instance operation.

- * Usage

The recommended way to instantiate a CreateInstanceOptions object is to statically - * import CreateInstanceOptions.Builder.* and invoke a static creation method followed by an - * instance mutator (if needed): - *

- * - * import static org.jclouds.deltacloud.options.CreateInstanceOptions.Builder.* - *

- * DeltacloudClient connection = // get connection - * ListenableFuture instance = client.createInstance(collection, "imageId", named("robot")); - * - * - * @author Adrian Cole - * @see - */ -public class CreateInstanceOptions extends BaseHttpRequestOptions { - public static final CreateInstanceOptions NONE = new CreateInstanceOptions(); - - /** - * A short label to identify the instance. - * - */ - public CreateInstanceOptions named(String name) { - formParameters.put("name", checkNotNull(name, "name")); - return this; - } - - /** - * The realm in which to launch the instance - * - */ - public CreateInstanceOptions realm(String realmId) { - formParameters.put("realm_id", checkNotNull(realmId, "realmId")); - return this; - } - - /** - * The hardware profile upon which to launch the instance - */ - public CreateInstanceOptions hardwareProfile(String hwpName) { - formParameters.put("hwp_name", checkNotNull(hwpName, "hwpName")); - return this; - } - - public String getName() { - return this.getFirstFormOrNull("name"); - } - - public static class Builder { - - /** - * @see CreateInstanceOptions#named - */ - public static CreateInstanceOptions named(String name) { - CreateInstanceOptions options = new CreateInstanceOptions(); - return options.named(name); - } - - /** - * @see CreateInstanceOptions#realm - */ - public static CreateInstanceOptions realm(String realmId) { - CreateInstanceOptions options = new CreateInstanceOptions(); - return options.realm(realmId); - } - - /** - * @see CreateInstanceOptions#hardwareProfile - */ - public static CreateInstanceOptions hardwareProfile(String hwpName) { - CreateInstanceOptions options = new CreateInstanceOptions(); - return options.hardwareProfile(hwpName); - } - - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceFinished.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceFinished.java deleted file mode 100644 index e9c9b9c762..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceFinished.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.predicates; - -import javax.inject.Singleton; - -import org.jclouds.deltacloud.DeltacloudClient; -import org.jclouds.deltacloud.domain.Instance; - -import com.google.inject.Inject; - -/** - * - * Tests to see if a instance is terminated - * - * @author Adrian Cole - */ -@Singleton -public class InstanceFinished extends InstanceState { - - @Inject - public InstanceFinished(DeltacloudClient client) { - super(client); - } - - @Override - protected Instance.State getState() { - return Instance.State.FINISH; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceRunning.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceRunning.java deleted file mode 100644 index efdf684d14..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceRunning.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.predicates; - -import javax.inject.Singleton; - -import org.jclouds.deltacloud.DeltacloudClient; -import org.jclouds.deltacloud.domain.Instance; - -import com.google.inject.Inject; - -/** - * - * Tests to see if a instance is running - * - * @author Adrian Cole - */ -@Singleton -public class InstanceRunning extends InstanceState { - - @Inject - public InstanceRunning(DeltacloudClient client) { - super(client); - } - - @Override - protected Instance.State getState() { - return Instance.State.RUNNING; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceState.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceState.java deleted file mode 100644 index e481e2cad7..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/predicates/InstanceState.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.deltacloud.DeltacloudClient; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * - * Tests to see if a instance is at a specific state - * - * @author Adrian Cole - */ -@Singleton -public abstract class InstanceState implements Predicate { - - private final DeltacloudClient client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public InstanceState(DeltacloudClient client) { - this.client = client; - } - - public boolean apply(Instance instance) { - logger.trace("looking for state on instance %s", checkNotNull(instance, "instance")); - instance = refresh(instance); - if (instance == null || instance.getState() == Instance.State.FINISH) - return false; - logger.trace("%s: looking for instance state %s: currently: %s", instance.getId(), getState(), instance - .getState()); - return instance.getState() == getState(); - } - - protected abstract Instance.State getState(); - - private Instance refresh(Instance instance) { - return client.getInstance(instance.getHref()); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionHandler.java deleted file mode 100644 index 58999275f6..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.domain.Feature; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class DeltacloudCollectionHandler extends ParseSax.HandlerWithResult { - private URI href; - private String rel; - private Set features = Sets.newLinkedHashSet(); - - private DeltacloudCollection realm; - - public DeltacloudCollection getResult() { - return realm; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equalsIgnoreCase("link")) { - this.href = URI.create(attributes.get("href")); - this.rel = attributes.get("rel"); - } else if (qName.equalsIgnoreCase("feature")) { - features.add(new Feature(attributes.get("name"))); - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("link")) { - this.realm = new DeltacloudCollection(href, rel, features); - this.href = null; - this.rel = null; - this.features = Sets.newLinkedHashSet(); - } - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandler.java deleted file mode 100644 index f08e1bf0aa..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class DeltacloudCollectionsHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set links = Sets.newLinkedHashSet(); - private final DeltacloudCollectionHandler linkHandler; - - @Inject - public DeltacloudCollectionsHandler(DeltacloudCollectionHandler linkHandler) { - this.linkHandler = linkHandler; - } - - public Set getResult() { - return links; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - linkHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - linkHandler.endElement(uri, localName, qName); - if (qName.equals("link") && currentText.toString().trim().equals("")) { - this.links.add(linkHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfileHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfileHandler.java deleted file mode 100644 index 4ebffa817b..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfileHandler.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class HardwareProfileHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - private final HardwarePropertyHandler propertyHandler; - - @Inject - HardwareProfileHandler(HardwarePropertyHandler propertyHandler) { - this.propertyHandler = propertyHandler; - } - - private URI href; - private String id; - private String name; - private Set properties = Sets.newLinkedHashSet(); - private boolean inProperty; - - private HardwareProfile profile; - - public HardwareProfile getResult() { - return profile; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equals("property")) { - inProperty = true; - } - - if (inProperty) { - propertyHandler.startElement(uri, localName, qName, attrs); - } else if (qName.equals("hardware_profile")) { - String href = attributes.get("href"); - if (href != null) { - this.href = URI.create(href); - } - this.id = attributes.get("id"); - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - - if (inProperty) - propertyHandler.endElement(uri, localName, qName); - - if (qName.endsWith("property")) { - inProperty = false; - this.properties.add(propertyHandler.getResult()); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("hardware_profile")) { - this.profile = new HardwareProfile(href, id, name, properties); - this.href = null; - this.id = null; - this.name = null; - this.properties = Sets.newLinkedHashSet(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfilesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfilesHandler.java deleted file mode 100644 index beb6aac3ac..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwareProfilesHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class HardwareProfilesHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set hardwareProfiles = Sets.newLinkedHashSet(); - private final HardwareProfileHandler hardwareProfileHandler; - - @Inject - public HardwareProfilesHandler(HardwareProfileHandler locationHandler) { - this.hardwareProfileHandler = locationHandler; - } - - public Set getResult() { - return hardwareProfiles; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - hardwareProfileHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - hardwareProfileHandler.endElement(uri, localName, qName); - if (qName.equals("hardware_profile") && currentText.toString().trim().equals("")) { - this.hardwareProfiles.add(hardwareProfileHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - hardwareProfileHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java deleted file mode 100644 index 474e8a8539..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.net.URI; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -import org.jclouds.deltacloud.domain.EnumHardwareProperty; -import org.jclouds.deltacloud.domain.FixedHardwareProperty; -import org.jclouds.deltacloud.domain.HardwareParameter; -import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.deltacloud.domain.RangeHardwareProperty; -import org.jclouds.deltacloud.domain.HardwareProperty.Kind; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class HardwarePropertyHandler extends ParseSax.HandlerWithResult { - private Kind kind; - private String name; - private String unit; - private Object value; - private HardwareParameter param; - private Set availableValues = Sets.newLinkedHashSet(); - private Number first; - private Number last; - - /** - * resets state of the handler when called. - * - * @return property or null - */ - public HardwareProperty getResult() { - try { - switch (kind) { - case FIXED: - return new FixedHardwareProperty(name, unit, value); - case ENUM: - return new EnumHardwareProperty(name, unit, value, param, availableValues); - case RANGE: - return new RangeHardwareProperty(name, unit, (Number) value, param, first, last); - default: - return null; - } - } finally { - this.kind = null; - this.name = null; - this.unit = null; - this.value = null; - this.param = null; - this.availableValues = Sets.newLinkedHashSet(); - this.first = null; - this.last = null; - } - } - - private static final Pattern LONG = Pattern.compile("^[0-9]+$"); - private static final Pattern DOUBLE = Pattern.compile("^[0-9]+\\.[0-9]+$"); - - @Nullable public static - Number parseNumberOrNull(String in) { - if (DOUBLE.matcher(in).matches()) - return new Double(in); - else if (LONG.matcher(in).matches()) - return Long.valueOf(in); - return null; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equals("property")) { - this.kind = Kind.fromValue(attributes.get("kind")); - this.name = attributes.get("name"); - this.unit = attributes.get("unit"); - if (attributes.containsKey("value")) { - this.value = stringOrNumber(attributes.get("value")); - } - } else if (qName.equals("param")) { - this.param = new HardwareParameter(URI.create(attributes.get("href")), attributes.get("method"), - attributes.get("name"), attributes.get("operation")); - } else if (qName.equals("range")) { - this.first = parseNumberOrNull(attributes.get("first")); - this.last = parseNumberOrNull(attributes.get("last")); - } else if (qName.equals("entry")) { - this.availableValues.add(stringOrNumber(attributes.get("value"))); - } - } - - public static Object stringOrNumber(String in) { - Number number = parseNumberOrNull(in); - return number != null ? number : in; - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImageHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImageHandler.java deleted file mode 100644 index 75db2bee00..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImageHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class ImageHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private URI href; - private String id; - private String ownerId; - private String name; - private String description; - private String architecture; - - private Image image; - - public Image getResult() { - return image; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equals("image")) { - String href = attributes.get("href"); - if (href != null) { - this.href = URI.create(href); - } - this.id = attributes.get("id"); - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("owner_id")) { - this.ownerId = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("description")) { - this.description = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("architecture")) { - this.architecture = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("image")) { - this.image = new Image(href, id, ownerId, name, description, architecture); - this.href = null; - this.id = null; - this.ownerId = null; - this.name = null; - this.description = null; - this.architecture = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImagesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImagesHandler.java deleted file mode 100644 index ceed234965..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/ImagesHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class ImagesHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set images = Sets.newLinkedHashSet(); - private final ImageHandler imageHandler; - - @Inject - public ImagesHandler(ImageHandler locationHandler) { - this.imageHandler = locationHandler; - } - - public Set getResult() { - return images; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - imageHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - imageHandler.endElement(uri, localName, qName); - if (qName.equals("image") && currentText.toString().trim().equals("")) { - this.images.add(imageHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - imageHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java deleted file mode 100644 index 00d82fb5f1..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; - -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.KeyAuthentication; -import org.jclouds.deltacloud.domain.PasswordAuthentication; -import org.jclouds.deltacloud.domain.Instance.Authentication; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.domain.LoginCredentials.Builder; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class InstanceHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - @Resource - protected Logger logger = Logger.NULL; - - private URI href; - private String id; - private String ownerId; - private String name; - private URI image; - private URI hardwareProfile; - private URI realm; - private Instance.State state; - private Map actions = Maps.newLinkedHashMap(); - private Set publicAddresses = Sets.newLinkedHashSet(); - private Set privateAddresses = Sets.newLinkedHashSet(); - - private boolean inPublicAddresses; - private boolean inPrivateAddresses; - - private Instance instance; - - private Builder credentialsBuilder = LoginCredentials.builder(); - private String keyName; - private Authentication authentication; - - public Instance getResult() { - return instance; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equals("public_addresses")) { - inPublicAddresses = true; - } else if (qName.equals("private_addresses")) { - inPrivateAddresses = true; - } else if (qName.equals("instance")) { - String href = attributes.get("href"); - if (href != null) { - this.href = URI.create(href); - } - this.id = attributes.get("id"); - } else if (qName.equals("link")) { - try { - Instance.Action action = Instance.Action.fromValue(attributes.get("rel")); - if (action != Instance.Action.UNRECOGNIZED) { - HttpRequest request = HttpRequest.builder().method(attributes.get("method").toUpperCase()).endpoint(attributes - .get("href")).build(); - actions.put(action, request); - } - } catch (RuntimeException e) { - if (logger.isDebugEnabled()) - logger.warn(e, "error parsing into action: %s, %s", qName, attributes); - } - } else if (attributes.containsKey("href")) { - URI href = URI.create(attributes.get("href")); - if (qName.equals("image")) - this.image = href; - else if (qName.equals("hardware_profile")) - this.hardwareProfile = href; - else if (qName.equals("realm")) - this.realm = href; - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.endsWith("public_addresses")) { - inPublicAddresses = false; - } else if (qName.endsWith("private_addresses")) { - inPrivateAddresses = false; - } - if (qName.equalsIgnoreCase("owner_id")) { - this.ownerId = currentOrNull(currentText); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentOrNull(currentText); - } else if (qName.equalsIgnoreCase("keyname")) { - this.keyName = currentOrNull(currentText); - } else if (qName.equalsIgnoreCase("username")) { - this.credentialsBuilder.user(currentOrNull(currentText)); - } else if (qName.equalsIgnoreCase("password")) { - this.credentialsBuilder.password(currentOrNull(currentText)); - } else if (qName.equalsIgnoreCase("authentication")) { - if (keyName != null) { - this.authentication = new KeyAuthentication(keyName); - } else { - LoginCredentials creds = credentialsBuilder.build(); - if (creds != null && creds.identity != null) - this.authentication = new PasswordAuthentication(creds); - } - this.keyName = null; - this.credentialsBuilder = LoginCredentials.builder(); - } else if (qName.equalsIgnoreCase("state")) { - this.state = Instance.State.fromValue(currentOrNull(currentText)); - } else if (qName.equalsIgnoreCase("address")) { - if (inPublicAddresses) - this.publicAddresses.add(currentOrNull(currentText)); - else if (inPrivateAddresses) - this.privateAddresses.add(currentOrNull(currentText)); - } else if (qName.equalsIgnoreCase("instance")) { - this.instance = new Instance(href, id, ownerId, name, image, hardwareProfile, realm, state, actions, - authentication, publicAddresses, privateAddresses); - this.href = null; - this.id = null; - this.ownerId = null; - this.name = null; - this.image = null; - this.hardwareProfile = null; - this.realm = null; - this.state = null; - this.authentication = null; - this.actions = Maps.newLinkedHashMap(); - this.publicAddresses = Sets.newLinkedHashSet(); - this.privateAddresses = Sets.newLinkedHashSet(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java deleted file mode 100644 index 3be3d3fcbc..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Map; - -import javax.annotation.Resource; - -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.domain.TransitionAutomatically; -import org.jclouds.deltacloud.domain.TransitionOnAction; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; - -/** - * @author Adrian Cole - */ -public class InstanceStatesHandler extends ParseSax.HandlerWithResult> { - - @Resource - protected Logger logger = Logger.NULL; - - private Multimap states = LinkedHashMultimap.create(); - private State state; - - public Multimap getResult() { - return states; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.equals("state")) { - state = instanceStateWarningOnUnrecognized(attributes.get("name")); - } else if (qName.equals("transition")) { - if (attributes.containsKey("auto")) - states.put(state, new TransitionAutomatically(instanceStateWarningOnUnrecognized(attributes.get("to")))); - else - states.put(state, new TransitionOnAction(instanceActionWarningOnUnrecognized(attributes.get("action")), - instanceStateWarningOnUnrecognized(attributes.get("to")))); - } - } - - State instanceStateWarningOnUnrecognized(String input) { - State state = State.fromValue(input); - if (state == State.UNRECOGNIZED) - logger.warn("unrecognized state: %s", input); - return state; - } - - Action instanceActionWarningOnUnrecognized(String input) { - Action action = Action.fromValue(input); - if (action == Action.UNRECOGNIZED) - logger.warn("unrecognized action: %s", input); - return action; - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstancesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstancesHandler.java deleted file mode 100644 index 7bf352eddc..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstancesHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class InstancesHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set instances = Sets.newLinkedHashSet(); - private final InstanceHandler instanceHandler; - - @Inject - public InstancesHandler(InstanceHandler locationHandler) { - this.instanceHandler = locationHandler; - } - - public Set getResult() { - return instances; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - instanceHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - instanceHandler.endElement(uri, localName, qName); - if (qName.equals("instance") && currentText.toString().trim().equals("")) { - this.instances.add(instanceHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - instanceHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmHandler.java deleted file mode 100644 index 053b5ac781..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.deltacloud.domain.Realm.State; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class RealmHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private URI href; - private String id; - private String name; - private String limit; - private State state; - - private Realm realm; - - public Realm getResult() { - return realm; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (attributes.containsKey("href")) { - this.href = URI.create(attributes.get("href")); - this.id = attributes.get("id"); - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("limit")) { - this.limit = currentText.toString().trim(); - if ("".equals(limit)) - limit = null; - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("state")) { - this.state = State.fromValue(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("realm")) { - this.realm = new Realm(href, id, name, limit, state); - this.href = null; - this.id = null; - this.name = null; - this.limit = null; - this.state = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmsHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmsHandler.java deleted file mode 100644 index ec7b445cd0..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/RealmsHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class RealmsHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set realms = Sets.newLinkedHashSet(); - private final RealmHandler realmHandler; - - @Inject - public RealmsHandler(RealmHandler realmHandler) { - this.realmHandler = realmHandler; - } - - public Set getResult() { - return realms; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - realmHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - realmHandler.endElement(uri, localName, qName); - if (qName.equals("realm") && currentText.toString().trim().equals("")) { - this.realms.add(realmHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - realmHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 834ff5d1aa..0000000000 --- a/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.deltacloud.DeltacloudApiMetadata \ No newline at end of file diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java deleted file mode 100644 index da1263f079..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "DeltacloudApiMetadataTest") -public class DeltacloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public DeltacloudApiMetadataTest() { - super(new DeltacloudApiMetadata()); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java deleted file mode 100644 index 882c089ff5..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java +++ /dev/null @@ -1,339 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URI; -import java.util.Set; - -import org.jclouds.Fallbacks.EmptyMultimapOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.deltacloud.DeltacloudFallbacks.VoidOnRedirectedDelete; -import org.jclouds.deltacloud.config.DeltacloudRestClientModule; -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.options.CreateInstanceOptions; -import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler; -import org.jclouds.deltacloud.xml.HardwareProfileHandler; -import org.jclouds.deltacloud.xml.HardwareProfilesHandler; -import org.jclouds.deltacloud.xml.ImageHandler; -import org.jclouds.deltacloud.xml.ImagesHandler; -import org.jclouds.deltacloud.xml.InstanceHandler; -import org.jclouds.deltacloud.xml.InstanceStatesHandler; -import org.jclouds.deltacloud.xml.InstancesHandler; -import org.jclouds.deltacloud.xml.RealmHandler; -import org.jclouds.deltacloud.xml.RealmsHandler; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseAsyncClientTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.Iterables; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code DeltacloudAsyncClient} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "DeltacloudAsyncClientTest") -public class DeltacloudAsyncClientTest extends BaseAsyncClientTest { - public void testGetCollections() throws SecurityException, NoSuchMethodException, IOException { - Method method = DeltacloudAsyncClient.class.getMethod("getCollections"); - HttpRequest httpRequest = processor.createRequest(method); - - assertRequestLineEquals(httpRequest, "GET http://localhost:3001/api HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - - assertRequestLineEquals(httpRequest, "GET http://localhost:3001/api HTTP/1.1"); - // for example, using basic authentication, we should get "only one" - // header - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseSax.class); - assertSaxResponseParserClassEquals(method, DeltacloudCollectionsHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testGetInstanceStates() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("getInstanceStates"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost:3001/api/instance_states HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, InstanceStatesHandler.class); - assertFallbackClassEquals(method, EmptyMultimapOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListRealms() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("listRealms"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost:3001/api/realms HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, RealmsHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetRealm() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("getRealm", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("https://delta/realm1")); - - assertRequestLineEquals(request, "GET https://delta/realm1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, RealmHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListImages() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("listImages"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost:3001/api/images HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, ImagesHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("getImage", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("https://delta/image1")); - - assertRequestLineEquals(request, "GET https://delta/image1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, ImageHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListHardwareProfiles() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("listHardwareProfiles"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost:3001/api/profiles HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, HardwareProfilesHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetHardwareProfile() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("getHardwareProfile", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("https://delta/profile1")); - - assertRequestLineEquals(request, "GET https://delta/profile1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, HardwareProfileHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListInstances() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("listInstances"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost:3001/api/instances HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, InstancesHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetInstance() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("getInstance", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("https://delta/instance1")); - - assertRequestLineEquals(request, "GET https://delta/instance1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, InstanceHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateInstance() throws SecurityException, NoSuchMethodException, IOException { - Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class, - CreateInstanceOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, "imageId-1"); - - assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n"); - assertPayloadEquals(httpRequest, "image_id=imageId-1", "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, httpRequest, ParseSax.class); - assertSaxResponseParserClassEquals(method, InstanceHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testCreateInstanceWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class, - CreateInstanceOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, "imageId-1", - CreateInstanceOptions.Builder.named("foo")); - - assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n"); - assertPayloadEquals(httpRequest, "image_id=imageId-1&name=foo", "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, httpRequest, ParseSax.class); - assertSaxResponseParserClassEquals(method, InstanceHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testPerformAction() throws IOException, SecurityException, NoSuchMethodException { - Method method = DeltacloudAsyncClient.class.getMethod("performAction", HttpRequest.class); - HttpRequest request = processor.createRequest(method, - HttpRequest.builder().method("POST").endpoint("https://delta/instance1/reboot").build()); - - assertRequestLineEquals(request, "POST https://delta/instance1/reboot HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnRedirectedDelete.class); - - checkFilters(request); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class); - } - - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected Module createModule() { - return new DeltacloudRestClientModuleExtension(); - } - - @ConfiguresRestClient - public static class DeltacloudRestClientModuleExtension extends DeltacloudRestClientModule { - - @Override - protected Supplier> provideCollections(long seconds, DeltacloudClient client) { - return Suppliers.ofInstance(null); - } - - @Override - protected Supplier provideImageCollection(Supplier> collectionSupplier) { - return Suppliers.ofInstance(URI.create("http://localhost:3001/api/images")); - } - - @Override - protected Supplier provideHardwareProfileCollection( - Supplier> collectionSupplier) { - return Suppliers.ofInstance(URI.create("http://localhost:3001/api/profiles")); - } - - @Override - protected Supplier provideInstanceCollection(Supplier> collectionSupplier) { - return Suppliers.ofInstance(URI.create("http://localhost:3001/api/instances")); - } - - @Override - protected Supplier provideRealmCollection(Supplier> collectionSupplier) { - return Suppliers.ofInstance(URI.create("http://localhost:3001/api/realms")); - } - - @Override - protected Supplier provideInstanceStateCollection( - Supplier> collectionSupplier) { - return Suppliers.ofInstance(URI.create("http://localhost:3001/api/instance_states")); - } - } - - protected ApiMetadata createApiMetadata() { - return new DeltacloudApiMetadata(); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java deleted file mode 100644 index ba34d5e4d4..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.logging.Logger; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.PasswordAuthentication; -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.domain.TransitionOnAction; -import org.jclouds.deltacloud.options.CreateInstanceOptions; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.ssh.SshClient; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.common.net.HostAndPort; -import com.google.gson.Gson; -import com.google.inject.Guice; - -/** - * Tests behavior of {@code DeltacloudClient} - * - * @author Adrian Cole - */ -@Test(groups = "live", sequential = true, testName = "DeltacloudClientLiveTest") -public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest { - - protected String prefix = System.getProperty("user.name") + ".test"; - protected Instance instance; - protected LoginCredentials creds; - - public void testCreateInstance() throws Exception { - Logger.getAnonymousLogger().info("starting instance"); - instance = client.createInstance(Iterables.find(client.listImages(), new Predicate() { - - @Override - public boolean apply(Image input) { - return input.getDescription().toLowerCase().indexOf("fedora") != -1; - } - - }).getId(), CreateInstanceOptions.Builder.named(prefix).hardwareProfile("1").realm("us")); - if (instance.getAuthentication() != null && instance.getAuthentication() instanceof PasswordAuthentication) - creds = PasswordAuthentication.class.cast(instance.getAuthentication()).getLoginCredentials(); - refreshInstance(); - checkStartedInstance(); - - Instance newInfo = client.getInstance(instance.getHref()); - checkInstanceMatchesGet(newInfo); - } - - protected void checkInstanceMatchesGet(Instance newInfo) { - assertEquals(newInfo.getHref(), instance.getHref()); - } - - protected void checkStartedInstance() { - System.out.println(new Gson().toJson(instance)); - assertEquals(instance.getName(), prefix); - assert stateChanges.get(Instance.State.RUNNING).apply(instance) : instance; - refreshInstance(); - assertEquals(instance.getState(), Instance.State.RUNNING); - } - - private Instance refreshInstance() { - if (instance != null) - return instance = client.getInstance(instance.getHref()); - return null; - } - - @Test(dependsOnMethods = "testCreateInstance") - public void testConnectivity() throws Exception { - Logger.getAnonymousLogger().info("awaiting ssh"); - assert socketTester.apply(HostAndPort.fromParts(Iterables.get(instance.getPublicAddresses(), 0), 22)) : instance; - if (creds != null) { - Logger.getAnonymousLogger().info("will connect ssh"); - doConnectViaSsh(instance, creds); - } - } - - public HttpRequest getAction(Instance.Action action) { - return instance.getActions().get(action); - } - - @Test(dependsOnMethods = "testConnectivity") - public void testLifeCycle() { - - HttpRequest rebootUri = getAction(Instance.Action.REBOOT); - if (rebootUri != null) { - client.performAction(rebootUri); - assert stateChanges.get(Instance.State.RUNNING).apply(instance) : instance; - } - } - - @Test(dependsOnMethods = "testLifeCycle") - public void testDestroyInstance() { - for (Transition transition : findChainTo(Instance.State.FINISH, refreshInstance().getState(), client - .getInstanceStates())) { - if (refreshInstance() == null) - break; - if (transition instanceof TransitionOnAction) { - client.performAction(getAction(TransitionOnAction.class.cast(transition).getAction())); - } - Predicate stateTester = stateChanges.get(transition.getTo()); - if (stateTester != null) - assert stateTester.apply(instance) : transition + " : " + instance; - else - Logger.getAnonymousLogger().warning(String.format("no state tester for: %s", transition)); - } - assert refreshInstance() == null; - } - - protected void doConnectViaSsh(Instance instance, LoginCredentials creds) throws IOException { - SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create( - HostAndPort.fromParts(Iterables.get(instance.getPublicAddresses(), 0), 22), creds); - try { - ssh.connect(); - ExecResponse hello = ssh.exec("echo hello"); - assertEquals(hello.getOutput().trim(), "hello"); - System.err.println(ssh.exec("df -k").getOutput()); - System.err.println(ssh.exec("mount").getOutput()); - System.err.println(ssh.exec("uname -a").getOutput()); - } finally { - if (ssh != null) - ssh.disconnect(); - } - } - - @Override - @AfterClass(groups = { "integration", "live" }) - protected void tearDownContext() { - testDestroyInstance(); - super.tearDownContext(); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java deleted file mode 100644 index 39a9d8288e..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.predicates.InstanceFinished; -import org.jclouds.deltacloud.predicates.InstanceRunning; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; -import com.google.common.net.HostAndPort; -import com.google.inject.Module; - -/** - * Tests behavior of {@code DeltacloudClient} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest") -public class ReadOnlyDeltacloudClientLiveTest extends BaseComputeServiceContextLiveTest { - - public ReadOnlyDeltacloudClientLiveTest() { - provider = "deltacloud"; - } - - protected DeltacloudClient client; - - protected Predicate socketTester; - protected ImmutableMap> stateChanges; - - @Override - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.setupContext(); - client = view.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi(); - socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS); - stateChanges = ImmutableMap.> of(// - Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, - TimeUnit.SECONDS),// - Instance.State.FINISH, new RetryablePredicate(new InstanceFinished(client), 30, 1, - TimeUnit.SECONDS)// - ); - } - - @Test - public void testGetLinksContainsAll() throws Exception { - Set links = client.getCollections(); - assertNotNull(links); - } - - @Test - public void testGetInstanceStatesCanGoFromStartToFinish() throws Exception { - Multimap states = client.getInstanceStates(); - assertNotNull(states); - Iterable toFinishFromStart = findChainTo(Instance.State.FINISH, Instance.State.START, states); - assert Iterables.size(toFinishFromStart) > 0 : toFinishFromStart; - Iterable toRunningFromStart = findChainTo(Instance.State.RUNNING, Instance.State.START, states); - assert Iterables.size(toRunningFromStart) > 0 : toRunningFromStart; - Iterable toFinishFromRunning = findChainTo(Instance.State.FINISH, Instance.State.RUNNING, states); - assert Iterables.size(toFinishFromRunning) > 0 : toFinishFromRunning; - assertEquals(ImmutableList.copyOf(Iterables.concat(toRunningFromStart, toFinishFromRunning)), ImmutableList - .copyOf(toFinishFromStart)); - } - - Iterable findChainTo(Instance.State desired, Instance.State currentState, - Multimap states) { - for (Transition transition : states.get(currentState)) { - if (currentState.ordinal() >= transition.getTo().ordinal()) - continue; - if (transition.getTo() == desired) - return ImmutableSet. of(transition); - Iterable transitions = findChainTo(desired, transition.getTo(), states); - if (Iterables.size(transitions) > 0) - return Iterables.concat(ImmutableSet.of(transition), transitions); - } - return ImmutableSet. of(); - } - - public void testListAndGetRealms() throws Exception { - Set response = client.listRealms(); - assert null != response; - long realmCount = response.size(); - assertTrue(realmCount >= 0); - for (Realm realm : response) { - Realm newDetails = client.getRealm(realm.getHref()); - assertEquals(realm, newDetails); - } - } - - public void testListAndGetImages() throws Exception { - Set response = client.listImages(); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 0); - for (Image image : response) { - Image newDetails = client.getImage(image.getHref()); - assertEquals(image, newDetails); - } - } - - public void testListAndGetHardwareProfiles() throws Exception { - Set response = client.listHardwareProfiles(); - assert null != response; - long profileCount = response.size(); - assertTrue(profileCount >= 0); - for (HardwareProfile profile : response) { - HardwareProfile newDetails = client.getHardwareProfile(profile.getHref()); - assertEquals(profile, newDetails); - } - } - - public void testListAndGetInstances() throws Exception { - Set response = client.listInstances(); - assert null != response; - long instanceCount = response.size(); - assertTrue(instanceCount >= 0); - for (Instance instance : response) { - Instance newDetails = client.getInstance(instance.getHref()); - assertEquals(instance, newDetails); - } - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java deleted file mode 100644 index 55ce6df8ac..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.domain.LocationScope; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Module; - -/** - * - * - * @author Adrian Cole - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "DeltacloudComputeServiceLiveTest") -public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public DeltacloudComputeServiceLiveTest() { - provider = "deltacloud"; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - // deltacloud does not support metadata - @Override - protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { - assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format( - "node userMetadata did not match %s %s", userMetadata, node); - } - - @Override - protected void checkNodes(Iterable nodes, String group, String task) throws IOException { - super.checkNodes(nodes, group, task); - for (NodeMetadata node : nodes) { - assertEquals(node.getLocation().getScope(), LocationScope.ZONE); - } - } - - @Test(enabled = true, dependsOnMethods = "testReboot", expectedExceptions = UnsupportedOperationException.class) - public void testSuspendResume() throws Exception { - super.testSuspendResume(); - } - - @Test(enabled = true, dependsOnMethods = "testSuspendResume") - @Override - public void testGetNodesWithDetails() throws Exception { - super.testGetNodesWithDetails(); - } - - @Test(enabled = true, dependsOnMethods = "testSuspendResume") - @Override - public void testListNodes() throws Exception { - super.testListNodes(); - } - - @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" }) - @Override - public void testDestroyNodes() { - super.testDestroyNodes(); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java deleted file mode 100644 index acbda95347..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.util.Set; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public DeltacloudTemplateBuilderLiveTest() { - provider = "deltacloud"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; - case DEBIAN: - return !(input.version.equals("6.0")) && input.is64Bit; - case CENTOS: - return !(input.version.matches("5.[023]") || input.version.equals("8.04")) && input.is64Bit; - case WINDOWS: - return input.version.equals("2008 SP2") || input.version.equals("") - || (input.version.equals("2008 R2") && input.is64Bit); - default: - return false; - } - } - - }); - } - - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "http://localhost:3001/api/realms/us"); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of(); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandlerTest.java deleted file mode 100644 index d63d18cd9b..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandlerTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.handlers; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class DeltacloudErrorHandlerTest { - - @Test - public void test400MakesIllegalArgumentException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 400, "", "Bad Request", - IllegalArgumentException.class); - } - - @Test - public void test401MakesAuthorizationException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 401, "", "Unauthorized", - AuthorizationException.class); - } - - @Test - public void test404MakesResourceNotFoundException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 404, "", "Not Found", - ResourceNotFoundException.class); - } - - @Test - public void testItemNotFoundMakesResourceNotFoundException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 500, "", "ItemNotFound", - ResourceNotFoundException.class); - } - - @Test - public void test405MakesIllegalArgumentException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 405, "", "Method Not Allowed", - IllegalArgumentException.class); - } - - @Test - public void test409MakesIllegalStateException() { - assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 409, "", "Conflict", IllegalStateException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - DeltacloudErrorHandler function = Guice.createInjector().getInstance(DeltacloudErrorHandler.class); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java deleted file mode 100644 index 5b7814fc28..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.handlers; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -import org.jclouds.ContextBuilder; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.inject.Injector; - -/** - * Tests behavior of {@code DeltacloudRedirectionRetry} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class DeltacloudRedirectionRetryHandlerTest { - Injector injector = ContextBuilder.newBuilder("stub").buildInjector(); - - @Test - public void test302DoesNotRetryOnDelete() { - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method("DELETE").endpoint("http://localhost").build(); - HttpResponse response = HttpResponse.builder().statusCode(302).message("HTTP/1.1 302 Found").build(); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - - replay(command); - - DeltacloudRedirectionRetryHandler retry = injector.getInstance( - DeltacloudRedirectionRetryHandler.class); - - assert !retry.shouldRetryRequest(command, response); - - verify(command); - - } - - @Test - public void test302DoesRetryOnGET() { - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build(); - HttpResponse response = HttpResponse.builder().statusCode(302).message("HTTP/1.1 302 Found").build(); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - expect(command.incrementRedirectCount()).andReturn(1); - - replay(command); - - DeltacloudRedirectionRetryHandler retry = injector.getInstance( - DeltacloudRedirectionRetryHandler.class); - - assert !retry.shouldRetryRequest(command, response); - - verify(command); - - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java deleted file mode 100644 index 3f6c359ac8..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.options; - -import static org.jclouds.deltacloud.options.CreateInstanceOptions.Builder.named; -import static org.testng.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of CreateInstanceOptions and CreateInstanceOptions.Builder.* - * - * @author Adrian Cole - */ -public class CreateInstanceOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(CreateInstanceOptions.class); - assert !String.class.isAssignableFrom(CreateInstanceOptions.class); - } - - @Test - public void testWithNamed() { - CreateInstanceOptions options = new CreateInstanceOptions(); - options.named("test"); - assertEquals(options.buildFormParameters().get("name"), ImmutableList.of("test")); - } - - @Test - public void testNullWithNamed() { - CreateInstanceOptions options = new CreateInstanceOptions(); - assertEquals(options.buildFormParameters().get("name"), ImmutableList.of()); - } - - @Test - public void testWithNamedStatic() { - CreateInstanceOptions options = named("test"); - assertEquals(options.buildFormParameters().get("name"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithNamedNPE() { - named(null); - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandlerTest.java deleted file mode 100644 index 8df04ba6dc..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/DeltacloudCollectionsHandlerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.deltacloud.domain.DeltacloudCollection; -import org.jclouds.deltacloud.domain.Feature; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code DeltacloudCollectionsHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DeltacloudCollectionsHandlerTest") -public class DeltacloudCollectionsHandlerTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/links.xml"); - Set expects = ImmutableSet.of( - new DeltacloudCollection(URI.create("http://localhost:3001/api/realms"), "realms"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/images"), "images"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/instance_states"), "instance_states"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/instances"), "instances", ImmutableSet - . of(new Feature("hardware_profiles"), new Feature("user_name"), new Feature( - "authentication_key"))), - new DeltacloudCollection(URI.create("http://localhost:3001/api/hardware_profiles"), "hardware_profiles"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/storage_snapshots"), "storage_snapshots"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/storage_volumes"), "storage_volumes"), - new DeltacloudCollection(URI.create("http://localhost:3001/api/keys"), "keys"), new DeltacloudCollection( - URI.create("http://localhost:3001/api/buckets"), "buckets") - - ); - assertEquals(factory.create(injector.getInstance(DeltacloudCollectionsHandler.class)).parse(is), expects); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfileHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfileHandlerTest.java deleted file mode 100644 index 8ff48a494a..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfileHandlerTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.deltacloud.domain.EnumHardwareProperty; -import org.jclouds.deltacloud.domain.FixedHardwareProperty; -import org.jclouds.deltacloud.domain.HardwareParameter; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.deltacloud.domain.RangeHardwareProperty; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code HardwareProfileHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class HardwareProfileHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = (ParseSax) injector.getInstance(ParseSax.Factory.class) - .create(injector.getInstance(HardwareProfileHandler.class)); - return parser; - } - - public static HardwareProfile parseHardwareProfile() { - return parseHardwareProfile("/test_get_hardware_profile.xml"); - } - - public static HardwareProfile parseHardwareProfile(String resource) { - InputStream is = HardwareProfileHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } - - public void test() { - HardwareProfile expects = new HardwareProfile( - URI.create("http://localhost:3001/api/hardware_profiles/m1-xlarge"), "m1-xlarge", "m1-xlarge", - ImmutableSet. of( - new FixedHardwareProperty("cpu", "count", Long.valueOf(4)), - new RangeHardwareProperty("memory", "MB", Long.valueOf(12288), new HardwareParameter(URI - .create("http://localhost:3001/api/instances"), "post", "hwp_memory", "create"), - Long.valueOf(12288), Long.valueOf(32768)), - new EnumHardwareProperty("storage", "GB", Long.valueOf(1024), new HardwareParameter(URI - .create("http://localhost:3001/api/instances"), "post", "hwp_storage", "create"), - ImmutableSet. of(Long.valueOf(1024), Long.valueOf(2048), Long.valueOf(4096))), - new FixedHardwareProperty("architecture", "label", "x86_64")) - ); - assertEquals(parseHardwareProfile(), expects); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfilesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfilesHandlerTest.java deleted file mode 100644 index a3cd0b7f07..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/HardwareProfilesHandlerTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.deltacloud.domain.EnumHardwareProperty; -import org.jclouds.deltacloud.domain.FixedHardwareProperty; -import org.jclouds.deltacloud.domain.HardwareParameter; -import org.jclouds.deltacloud.domain.HardwareProfile; -import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.deltacloud.domain.RangeHardwareProperty; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code HardwareProfilesHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "HardwareProfilesHandlerTest") -public class HardwareProfilesHandlerTest extends BaseHandlerTest { - - @Test - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_hardware_profiles.xml"); - Set expects = ImmutableSet.of( - new HardwareProfile(URI.create("http://localhost:3001/api/hardware_profiles/m1-small"), "m1-small", - "m1-small", ImmutableSet. of( - new FixedHardwareProperty("cpu", "count", Long.valueOf(1)), new FixedHardwareProperty("memory", - "MB", new Double(1740.8)), new FixedHardwareProperty("storage", "GB", Long.valueOf(160)), - new FixedHardwareProperty("architecture", "label", "i386"))), - new HardwareProfile(URI.create("http://localhost:3001/api/hardware_profiles/m1-large"), "m1-large", - "m1-large", ImmutableSet. of( - new FixedHardwareProperty("cpu", "count", Long.valueOf(2)), - new RangeHardwareProperty("memory", "MB", Long.valueOf(10240), new HardwareParameter(URI - .create("http://localhost:3001/api/instances"), "post", "hwp_memory", "create"), - new Double(7680.0), Long.valueOf(15360)), new EnumHardwareProperty("storage", "GB", Long.valueOf( - 850), new HardwareParameter(URI.create("http://localhost:3001/api/instances"), "post", - "hwp_storage", "create"), ImmutableSet. of(Long.valueOf(850), Long.valueOf(1024))), - new FixedHardwareProperty("architecture", "label", "x86_64"))), - new HardwareProfile(URI.create("http://localhost:3001/api/hardware_profiles/m1-xlarge"), "m1-xlarge", - "m1-xlarge", ImmutableSet. of( - new FixedHardwareProperty("cpu", "count", Long.valueOf(4)), - new RangeHardwareProperty("memory", "MB", Long.valueOf(12288), new HardwareParameter(URI - .create("http://localhost:3001/api/instances"), "post", "hwp_memory", "create"), - Long.valueOf(12288), Long.valueOf(32768)), - new EnumHardwareProperty("storage", "GB", Long.valueOf(1024), new HardwareParameter(URI - .create("http://localhost:3001/api/instances"), "post", "hwp_storage", "create"), - ImmutableSet. of(Long.valueOf(1024), Long.valueOf(2048), Long.valueOf(4096))), - new FixedHardwareProperty("architecture", "label", "x86_64"))), - new HardwareProfile(URI.create("http://localhost:3001/api/hardware_profiles/opaque"), "opaque", "opaque", - ImmutableSet. of())); - assertEquals(factory.create(injector.getInstance(HardwareProfilesHandler.class)).parse(is), expects); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImageHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImageHandlerTest.java deleted file mode 100644 index 8bfe63a430..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImageHandlerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code ImageHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class ImageHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = (ParseSax) injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(ImageHandler.class)); - return parser; - } - - public static Image parseImage() { - return parseImage("/test_get_image.xml"); - } - - public static Image parseImage(String resource) { - InputStream is = ImageHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } - - public void test() { - Image expects = new Image(URI.create("http://fancycloudprovider.com/api/images/img1"), "img1", "fedoraproject", - "Fedora 10", "Fedora 10", "x86_64"); - assertEquals(parseImage(), expects); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImagesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImagesHandlerTest.java deleted file mode 100644 index 9cb56269e7..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/ImagesHandlerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.deltacloud.domain.Image; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code ImagesHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ImagesHandlerTest") -public class ImagesHandlerTest extends BaseHandlerTest { - - @Test - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_images.xml"); - Set expects = ImmutableSet.of( - - new Image(URI.create("http://fancycloudprovider.com/api/images/img1"), "img1", "fedoraproject", "Fedora 10", - "Fedora 10", "x86_64"), new Image(URI.create("http://fancycloudprovider.com/api/images/img2"), "img2", - "fedoraproject", "Fedora 10", "Fedora 10", "i386"), - new Image(URI.create("http://fancycloudprovider.com/api/images/img3"), "img3", "ted", "JBoss", "JBoss", - "i386")); - assertEquals(factory.create(injector.getInstance(ImagesHandler.class)).parse(is), expects); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java deleted file mode 100644 index 88f2c354bb..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.KeyAuthentication; -import org.jclouds.deltacloud.domain.PasswordAuthentication; -import org.jclouds.deltacloud.domain.Instance.Authentication; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code InstanceHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class InstanceHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(InstanceHandler.class)); - return parser; - } - - public static Instance parseInstance() { - return parseInstance("/test_get_instance.xml"); - } - - public static Instance parseInstance(String resource) { - InputStream is = InstanceHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } - - public void testWithNoAuthentication() { - Instance expects = instanceWithAuthentication(null); - assertEquals(parseInstance("/test_get_instance.xml").toString(), expects.toString()); - } - - public void testWithPasswordAuthentication() { - Instance expects = instanceWithAuthentication(new PasswordAuthentication(LoginCredentials.builder().user("root") - .password("FOO").build())); - assertEquals(parseInstance("/test_get_instance_pw.xml").toString(), expects.toString()); - } - - public void testWithKeyAuthentication() { - Instance expects = instanceWithAuthentication(new KeyAuthentication("keyname")); - assertEquals(parseInstance("/test_get_instance_key.xml").toString(), expects.toString()); - } - - public void testWithKeyAuthenticationBlank() { - Instance expects = instanceWithAuthentication(null); - assertEquals(parseInstance("/test_get_instance_nokey.xml").toString(), expects.toString()); - } - - private Instance instanceWithAuthentication(Authentication authentication) { - return new Instance(URI.create("http://fancycloudprovider.com/api/instances/inst1"), "inst1", "larry", - "Production JBoss Instance", URI.create("http://fancycloudprovider.com/api/images/img3"), - URI.create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"), - URI.create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap.of( - Instance.Action.REBOOT, - HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/reboot").build(), - Instance.Action.STOP, - HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/stop").build()), - authentication, ImmutableSet.of("inst1.larry.fancycloudprovider.com"), - ImmutableSet.of("inst1.larry.internal")); - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java deleted file mode 100644 index 3c818153ce..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.deltacloud.domain.Transition; -import org.jclouds.deltacloud.domain.TransitionAutomatically; -import org.jclouds.deltacloud.domain.TransitionOnAction; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; - -/** - * Tests behavior of {@code StatesHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "StatesHandlerTest") -public class InstanceStatesHandlerTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/test_get_states.xml"); - Multimap expects = ImmutableMultimap. builder().put(State.START, - new TransitionOnAction(Action.CREATE, State.PENDING)).put(State.PENDING, - new TransitionAutomatically(State.RUNNING)) - .putAll(State.RUNNING, new TransitionOnAction(Action.REBOOT, State.RUNNING), - new TransitionOnAction(Action.STOP, State.STOPPED)).putAll(State.STOPPED, - new TransitionOnAction(Action.START, State.RUNNING), - new TransitionOnAction(Action.DESTROY, State.FINISH)).build(); - assertEquals(factory.create(injector.getInstance(InstanceStatesHandler.class)).parse(is).entries(), expects - .entries()); - - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstancesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstancesHandlerTest.java deleted file mode 100644 index e8c71199a9..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstancesHandlerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code InstancesHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "InstancesHandlerTest") -public class InstancesHandlerTest extends BaseHandlerTest { - - @Test - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_instances.xml"); - Set expects = ImmutableSet.of(new Instance(URI - .create("http://fancycloudprovider.com/api/instances/inst1"), "inst1", "larry", - "Production JBoss Instance", URI.create("http://fancycloudprovider.com/api/images/img3"), URI - .create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"), URI - .create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap - .of(Instance.Action.REBOOT, HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/reboot").build(), - Instance.Action.STOP, HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/stop").build()), null, - ImmutableSet.of("inst1.larry.fancycloudprovider.com"), ImmutableSet.of("inst1.larry.internal"))); - assertEquals(factory.create(injector.getInstance(InstancesHandler.class)).parse(is).toString(), expects.toString()); - } -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmHandlerTest.java deleted file mode 100644 index ebd066049d..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmHandlerTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code RealmHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class RealmHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(RealmHandler.class)); - return parser; - } - - public static Realm parseRealm() { - return parseRealm("/test_get_realm.xml"); - } - - public static Realm parseRealm(String resource) { - InputStream is = RealmHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } - - public void test() { - Realm expects = new Realm(URI.create("http://fancycloudprovider.com/api/realms/us"), "us", "United States", null, - Realm.State.AVAILABLE); - assertEquals(parseRealm(), expects); - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmsHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmsHandlerTest.java deleted file mode 100644 index 7e5b5f3bb9..0000000000 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/RealmsHandlerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.deltacloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.deltacloud.domain.Realm; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code RealmsHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "RealmsHandlerTest") -public class RealmsHandlerTest extends BaseHandlerTest { - - @Test - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_realms.xml"); - Set expects = ImmutableSet.of(new Realm(URI - .create("http://fancycloudprovider.com/api/realms/us"), "us", "United States", null, - Realm.State.AVAILABLE), new Realm(URI.create("http://fancycloudprovider.com/api/realms/eu"), "eu", - "Europe", null, Realm.State.AVAILABLE)); - assertEquals(factory.create(injector.getInstance(RealmsHandler.class)).parse(is), expects); - } -} diff --git a/apis/deltacloud/src/test/resources/links.xml b/apis/deltacloud/src/test/resources/links.xml deleted file mode 100644 index 39e13d2283..0000000000 --- a/apis/deltacloud/src/test/resources/links.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/log4j.xml b/apis/deltacloud/src/test/resources/log4j.xml deleted file mode 100644 index 63810d3ca0..0000000000 --- a/apis/deltacloud/src/test/resources/log4j.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apis/deltacloud/src/test/resources/test_get_hardware_profile.xml b/apis/deltacloud/src/test/resources/test_get_hardware_profile.xml deleted file mode 100644 index 5797cdae4f..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_hardware_profile.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - m1-xlarge - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_get_image.xml b/apis/deltacloud/src/test/resources/test_get_image.xml deleted file mode 100644 index 9fd7f331a0..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_image.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - fedoraproject - Fedora 10 - Fedora 10 - x86_64 - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_get_instance.xml b/apis/deltacloud/src/test/resources/test_get_instance.xml deleted file mode 100644 index 884147d224..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_instance.xml +++ /dev/null @@ -1,20 +0,0 @@ - - larry - Production JBoss Instance - - - - - RUNNING - - - - - -
inst1.larry.fancycloudprovider.com
-
- - -
inst1.larry.internal
-
-
\ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_get_instance_key.xml b/apis/deltacloud/src/test/resources/test_get_instance_key.xml deleted file mode 100644 index 6a20a01e9e..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_instance_key.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - larry - Production JBoss Instance - - - - - RUNNING - - - - - -
inst1.larry.fancycloudprovider.com
-
- - -
inst1.larry.internal
-
- - keyname - -
diff --git a/apis/deltacloud/src/test/resources/test_get_instance_nokey.xml b/apis/deltacloud/src/test/resources/test_get_instance_nokey.xml deleted file mode 100644 index b74de30913..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_instance_nokey.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - larry - Production JBoss Instance - - - - - RUNNING - - - - - -
inst1.larry.fancycloudprovider.com
-
- - -
inst1.larry.internal
-
- - - -
diff --git a/apis/deltacloud/src/test/resources/test_get_instance_pw.xml b/apis/deltacloud/src/test/resources/test_get_instance_pw.xml deleted file mode 100644 index f557f080a9..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_instance_pw.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - larry - Production JBoss Instance - - - - - RUNNING - - - - - -
inst1.larry.fancycloudprovider.com
-
- - -
inst1.larry.internal
-
- - - root - FOO - - -
\ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_get_realm.xml b/apis/deltacloud/src/test/resources/test_get_realm.xml deleted file mode 100644 index f08bbef139..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_realm.xml +++ /dev/null @@ -1,5 +0,0 @@ - - United States - AVAILABLE - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_get_states.xml b/apis/deltacloud/src/test/resources/test_get_states.xml deleted file mode 100644 index 3f0efacab5..0000000000 --- a/apis/deltacloud/src/test/resources/test_get_states.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_list_hardware_profiles.xml b/apis/deltacloud/src/test/resources/test_list_hardware_profiles.xml deleted file mode 100644 index 2028833898..0000000000 --- a/apis/deltacloud/src/test/resources/test_list_hardware_profiles.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - m1-small - - - - - - - m1-large - - - - - - - - - - - - - - - - m1-xlarge - - - - - - - - - - - - - - - - - opaque - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_list_images.xml b/apis/deltacloud/src/test/resources/test_list_images.xml deleted file mode 100644 index 49c888d264..0000000000 --- a/apis/deltacloud/src/test/resources/test_list_images.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - fedoraproject - Fedora 10 - Fedora 10 - x86_64 - - - fedoraproject - Fedora 10 - Fedora 10 - i386 - - - ted - JBoss - JBoss - i386 - - \ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_list_instances.xml b/apis/deltacloud/src/test/resources/test_list_instances.xml deleted file mode 100644 index 2dac2ccc3a..0000000000 --- a/apis/deltacloud/src/test/resources/test_list_instances.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - larry - Production JBoss Instance - - - - - RUNNING - - - - - -
inst1.larry.fancycloudprovider.com
-
- - -
inst1.larry.internal
-
-
-
\ No newline at end of file diff --git a/apis/deltacloud/src/test/resources/test_list_realms.xml b/apis/deltacloud/src/test/resources/test_list_realms.xml deleted file mode 100644 index a970d4f1b7..0000000000 --- a/apis/deltacloud/src/test/resources/test_list_realms.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - United States - AVAILABLE - - - - Europe - AVAILABLE - - - \ No newline at end of file diff --git a/apis/pom.xml b/apis/pom.xml index e02a695ea8..1c062f31fd 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -40,7 +40,6 @@ s3 ec2 sqs - deltacloud vcloud elasticstack atmos