From 793764e4f009637a92af57244d70d2a4d4a14720 Mon Sep 17 00:00:00 2001 From: Everett Toews Date: Sat, 29 Dec 2012 13:32:42 -0600 Subject: [PATCH] Deleted slicehost project. Use rackspace-cloudservers-us/uk instead. --- allcompute/pom.xml | 5 - providers/pom.xml | 1 - providers/slicehost/README.txt | 25 -- providers/slicehost/pom.xml | 120 ------- .../slicehost/SlicehostApiMetadata.java | 94 ------ .../slicehost/SlicehostAsyncClient.java | 189 ----------- .../jclouds/slicehost/SlicehostClient.java | 71 ---- .../slicehost/SlicehostProviderMetadata.java | 64 ---- .../binders/BindCreateBackupToXmlPayload.java | 65 ---- .../binders/BindCreateSliceToXmlPayload.java | 66 ---- .../SlicehostComputeServiceContextModule.java | 95 ------ .../compute/functions/FlavorToHardware.java | 43 --- .../functions/SliceToNodeMetadata.java | 136 -------- .../functions/SlicehostImageToImage.java | 53 --- .../SlicehostImageToOperatingSystem.java | 90 ------ .../SlicehostComputeServiceAdapter.java | 119 ------- .../config/SlicehostRestClientModule.java | 45 --- .../org/jclouds/slicehost/domain/Backup.java | 115 ------- .../org/jclouds/slicehost/domain/Flavor.java | 109 ------- .../org/jclouds/slicehost/domain/Image.java | 85 ----- .../org/jclouds/slicehost/domain/Slice.java | 252 --------------- .../slicehost/filters/SlicehostBasic.java | 51 --- .../ParseSlicehostErrorFromHttpResponse.java | 128 -------- .../slicehost/predicates/SliceActive.java | 64 ---- .../slicehost/predicates/SliceTerminated.java | 63 ---- .../jclouds/slicehost/xml/BackupHandler.java | 78 ----- .../jclouds/slicehost/xml/BackupsHandler.java | 68 ---- .../jclouds/slicehost/xml/ErrorHandler.java | 47 --- .../jclouds/slicehost/xml/FlavorHandler.java | 65 ---- .../jclouds/slicehost/xml/FlavorsHandler.java | 68 ---- .../jclouds/slicehost/xml/ImageHandler.java | 62 ---- .../jclouds/slicehost/xml/ImagesHandler.java | 68 ---- .../jclouds/slicehost/xml/SliceHandler.java | 108 ------- .../jclouds/slicehost/xml/SlicesHandler.java | 68 ---- .../org.jclouds.providers.ProviderMetadata | 1 - .../slicehost/SlicehostAsyncClientTest.java | 258 --------------- .../slicehost/SlicehostClientLiveTest.java | 303 ------------------ .../slicehost/SlicehostProviderTest.java | 34 -- .../SlicehostComputeServiceLiveTest.java | 74 ----- .../SlicehostTemplateBuilderLiveTest.java | 92 ------ ...cehostComputeServiceContextModuleTest.java | 37 --- .../functions/FlavorToHardwareTest.java | 67 ---- .../functions/SliceToNodeMetadataTest.java | 125 -------- .../functions/SlicehostImageToImageTest.java | 92 ------ .../slicehost/xml/FlavorHandlerTest.java | 59 ---- .../slicehost/xml/FlavorsHandlerTest.java | 55 ---- .../slicehost/xml/ImageHandlerTest.java | 67 ---- .../slicehost/xml/ImagesHandlerTest.java | 77 ----- .../slicehost/xml/SliceHandlerTest.java | 75 ----- .../slicehost/xml/SlicesHandlerTest.java | 56 ---- .../slicehost/src/test/resources/log4j.xml | 117 ------- .../src/test/resources/test_errors.xml | 4 - .../src/test/resources/test_get_flavor.xml | 7 - .../src/test/resources/test_get_image.xml | 7 - .../src/test/resources/test_get_image32.xml | 7 - .../src/test/resources/test_get_slice.xml | 17 - .../src/test/resources/test_list_flavors.xml | 27 -- .../src/test/resources/test_list_images.xml | 51 --- .../src/test/resources/test_list_slices.xml | 48 --- .../src/test/resources/test_new_slice.xml | 16 - 60 files changed, 4553 deletions(-) delete mode 100644 providers/slicehost/README.txt delete mode 100644 providers/slicehost/pom.xml delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateBackupToXmlPayload.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateSliceToXmlPayload.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImage.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostComputeServiceAdapter.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Backup.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Flavor.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Image.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Slice.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceActive.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceTerminated.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupsHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ErrorHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorsHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImageHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImagesHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SliceHandler.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SlicesHandler.java delete mode 100644 providers/slicehost/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/FlavorToHardwareTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorHandlerTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorsHandlerTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImageHandlerTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImagesHandlerTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SliceHandlerTest.java delete mode 100644 providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SlicesHandlerTest.java delete mode 100644 providers/slicehost/src/test/resources/log4j.xml delete mode 100644 providers/slicehost/src/test/resources/test_errors.xml delete mode 100644 providers/slicehost/src/test/resources/test_get_flavor.xml delete mode 100644 providers/slicehost/src/test/resources/test_get_image.xml delete mode 100644 providers/slicehost/src/test/resources/test_get_image32.xml delete mode 100644 providers/slicehost/src/test/resources/test_get_slice.xml delete mode 100644 providers/slicehost/src/test/resources/test_list_flavors.xml delete mode 100644 providers/slicehost/src/test/resources/test_list_images.xml delete mode 100644 providers/slicehost/src/test/resources/test_list_slices.xml delete mode 100644 providers/slicehost/src/test/resources/test_new_slice.xml diff --git a/allcompute/pom.xml b/allcompute/pom.xml index 1b966a5909..15af0d24b7 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -125,11 +125,6 @@ gogrid ${project.version} - - org.jclouds.provider - slicehost - ${project.version} - org.jclouds.api elasticstack diff --git a/providers/pom.xml b/providers/pom.xml index feee92aa78..8e1fb72374 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -33,7 +33,6 @@ jclouds providers project gogrid - slicehost cloudsigma-zrh cloudsigma-lvs azureblob diff --git a/providers/slicehost/README.txt b/providers/slicehost/README.txt deleted file mode 100644 index 2d69b63786..0000000000 --- a/providers/slicehost/README.txt +++ /dev/null @@ -1,25 +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. -==== - -# -# The jclouds provider for Slicehost (http://www.slicehost.com/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. \ No newline at end of file diff --git a/providers/slicehost/pom.xml b/providers/slicehost/pom.xml deleted file mode 100644 index 56cd1a2426..0000000000 --- a/providers/slicehost/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.6.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.provider - slicehost - jclouds Slicehost provider - ComputeService implementation of Slicehost datacenters - bundle - - - https://api.slicehost.com - 1.4.1.1 - - FIXME - - - org.jclouds.slicehost*;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-core - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${project.version} - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - 1 - - ${test.slicehost.endpoint} - ${test.slicehost.api-version} - ${test.slicehost.build-version} - ${test.slicehost.identity} - ${test.slicehost.template} - - - - - - - - - - - - diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java deleted file mode 100644 index b11c086b76..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java +++ /dev/null @@ -1,94 +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.slicehost; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; -import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; -import org.jclouds.slicehost.config.SlicehostRestClientModule; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Slicehost 1.0 API - * - * @author Adrian Cole - */ -public class SlicehostApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public SlicehostApiMetadata() { - this(new Builder()); - } - - protected SlicehostApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - properties.setProperty("jclouds.ssh.max-retries", "8"); - return properties; - } - - public static class Builder - extends - BaseRestApiMetadata.Builder { - - protected Builder() { - super(SlicehostClient.class, SlicehostAsyncClient.class); - id("slicehost") - .name("Slicehost API") - .identityName("API password") - .documentation(URI.create("http://articles.slicehost.com/api")) - .version("https://api.slicehost.com") - .defaultEndpoint("https://api.slicehost.com") - .defaultProperties(SlicehostApiMetadata.defaultProperties()) - .view(TypeToken.of(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(SlicehostRestClientModule.class, SlicehostComputeServiceContextModule.class)); - } - - @Override - public SlicehostApiMetadata build() { - return new SlicehostApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(ApiMetadata in) { - super.fromApiMetadata(in); - return this; - } - - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java deleted file mode 100644 index c3d1f5a45b..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java +++ /dev/null @@ -1,189 +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.slicehost; - -import java.util.Set; -import java.util.concurrent.ExecutionException; - -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.slicehost.binders.BindCreateSliceToXmlPayload; -import org.jclouds.slicehost.domain.Backup; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.domain.Image; -import org.jclouds.slicehost.domain.Slice; -import org.jclouds.slicehost.filters.SlicehostBasic; -import org.jclouds.slicehost.xml.BackupHandler; -import org.jclouds.slicehost.xml.BackupsHandler; -import org.jclouds.slicehost.xml.FlavorHandler; -import org.jclouds.slicehost.xml.FlavorsHandler; -import org.jclouds.slicehost.xml.ImageHandler; -import org.jclouds.slicehost.xml.ImagesHandler; -import org.jclouds.slicehost.xml.SliceHandler; -import org.jclouds.slicehost.xml.SlicesHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Slicehost via their REST API. - *

- * All commands return a ListenableFuture of the result from Slicehost. Any exceptions incurred - * during processing will be backend in an {@link ExecutionException} as documented in - * {@link ListenableFuture#get()}. - * - * @see SlicehostClient - * @see - * @author Adrian Cole - */ -@RequestFilters(SlicehostBasic.class) -public interface SlicehostAsyncClient { - - /** - * @see SlicehostClient#listSlices - */ - @GET - @Path("/slices.xml") - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(SlicesHandler.class) - ListenableFuture> listSlices(); - - /** - * @see SlicehostClient#getSlice - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @Path("/slices/{id}.xml") - @XMLResponseParser(SliceHandler.class) - ListenableFuture getSlice(@PathParam("id") int id); - - /** - * @see SlicehostClient#destroySlice - */ - @DELETE - @Fallback(VoidOnNotFoundOr404.class) - @Path("/slices/{id}/destroy.xml") - ListenableFuture destroySlice(@PathParam("id") int id); - - /** - * @see SlicehostClient#rebootSlice - */ - @PUT - @Path("/slices/{id}/reboot.xml") - ListenableFuture rebootSlice(@PathParam("id") int id); - - /** - * @see SlicehostClient#hardRebootSlice - */ - @PUT - @Path("/slices/{id}/hard_reboot.xml") - ListenableFuture hardRebootSlice(@PathParam("id") int id); - - /** - * @see SlicehostClient#createSlice - */ - @POST - @Path("/slices.xml") - @MapBinder(BindCreateSliceToXmlPayload.class) - @XMLResponseParser(SliceHandler.class) - ListenableFuture createSlice(@PayloadParam("name") String name, @PayloadParam("image_id") int imageId, - @PayloadParam("flavor_id") int flavorId); - - /** - * @see SlicehostClient#rebuildSliceFromImage - */ - @PUT - @Path("/slices/{id}/rebuild.xml") - ListenableFuture rebuildSliceFromImage(@PathParam("id") int id, @QueryParam("image_id") int imageId); - - /** - * @see SlicehostClient#rebuildSliceFromBackup - */ - @PUT - @Path("/slices/{id}/rebuild.xml") - ListenableFuture rebuildSliceFromBackup(@PathParam("id") int id, @QueryParam("backup_id") int imageId); - - /** - * @see SlicehostClient#listFlavors - */ - @GET - @Path("/flavors.xml") - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(FlavorsHandler.class) - ListenableFuture> listFlavors(); - - /** - * @see SlicehostClient#getFlavor - */ - @GET - @Path("/flavors/{id}.xml") - @Fallback(NullOnNotFoundOr404.class) - @XMLResponseParser(FlavorHandler.class) - ListenableFuture getFlavor(@PathParam("id") int id); - - /** - * @see SlicehostClient#listImages - */ - @GET - @Path("/images.xml") - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(ImagesHandler.class) - ListenableFuture> listImages(); - - /** - * @see SlicehostClient#getImage - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @Path("/images/{id}.xml") - @XMLResponseParser(ImageHandler.class) - ListenableFuture getImage(@PathParam("id") int id); - - /** - * @see SlicehostClient#listBackups - */ - @GET - @Path("/backups.xml") - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(BackupsHandler.class) - ListenableFuture> listBackups(); - - /** - * @see SlicehostClient#getBackup - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @Path("/backups/{id}.xml") - @XMLResponseParser(BackupHandler.class) - ListenableFuture getBackup(@PathParam("id") int id); - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java deleted file mode 100644 index 83daef81ce..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java +++ /dev/null @@ -1,71 +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.slicehost; - -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.concurrent.Timeout; -import org.jclouds.slicehost.domain.Backup; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.domain.Image; -import org.jclouds.slicehost.domain.Slice; - -/** - * Provides access to Slicehost via their REST API. - *

- * All commands return a ListenableFuture of the result from Slicehost. Any exceptions incurred - * during processing will be backend in an {@link ExecutionException} as documented in - * {@link ListenableFuture#get()}. - * - * @see SlicehostAsyncClient - * @see - * @author Adrian Cole - */ -@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) -public interface SlicehostClient { - Set listSlices(); - - Slice getSlice(int id); - - Void destroySlice(int id); - - Void rebootSlice(int id); - - Void hardRebootSlice(int id); - - Slice createSlice(String name, int imageId, int flavorId); - - Void rebuildSliceFromImage(int id, int imageId); - - Void rebuildSliceFromBackup(int id, int imageId); - - Set listFlavors(); - - Flavor getFlavor(int id); - - Set listImages(); - - Image getImage(int id); - - Set listBackups(); - - Backup getBackup(int id); - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java deleted file mode 100644 index 3b33a1c590..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.jclouds.slicehost; - -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Slicehost - * - * @author Adrian Cole - */ -public class SlicehostProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public SlicehostProviderMetadata() { - super(builder()); - } - - public SlicehostProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],os64Bit=true,osDescriptionMatches=^((?!MGC).)*$"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("slicehost") - .name("Slicehost") - .apiMetadata(new SlicehostApiMetadata()) - .homepage(URI.create("http://www.slicehost.com")) - .console(URI.create("https://manage.slicehost.com/")) - .iso3166Codes("US-IL", "US-TX", "US-MO"); - } - - @Override - public SlicehostProviderMetadata build() { - return new SlicehostProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateBackupToXmlPayload.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateBackupToXmlPayload.java deleted file mode 100644 index 3b3afe6d5b..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateBackupToXmlPayload.java +++ /dev/null @@ -1,65 +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.slicehost.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; - -/** - * - * @author Adrian Cole - * - */ -@Singleton -public class BindCreateBackupToXmlPayload implements MapBinder { - private final BindToStringPayload binder; - - @Inject - BindCreateBackupToXmlPayload(BindToStringPayload binder) { - this.binder = binder; - } - - @Override - public R bindToRequest(R request, Map postParams) { - String sliceId = checkNotNull(postParams.get("slice_id"), "slice_id").toString(); - String name = checkNotNull(postParams.get("name"), "name").toString(); - StringBuilder builder = new StringBuilder(); - builder.append(""); - builder.append("").append(sliceId).append(""); - builder.append("").append(name).append(""); - builder.append(""); - request = binder.bindToRequest(request, builder.toString()); - request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_XML); - return request; - } - - @Override - public R bindToRequest(R request, Object input) { - throw new UnsupportedOperationException("should use map params"); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateSliceToXmlPayload.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateSliceToXmlPayload.java deleted file mode 100644 index 82f4ce9d08..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/binders/BindCreateSliceToXmlPayload.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.slicehost.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; - -/** - * - * @author Adrian Cole - * - */ -@Singleton -public class BindCreateSliceToXmlPayload implements MapBinder { - private final BindToStringPayload binder; - - @Inject - BindCreateSliceToXmlPayload(BindToStringPayload binder) { - this.binder = binder; - } - @Override - public R bindToRequest(R request, Map postParams) { - String flavorId = checkNotNull(postParams.get("flavor_id"), "flavor_id").toString(); - String imageId = checkNotNull(postParams.get("image_id"), "image_id").toString(); - String name = checkNotNull(postParams.get("name"), "name").toString(); - StringBuilder builder = new StringBuilder(); - builder.append(""); - builder.append("").append(flavorId).append(""); - builder.append("").append(imageId).append(""); - builder.append("").append(name).append(""); - builder.append(""); - request = binder.bindToRequest(request, builder.toString()); - request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_XML); - return request; - } - - @Override - public R bindToRequest(R request, Object input) { - throw new UnsupportedOperationException("should use map params"); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java deleted file mode 100644 index adb64b9a92..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java +++ /dev/null @@ -1,95 +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.slicehost.compute.config; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.domain.Location; -import org.jclouds.functions.IdentityFunction; -import org.jclouds.slicehost.compute.functions.FlavorToHardware; -import org.jclouds.slicehost.compute.functions.SliceToNodeMetadata; -import org.jclouds.slicehost.compute.functions.SlicehostImageToImage; -import org.jclouds.slicehost.compute.functions.SlicehostImageToOperatingSystem; -import org.jclouds.slicehost.compute.strategy.SlicehostComputeServiceAdapter; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.domain.Slice; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -/** - * Configures the {@link SlicehostComputeServiceContext}; requires {@link BaseComputeService} bound. - * - * @author Adrian Cole - */ -public class SlicehostComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @SuppressWarnings("unchecked") - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(SlicehostComputeServiceAdapter.class); - - bind(new TypeLiteral>() { - }).to(SliceToNodeMetadata.class); - - bind(new TypeLiteral>() { - }).to(SlicehostImageToImage.class); - bind(new TypeLiteral>() { - }).to(SlicehostImageToOperatingSystem.class); - - bind(new TypeLiteral>() { - }).to(FlavorToHardware.class); - - // we aren't converting location from a provider-specific type - bind(new TypeLiteral>() { - }).to(Class.class.cast(IdentityFunction.class)); - - } - - @VisibleForTesting - public static final Map sliceStatusToNodeStatus = ImmutableMap - . builder().put(Slice.Status.ACTIVE, Status.RUNNING)// - .put(Slice.Status.BUILD, Status.PENDING)// - .put(Slice.Status.REBOOT, Status.PENDING)// - .put(Slice.Status.HARD_REBOOT, Status.PENDING)// - .put(Slice.Status.TERMINATED, Status.TERMINATED)// - .put(Slice.Status.UNRECOGNIZED, Status.UNRECOGNIZED)// - .build(); - - @Singleton - @Provides - Map provideSliceToNodeStatus() { - return sliceStatusToNodeStatus; - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java deleted file mode 100644 index 8cdd68048d..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java +++ /dev/null @@ -1,43 +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.slicehost.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.internal.VolumeImpl; -import org.jclouds.slicehost.domain.Flavor; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; - -/** - * @author Adrian Cole - */ -@Singleton -public class FlavorToHardware implements Function { - public Hardware apply(Flavor from) { - return new HardwareBuilder().ids(from.getId() + "").name(from.getName()).hypervisor("xen") - .processors(ImmutableList.of(new Processor(from.getRam() / 1024.0, 1.0))).ram(from.getRam()) - .volumes(ImmutableList. of(new VolumeImpl((from.getRam() * 4) / 1024.0f, true, true))).build(); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java deleted file mode 100644 index 5e1c260197..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java +++ /dev/null @@ -1,136 +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.slicehost.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.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.domain.Location; -import org.jclouds.logging.Logger; -import org.jclouds.slicehost.domain.Slice; -import org.jclouds.util.Predicates2; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Singleton -public class SliceToNodeMetadata implements Function { - protected final Supplier location; - protected final Map sliceToNodeStatus; - protected final Supplier> images; - protected final Supplier> hardwares; - protected final GroupNamingConvention nodeNamingConvention; - - @Resource - protected Logger logger = Logger.NULL; - - private static class FindImageForSlice implements Predicate { - private final Slice slice; - - private FindImageForSlice(Slice slice) { - this.slice = slice; - } - - @Override - public boolean apply(Image input) { - return input.getProviderId().equals(slice.getImageId() + ""); - } - } - - private static class FindHardwareForSlice implements Predicate { - private final Slice slice; - - private FindHardwareForSlice(Slice slice) { - this.slice = slice; - } - - @Override - public boolean apply(Hardware input) { - return input.getProviderId().equals(slice.getFlavorId() + ""); - } - } - - @Inject - SliceToNodeMetadata(Map sliceStateToNodeStatus, - @Memoized Supplier> images, Supplier location, - @Memoized Supplier> hardwares, - GroupNamingConvention.Factory namingConvention) { - this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.sliceToNodeStatus = checkNotNull(sliceStateToNodeStatus, "sliceStateToNodeStatus"); - this.images = checkNotNull(images, "images"); - this.location = checkNotNull(location, "location"); - this.hardwares = checkNotNull(hardwares, "hardwares"); - } - - @Override - public NodeMetadata apply(Slice from) { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.ids(from.getId() + ""); - builder.name(from.getName()); - builder.hostname(from.getName()); - builder.location(location.get()); - builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); - builder.imageId(from.getImageId() + ""); - builder.operatingSystem(parseOperatingSystem(from)); - builder.hardware(parseHardware(from)); - builder.status(sliceToNodeStatus.get(from.getStatus())); - builder.publicAddresses(Iterables.filter(from.getAddresses(), Predicates.not(Predicates2.startsWith("10.")))); - builder.privateAddresses(Iterables.filter(from.getAddresses(), Predicates2.startsWith("10."))); - return builder.build(); - } - - protected Hardware parseHardware(Slice from) { - try { - return Iterables.find(hardwares.get(), new FindHardwareForSlice(from)); - } catch (NoSuchElementException e) { - logger.debug("could not find a matching hardware for slice %s", from); - } - return null; - } - - protected OperatingSystem parseOperatingSystem(Slice from) { - try { - return Iterables.find(images.get(), new FindImageForSlice(from)).getOperatingSystem(); - } catch (NoSuchElementException e) { - logger.debug("could not find a matching image for slice %s in location %s", from, location); - } - return null; - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImage.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImage.java deleted file mode 100644 index 9f24936883..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImage.java +++ /dev/null @@ -1,53 +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.slicehost.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.OperatingSystem; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class SlicehostImageToImage implements Function { - private final Function imageToOs; - - @Inject - SlicehostImageToImage(Function imageToOs) { - this.imageToOs = imageToOs; - } - - public Image apply(org.jclouds.slicehost.domain.Image from) { - ImageBuilder builder = new ImageBuilder(); - builder.ids(from.getId() + ""); - builder.name(from.getName()); - builder.description(from.getName()); - builder.operatingSystem(imageToOs.apply(from)); - builder.status(Image.Status.AVAILABLE); - Image image = builder.build(); - return image; - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java deleted file mode 100644 index baa9fd141a..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java +++ /dev/null @@ -1,90 +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.slicehost.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 SlicehostImageToOperatingSystem 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 SlicehostImageToOperatingSystem(Map> osVersionMap) { - this.osVersionMap = osVersionMap; - } - - public OperatingSystem apply(final org.jclouds.slicehost.domain.Image from) { - OsFamily osFamily = null; - String osName = null; - String osArch = null; - String osVersion = null; - String osDescription = from.getName(); - boolean is64Bit = !from.getName().endsWith("32-bit"); - 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/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostComputeServiceAdapter.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostComputeServiceAdapter.java deleted file mode 100644 index 33c3b94d0f..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostComputeServiceAdapter.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.slicehost.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.slicehost.SlicehostClient; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.domain.Image; -import org.jclouds.slicehost.domain.Slice; - -import com.google.common.collect.ImmutableSet; - -/** - * defines the connection between the {@link SlicehostClient} implementation and the jclouds - * {@link ComputeService} - * - */ -@Singleton -public class SlicehostComputeServiceAdapter implements ComputeServiceAdapter { - - protected final SlicehostClient client; - - @Inject - protected SlicehostComputeServiceAdapter(SlicehostClient client) { - this.client = checkNotNull(client, "client"); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, - Template template) { - Slice server = client - .createSlice(name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template - .getHardware().getProviderId())); - - return new NodeAndInitialCredentials(server, server.getId() + "", LoginCredentials.builder().password( - server.getRootPassword()).build()); - } - - @Override - public Iterable listHardwareProfiles() { - return client.listFlavors(); - } - - @Override - public Iterable listImages() { - return client.listImages(); - } - - @Override - public Iterable listNodes() { - return client.listSlices(); - } - - @Override - public Iterable listLocations() { - // Not using the adapter to determine locations - return ImmutableSet.of(); - } - - @Override - public Slice getNode(String id) { - int serverId = Integer.parseInt(id); - return client.getSlice(serverId); - } - - @Override - public Image getImage(String id) { - int imageId = Integer.parseInt(id); - return client.getImage(imageId); - } - - @Override - public void destroyNode(String id) { - int serverId = Integer.parseInt(id); - // if false server wasn't around in the first place - client.destroySlice(serverId); - } - - @Override - public void rebootNode(String id) { - int sliceId = Integer.parseInt(id); - client.hardRebootSlice(sliceId); - } - - @Override - public void resumeNode(String id) { - throw new UnsupportedOperationException("suspend not supported"); - } - - @Override - public void suspendNode(String id) { - throw new UnsupportedOperationException("suspend not supported"); - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java deleted file mode 100644 index aa9189154a..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java +++ /dev/null @@ -1,45 +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.slicehost.config; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; -import org.jclouds.slicehost.handlers.ParseSlicehostErrorFromHttpResponse; - -/** - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class SlicehostRestClientModule extends RestClientModule { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseSlicehostErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseSlicehostErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseSlicehostErrorFromHttpResponse.class); - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Backup.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Backup.java deleted file mode 100644 index c409f5ef0b..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Backup.java +++ /dev/null @@ -1,115 +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.slicehost.domain; - -import java.util.Date; - -/** - * - * - * @author Adrian Cole - */ -public class Backup { - - private final int id; - private final String name; - private final String sliceId; - private final Date date; - - public Backup(int id, String name, String sliceId, Date date) { - this.id = id; - this.name = name; - this.sliceId = sliceId; - this.date = date; - } - - /** - * @return id of the backup - */ - public int getId() { - return id; - } - - /** - * @return Examples: weekly, my snapshot - */ - public String getName() { - return name; - } - - /** - * @return The Slice this backup was made from - */ - public String getSliceId() { - return sliceId; - } - - /** - * @return The time the backup was taken - */ - public Date getDate() { - return date; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((date == null) ? 0 : date.hashCode()); - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((sliceId == null) ? 0 : sliceId.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; - Backup other = (Backup) obj; - if (date == null) { - if (other.date != null) - return false; - } else if (!date.equals(other.date)) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (sliceId == null) { - if (other.sliceId != null) - return false; - } else if (!sliceId.equals(other.sliceId)) - return false; - return true; - } - - @Override - public String toString() { - return "[date=" + date + ", id=" + id + ", name=" + name + ", sliceId=" + sliceId + "]"; - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Flavor.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Flavor.java deleted file mode 100644 index 260d091452..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Flavor.java +++ /dev/null @@ -1,109 +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.slicehost.domain; - -/** - * - * A flavor is an available hardware configuration for a slice. - * - * @author Adrian Cole - */ -public class Flavor { - - private final int id; - private final String name; - private final int price; - private final int ram; - - public Flavor(int id, String name, int price, int ram) { - this.id = id; - this.name = name; - this.price = price; - this.ram = ram; - } - - /** - * @return id of the flavor - */ - public int getId() { - return id; - } - - /** - * @return Verbose name for the flavor, e.g. 256 slice - */ - public String getName() { - return name; - } - - /** - * @return The price as an integer of cents. For example: 2000 equals $20.00. - * Note that all prices are in USD - */ - public int getPrice() { - return price; - } - - /** - * @return The amount of RAM (in Megabytes) included with the plan - */ - public int getRam() { - return ram; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + Float.floatToIntBits(price); - result = prime * result + ram; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Flavor other = (Flavor) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (Float.floatToIntBits(price) != Float.floatToIntBits(other.price)) - return false; - if (ram != other.ram) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + id + ", name=" + name + ", price=" + price + ", ram=" + ram + "]"; - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Image.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Image.java deleted file mode 100644 index 2f6de6c952..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Image.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.slicehost.domain; - -/** - * - * - * @author Adrian Cole - */ -public class Image { - - private final int id; - private final String name; - - public Image(int id, String name) { - this.id = id; - this.name = name; - - } - - /** - * @return id of the image - */ - public int getId() { - return id; - } - - /** - * @return Example: Ubuntu 8.04 LTS (hardy) - */ - public String getName() { - return name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Image other = (Image) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - - return true; - } - - @Override - public String toString() { - return "[id=" + id + ", name=" + name + "]"; - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Slice.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Slice.java deleted file mode 100644 index f9f8492855..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/domain/Slice.java +++ /dev/null @@ -1,252 +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.slicehost.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.CaseFormat; - -/** - * A slice is a virtual machine instance in the Slicehost system. Flavor and image are requisite - * elements when creating a slice. - * - * @author Adrian Cole - */ -public class Slice { - /** - * The current status of the slice - * - */ - public enum Status { - - ACTIVE, BUILD, REBOOT, HARD_REBOOT, TERMINATED, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Status fromValue(String state) { - try { - return valueOf(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - private final int id; - private final String name; - private final int flavorId; - @Nullable - private final Integer imageId; - @Nullable - private final Integer backupId; - private final Status status; - @Nullable - private final Integer progress; - private final float bandwidthIn; - private final float bandwidthOut; - private final Set addresses; - @Nullable - private final String rootPassword; - - public Slice(int id, String name, int flavorId, @Nullable Integer imageId, @Nullable Integer backupId, - Status status, @Nullable Integer progress, float bandwidthIn, float bandwidthOut, Set addresses, - @Nullable String rootPassword) { - this.id = id; - this.name = name; - this.flavorId = flavorId; - this.imageId = imageId; - this.backupId = backupId; - this.status = status; - this.progress = progress; - this.bandwidthIn = bandwidthIn; - this.bandwidthOut = bandwidthOut; - this.addresses = addresses; - this.rootPassword = rootPassword; - } - - /** - * @return unique id within slicehost - */ - public int getId() { - return id; - } - - /** - * @return A string to identify the slice - */ - public String getName() { - return name; - } - - /** - * @return the flavor of a slice - */ - public int getFlavorId() { - return flavorId; - } - - /** - * @return the image used to create the slice or null - */ - public Integer getImageId() { - return imageId; - } - - /** - * @return The current status of the slice - */ - public Status getStatus() { - return status; - } - - /** - * @return The percentage of current action in percentage - */ - public Integer getProgress() { - return progress; - } - - /** - * @return The incoming bandwidth total for this billing cycle, in Gigabytes - */ - public float getBandwidthIn() { - return bandwidthIn; - } - - /** - * @return The outgoing bandwidth total for this billing cycle, in Gigabytes - */ - public float getBandwidthOut() { - return bandwidthOut; - } - - /** - * @return an array of strings representing the Slice's IPs, including private IPs - */ - public Set getAddresses() { - return addresses; - } - - /** - * @return root password, if just created - */ - public String getRootPassword() { - return rootPassword; - } - - /** - * @return backup used to create this instance or null - */ - public Integer getBackupId() { - return backupId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((addresses == null) ? 0 : addresses.hashCode()); - result = prime * result + ((backupId == null) ? 0 : backupId.hashCode()); - result = prime * result + Float.floatToIntBits(bandwidthIn); - result = prime * result + Float.floatToIntBits(bandwidthOut); - result = prime * result + flavorId; - result = prime * result + id; - result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((progress == null) ? 0 : progress.hashCode()); - result = prime * result + ((rootPassword == null) ? 0 : rootPassword.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Slice other = (Slice) obj; - if (addresses == null) { - if (other.addresses != null) - return false; - } else if (!addresses.equals(other.addresses)) - return false; - if (backupId == null) { - if (other.backupId != null) - return false; - } else if (!backupId.equals(other.backupId)) - return false; - if (Float.floatToIntBits(bandwidthIn) != Float.floatToIntBits(other.bandwidthIn)) - return false; - if (Float.floatToIntBits(bandwidthOut) != Float.floatToIntBits(other.bandwidthOut)) - return false; - if (flavorId != other.flavorId) - return false; - if (id != other.id) - return false; - if (imageId == null) { - if (other.imageId != null) - return false; - } else if (!imageId.equals(other.imageId)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (progress == null) { - if (other.progress != null) - return false; - } else if (!progress.equals(other.progress)) - return false; - if (rootPassword == null) { - if (other.rootPassword != null) - return false; - } else if (!rootPassword.equals(other.rootPassword)) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + id + ", name=" + name + ", flavorId=" + flavorId + ", imageId=" + imageId + ", backupId=" - + backupId + ", status=" + status + ", progress=" + progress + ", bandwidthIn=" + bandwidthIn - + ", bandwidthOut=" + bandwidthOut + ", addresses=" + addresses + ", rootPassword=" - + (rootPassword != null) + "]"; - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java deleted file mode 100644 index c9087eb420..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.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.slicehost.filters; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.crypto.CryptoStreams; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.rest.annotations.Identity; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class SlicehostBasic implements HttpRequestFilter { - private final String apikey; - - @Inject - public SlicehostBasic(@Identity String apikey) { - this.apikey = checkNotNull(apikey, "apikey"); - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - return request.toBuilder().replaceHeader(HttpHeaders.AUTHORIZATION, - String.format("Basic %s", CryptoStreams.base64(apikey.getBytes()))).build(); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java deleted file mode 100644 index d013eb6b4e..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.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.slicehost.handlers; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Provider; -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.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.slicehost.xml.ErrorHandler; -import org.jclouds.util.Strings2; - -/** - * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole - * - */ -@Singleton -public class ParseSlicehostErrorFromHttpResponse implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - public static final Pattern RESOURCE_PATTERN = Pattern.compile("^/v1[^/]*/[0-9]+/([^/]+)/([0-9]+)"); - - private final ErrorParser errorParser; - - @Inject - ParseSlicehostErrorFromHttpResponse(ErrorParser errorParser) { - this.errorParser = errorParser; - } - - public void handleError(HttpCommand command, HttpResponse response) { - Exception exception = new HttpResponseException(command, response); - try { - String content = response.getStatusCode() != 401 ? parseErrorFromContentOrNull(command, response) : null; - exception = content != null ? new HttpResponseException(command, response, content) : exception; - switch (response.getStatusCode()) { - case 401: - exception = new AuthorizationException(exception.getMessage(), exception); - break; - case 403: - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - String path = command.getCurrentRequest().getEndpoint().getPath(); - Matcher matcher = RESOURCE_PATTERN.matcher(path); - String message; - if (matcher.find()) { - message = String.format("%s %s not found", matcher.group(1), matcher.group(2)); - } else { - message = path; - } - exception = new ResourceNotFoundException(message); - } - break; - case 422: - exception = new IllegalStateException(content); - break; - default: - exception = new HttpResponseException(command, response, content); - } - } finally { - releasePayload(response); - command.setException(exception); - } - } - - @Singleton - static class ErrorParser { - final ParseSax.Factory factory; - final Provider errorHandlerProvider; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - ErrorParser(Factory factory, Provider errorHandlerProvider) { - this.factory = factory; - this.errorHandlerProvider = errorHandlerProvider; - } - - String parse(String in) { - return factory.create(errorHandlerProvider.get()).parse(in); - } - - } - - String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { - // slicehost returns " " which is unparsable - if (response.getPayload() != null) { - try { - String payload = Strings2.toString(response.getPayload()).trim(); - return payload.indexOf("xml") != -1 ? errorParser.parse(payload) : payload; - } catch (IOException e) { - } - } - return null; - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceActive.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceActive.java deleted file mode 100644 index 9cd3d8a031..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceActive.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.slicehost.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.slicehost.SlicehostClient; -import org.jclouds.slicehost.domain.Slice; - -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * - * - * @author Adrian Cole - */ -@Singleton -public class SliceActive implements Predicate { - - private final SlicehostClient client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public SliceActive(SlicehostClient client) { - this.client = client; - } - - public boolean apply(Slice slice) { - logger.trace("looking for state on slice %s", checkNotNull(slice, "slice")); - slice = refresh(slice); - if (slice == null) - return false; - logger.trace("%s: looking for slice state %s: currently: %s", slice.getId(), Slice.Status.ACTIVE, slice - .getStatus()); - return slice.getStatus() == Slice.Status.ACTIVE; - } - - private Slice refresh(Slice slice) { - return client.getSlice(slice.getId()); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceTerminated.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceTerminated.java deleted file mode 100644 index 6908f7ce89..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/predicates/SliceTerminated.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.slicehost.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.slicehost.SlicehostClient; -import org.jclouds.slicehost.domain.Slice; - -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class SliceTerminated implements Predicate { - - private final SlicehostClient client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public SliceTerminated(SlicehostClient client) { - this.client = client; - } - - public boolean apply(Slice slice) { - logger.trace("looking for state on slice %s", checkNotNull(slice, "slice")); - slice = refresh(slice); - if (slice == null) - return true; - logger.trace("%s: looking for slice state %s: currently: %s", slice.getId(), Slice.Status.TERMINATED, slice - .getStatus()); - return slice.getStatus() == Slice.Status.TERMINATED; - } - - private Slice refresh(Slice slice) { - return client.getSlice(slice.getId()); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupHandler.java deleted file mode 100644 index b808112413..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupHandler.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.slicehost.xml; - -import java.text.DateFormat; -import java.text.ParseException; -import java.util.Date; - -import javax.annotation.Resource; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.slicehost.domain.Backup; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class BackupHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private int id; - private String name; - private String sliceId; - private Date date; - - private Backup backup; - @Resource - protected Logger logger = Logger.NULL; - - public Backup getResult() { - return backup; - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("id")) { - id = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("slice_id")) { - sliceId = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("date")) { - try { - date = DateFormat.getInstance().parse(currentText.toString().trim()); - } catch (ParseException e) { - logger.warn(e, "error parsing: %s", currentText.toString().trim()); - } - } else if (qName.equalsIgnoreCase("backup")) { - this.backup = new Backup(id, name, sliceId, date); - this.id = -1; - this.name = null; - this.sliceId = null; - this.date = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupsHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupsHandler.java deleted file mode 100644 index b7a61d319d..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/BackupsHandler.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.slicehost.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Backup; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class BackupsHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set backups = Sets.newLinkedHashSet(); - private final BackupHandler locationHandler; - - @Inject - public BackupsHandler(BackupHandler locationHandler) { - this.locationHandler = locationHandler; - } - - public Set getResult() { - return backups; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - locationHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - locationHandler.endElement(uri, localName, qName); - if (qName.equals("backup") && currentText.toString().trim().equals("")) { - this.backups.add(locationHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - locationHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ErrorHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ErrorHandler.java deleted file mode 100644 index 3582c8699a..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ErrorHandler.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.slicehost.xml; - -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class ErrorHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private String error; - - public String getResult() { - return error; - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("error")) { - this.error = currentText.toString().trim(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorHandler.java deleted file mode 100644 index 778325df64..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorHandler.java +++ /dev/null @@ -1,65 +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.slicehost.xml; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Flavor; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class FlavorHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private int id; - private String name; - private int price; - private int ram; - - private Flavor flavor; - - public Flavor getResult() { - return flavor; - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("id")) { - id = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("ram")) { - ram = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("price")) { - price = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("flavor")) { - this.flavor = new Flavor(id, name, price, ram); - this.id = -1; - this.name = null; - this.ram = -1; - this.price = 0; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorsHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorsHandler.java deleted file mode 100644 index 4129fb1ddf..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/FlavorsHandler.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.slicehost.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Flavor; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class FlavorsHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set slices = Sets.newLinkedHashSet(); - private final FlavorHandler locationHandler; - - @Inject - public FlavorsHandler(FlavorHandler locationHandler) { - this.locationHandler = locationHandler; - } - - public Set getResult() { - return slices; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - locationHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - locationHandler.endElement(uri, localName, qName); - if (qName.equals("flavor") && currentText.toString().trim().equals("")) { - this.slices.add(locationHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - locationHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImageHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImageHandler.java deleted file mode 100644 index be6f20a67e..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImageHandler.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.slicehost.xml; - -import javax.annotation.Resource; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.slicehost.domain.Image; -import org.xml.sax.SAXException; - -/** - * @author Adrian Cole - */ -public class ImageHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private int id; - private String name; - - private Image image; - @Resource - protected Logger logger = Logger.NULL; - - public Image getResult() { - return image; - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("id")) { - id = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("image")) { - this.image = new Image(id, name); - this.id = -1; - this.name = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImagesHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/ImagesHandler.java deleted file mode 100644 index cc6960d668..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/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.slicehost.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Image; -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 locationHandler; - - @Inject - public ImagesHandler(ImageHandler locationHandler) { - this.locationHandler = locationHandler; - } - - public Set getResult() { - return images; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - locationHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - locationHandler.endElement(uri, localName, qName); - if (qName.equals("image") && currentText.toString().trim().equals("")) { - this.images.add(locationHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - locationHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SliceHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SliceHandler.java deleted file mode 100644 index d6b7ad4b13..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SliceHandler.java +++ /dev/null @@ -1,108 +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.slicehost.xml; - -import java.util.Set; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.slicehost.domain.Slice; -import org.jclouds.slicehost.domain.Slice.Status; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class SliceHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private int id; - private String name; - private int flavorId; - @Nullable - private Integer imageId; - @Nullable - private Integer backupId; - private Status status; - @Nullable - private Integer progress; - private float bandwidthIn; - private float bandwidthOut; - private Set addresses = Sets.newLinkedHashSet(); - @Nullable - private String rootPassword; - - private Slice slice; - - public Slice getResult() { - return slice; - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equalsIgnoreCase("id")) { - id = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("name")) { - this.name = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("flavor-id")) { - flavorId = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("image-id")) { - imageId = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("backup-id")) { - backupId = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("status")) { - this.status = Slice.Status.fromValue(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("progress")) { - try { - progress = Integer.parseInt(currentText.toString().trim()); - } catch (NumberFormatException e) { - - } - } else if (qName.equalsIgnoreCase("bw-in")) { - bandwidthIn = Float.parseFloat(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("bw-out")) { - bandwidthOut = Float.parseFloat(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("address")) { - this.addresses.add(currentText.toString().trim()); - } else if (qName.equalsIgnoreCase("root-password")) { - this.rootPassword = currentText.toString().trim(); - } else if (qName.equalsIgnoreCase("slice")) { - this.slice = new Slice(id, name, flavorId, imageId, backupId, status, progress, bandwidthIn, bandwidthOut, - addresses, rootPassword); - this.id = -1; - this.name = null; - this.flavorId = -1; - this.imageId = null; - this.backupId = null; - this.status = null; - this.progress = null; - this.bandwidthIn = 0; - this.bandwidthOut = 0; - this.addresses = Sets.newLinkedHashSet(); - this.rootPassword = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SlicesHandler.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SlicesHandler.java deleted file mode 100644 index d6d7e2cd62..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/xml/SlicesHandler.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.slicehost.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Slice; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class SlicesHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private Set slices = Sets.newLinkedHashSet(); - private final SliceHandler locationHandler; - - @Inject - public SlicesHandler(SliceHandler locationHandler) { - this.locationHandler = locationHandler; - } - - public Set getResult() { - return slices; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - locationHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - locationHandler.endElement(uri, localName, qName); - if (qName.equals("slice") && currentText.toString().trim().equals("")) { - this.slices.add(locationHandler.getResult()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - locationHandler.characters(ch, start, length); - currentText.append(ch, start, length); - } -} diff --git a/providers/slicehost/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/slicehost/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 78e0e800bc..0000000000 --- a/providers/slicehost/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.slicehost.SlicehostProviderMetadata diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java deleted file mode 100644 index a24e36a361..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java +++ /dev/null @@ -1,258 +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.slicehost; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.lang.reflect.Method; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseAsyncClientTest; -import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.slicehost.filters.SlicehostBasic; -import org.jclouds.slicehost.xml.FlavorHandler; -import org.jclouds.slicehost.xml.FlavorsHandler; -import org.jclouds.slicehost.xml.ImageHandler; -import org.jclouds.slicehost.xml.ImagesHandler; -import org.jclouds.slicehost.xml.SliceHandler; -import org.jclouds.slicehost.xml.SlicesHandler; -import org.testng.annotations.Test; - -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code SlicehostAsyncClient} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SlicehostAsyncClientTest") -public class SlicehostAsyncClientTest extends BaseAsyncClientTest { - - public void testCreateSlice() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("createSlice", String.class, int.class, int.class); - HttpRequest request = processor.createRequest(method, "ralphie", 2, 1); - - assertRequestLineEquals(request, "POST https://api.slicehost.com/slices.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals( - request, - "12ralphie", - "application/xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SliceHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - - } - - public void testDestroySlice() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("destroySlice", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "DELETE https://api.slicehost.com/slices/2/destroy.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListSlices() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("listSlices"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/slices.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SlicesHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetSlice() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("getSlice", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/slices/2.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SliceHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("listFlavors"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/flavors.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, FlavorsHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("getFlavor", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/flavors/2.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, FlavorHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListImages() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("listImages"); - HttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/images.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SlicehostAsyncClient.class.getMethod("getImage", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "GET https://api.slicehost.com/images/2.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, ImageHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - - public void testRebuildSliceFromImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("rebuildSliceFromImage", int.class, int.class); - HttpRequest request = processor.createRequest(method, 3, 1); - - assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/3/rebuild.xml?image_id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testRebuildSliceFromBackup() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("rebuildSliceFromBackup", int.class, int.class); - HttpRequest request = processor.createRequest(method, 3, 1); - - assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/3/rebuild.xml?backup_id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testReboot() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("rebootSlice", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/2/reboot.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testHardReboot() throws IOException, SecurityException, NoSuchMethodException { - Method method = SlicehostAsyncClient.class.getMethod("hardRebootSlice", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/2/hard_reboot.xml HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), SlicehostBasic.class); - - } - - @Override - public ProviderMetadata createProviderMetadata() { - return new SlicehostProviderMetadata(); - } - -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java deleted file mode 100644 index b1db169031..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ /dev/null @@ -1,303 +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.slicehost; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.lang.reflect.UndeclaredThrowableException; -import java.security.SecureRandom; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpResponseException; -import org.jclouds.io.Payloads; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.predicates.SocketOpen; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.domain.Image; -import org.jclouds.slicehost.domain.Slice; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshException; -import org.jclouds.util.Predicates2; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; -import com.google.common.net.HostAndPort; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code SlicehostClient} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "SlicehostClientLiveTest") -public class SlicehostClientLiveTest extends BaseComputeServiceContextLiveTest { - - public SlicehostClientLiveTest() { - provider = "slicehost"; - } - - protected SlicehostClient client; - protected SshClient.Factory sshFactory; - private Predicate socketTester; - - @BeforeGroups(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - Injector injector = view.utils().injector(); - - client = injector.getInstance(SlicehostClient.class); - sshFactory = injector.getInstance(SshClient.Factory.class); - SocketOpen socketOpen = injector.getInstance(SocketOpen.class); - socketTester = new RetryablePredicate(socketOpen, 120, 1, TimeUnit.SECONDS); - injector.injectMembers(socketOpen); // add logger - } - - public void testListSlices() throws Exception { - - Set response = client.listSlices(); - assert null != response; - long initialContainerCount = response.size(); - assertTrue(initialContainerCount >= 0); - - } - - public void testListSlicesDetail() throws Exception { - Set response = client.listSlices(); - assert null != response; - long initialContainerCount = response.size(); - assertTrue(initialContainerCount >= 0); - } - - public void testListImages() throws Exception { - Set response = client.listImages(); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 1); - for (Image image : response) { - assertTrue(image.getId() >= 0); - assert null != image.getName() : image; - } - - } - - public void testListImagesDetail() throws Exception { - Set response = client.listImages(); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 0); - for (Image image : response) { - assertTrue(image.getId() >= 1); - assert null != image.getName() : image; - } - } - - public void testGetImagesDetail() throws Exception { - Set response = client.listImages(); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 0); - for (Image image : response) { - try { - Image newDetails = client.getImage(image.getId()); - assertEquals(image, newDetails); - } catch (HttpResponseException e) {// Ticket #9867 - if (e.getResponse().getStatusCode() != 400) - throw e; - } - } - } - - @Test - public void testGetImageDetailsNotFound() throws Exception { - assert client.getImage(12312987) == null; - } - - @Test - public void testGetSliceDetailsNotFound() throws Exception { - assert client.getSlice(12312987) == null; - } - - public void testGetSlicesDetail() throws Exception { - Set response = client.listSlices(); - assert null != response; - long sliceCount = response.size(); - assertTrue(sliceCount >= 0); - for (Slice slice : response) { - Slice newDetails = client.getSlice(slice.getId()); - assertEquals(slice, newDetails); - } - } - - public void testListFlavors() throws Exception { - Set response = client.listFlavors(); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 1); - for (Flavor flavor : response) { - assertTrue(flavor.getId() >= 0); - assert null != flavor.getName() : flavor; - } - - } - - public void testListFlavorsDetail() throws Exception { - Set response = client.listFlavors(); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 0); - for (Flavor flavor : response) { - assertTrue(flavor.getId() >= 1); - assert null != flavor.getName() : flavor; - assert -1 != flavor.getRam() : flavor; - } - } - - public void testGetFlavorsDetail() throws Exception { - Set response = client.listFlavors(); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 0); - for (Flavor flavor : response) { - Flavor newDetails = client.getFlavor(flavor.getId()); - assertEquals(flavor, newDetails); - } - } - - @Test - public void testGetFlavorDetailsNotFound() throws Exception { - assert client.getFlavor(12312987) == null; - } - - private String slicePrefix = System.getProperty("user.name") + ".sh"; - private int sliceId; - private String rootPassword; - - @Test(enabled = true) - public void testCreateSlice() throws Exception { - int imageId = 14362; - int flavorId = 1; - Slice slice = null; - while (slice == null) { - String sliceName = slicePrefix + "createslice" + new SecureRandom().nextInt(); - try { - slice = client.createSlice(sliceName, imageId, flavorId); - } catch (UndeclaredThrowableException e) { - HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); - if (htpe.getResponse().getStatusCode() == 400) - continue; - throw e; - } - } - assertNotNull(slice.getRootPassword()); - sliceId = slice.getId(); - rootPassword = slice.getRootPassword(); - assertEquals(slice.getStatus(), Slice.Status.BUILD); - blockUntilSliceActive(sliceId); - } - - private void blockUntilSliceActive(int sliceId) throws InterruptedException { - Slice currentDetails = null; - for (currentDetails = client.getSlice(sliceId); currentDetails.getStatus() != Slice.Status.ACTIVE; currentDetails = client - .getSlice(sliceId)) { - System.out.printf("blocking on status active%n%s%n", currentDetails); - Thread.sleep(5 * 1000); - } - } - - @Test(enabled = true, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateSlice") - public void testSliceDetails() throws Exception { - Slice slice = client.getSlice(sliceId); - assertEquals(slice.getStatus(), Slice.Status.ACTIVE); - assert slice.getProgress() >= 0 : "newDetails.getProgress()" + slice.getProgress(); - assertEquals(Integer.valueOf(14362), slice.getImageId()); - assertEquals(1, slice.getFlavorId()); - assertNotNull(slice.getAddresses()); - checkPassOk(slice, rootPassword); - } - - private void checkPassOk(Slice newDetails, String pass) throws IOException { - try { - doCreateMarkerFile(newDetails, pass); - } catch (SshException e) {// try twice in case there is a network timeout - try { - Thread.sleep(10 * 1000); - } catch (InterruptedException e1) { - } - doCreateMarkerFile(newDetails, pass); - } - } - - private void doCreateMarkerFile(Slice newDetails, String pass) throws IOException { - String ip = getIp(newDetails); - HostAndPort socket = HostAndPort.fromParts(ip, 22); - socketTester.apply(socket); - - SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build()); - try { - client.connect(); - client.put("/etc/jclouds.txt", Payloads.newStringPayload("slicehost")); - } finally { - if (client != null) - client.disconnect(); - } - } - - private String getIp(Slice newDetails) { - return Iterables.find(newDetails.getAddresses(), Predicates.not(Predicates2.startsWith("10."))); - } - - @Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testSliceDetails") - public void testRebootHard() throws Exception { - client.hardRebootSlice(sliceId); - blockUntilSliceActive(sliceId); - } - - @Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootHard") - public void testRebootSoft() throws Exception { - client.rebootSlice(sliceId); - blockUntilSliceActive(sliceId); - } - - @Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft") - void destroySlice1() { - if (sliceId > 0) { - client.destroySlice(sliceId); - assert client.getSlice(sliceId) == null; - } - } - - @AfterTest - void destroySlicesOnEnd() { - if (sliceId > 0) { - client.destroySlice(sliceId); - } - - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java deleted file mode 100644 index efaa51877a..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.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.slicehost; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "SlicehostProviderTest") -public class SlicehostProviderTest extends BaseProviderMetadataTest { - - public SlicehostProviderTest() { - super(new SlicehostProviderMetadata(), new SlicehostApiMetadata()); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java deleted file mode 100644 index ef37640c50..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ /dev/null @@ -1,74 +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.slicehost.compute; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * - * Generally disabled, as it incurs higher fees. - * - * @author Adrian Cole - */ -@Test(groups = "live", enabled = true, singleThreaded = true) -public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public SlicehostComputeServiceLiveTest() { - provider = "slicehost"; - } - - @Override - protected SshjSshClientModule getSshModule() { - return new SshjSshClientModule(); - } - - // slicehost 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); - } - @Test(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/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java deleted file mode 100644 index 615ce29e86..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ /dev/null @@ -1,92 +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.slicehost.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -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 SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public SlicehostTemplateBuilderLiveTest() { - provider = "slicehost"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04") || input.version.startsWith("11")) - && input.is64Bit; - case DEBIAN: - return input.is64Bit; - case CENTOS: - return (input.version.equals("") || input.version.matches("5.[0456]") || input.version.equals("6.0")) - && input.is64Bit; - case WINDOWS: - return input.version.equals("2008 SP2") || input.version.equals("") - || ((input.version.equals("2003") || input.version.equals("2008 R2")) && input.is64Bit); - default: - return false; - } - } - - }); - } - - @Override - public void testFromTemplate() { - // TODO: multiple servers match - } - - @Test - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(getCores(defaultTemplate.getHardware()), 0.25d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("US-IL", "US-TX", "US-MO"); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java deleted file mode 100644 index b6e9872596..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java +++ /dev/null @@ -1,37 +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.slicehost.compute.config; - -import org.jclouds.slicehost.domain.Slice; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit") -public class SlicehostComputeServiceContextModuleTest { - - public void testAllStatusCovered() { - - for (Slice.Status state : Slice.Status.values()) { - assert SlicehostComputeServiceContextModule.sliceStatusToNodeStatus.containsKey(state) : state; - } - - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/FlavorToHardwareTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/FlavorToHardwareTest.java deleted file mode 100644 index 29afcc81c9..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/FlavorToHardwareTest.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.slicehost.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.UnknownHostException; - -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.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.slicehost.domain.Flavor; -import org.jclouds.slicehost.xml.FlavorHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit") -public class FlavorToHardwareTest { - Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); - - @Test - public void test() throws UnknownHostException { - assertEquals( - convertFlavor(), - new HardwareBuilder() - .ids("1") - .name("256 slice") - .processors(ImmutableList.of(new Processor(0.25, 1.0))) - .ram(256) - .volumes( - ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(1.0f).durable(true) - .bootDevice(true).build())).build()); - } - - public static Hardware convertFlavor() { - Flavor flavor = FlavorHandlerTest.parseFlavor(); - - FlavorToHardware parser = new FlavorToHardware(); - - return parser.apply(flavor); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java deleted file mode 100644 index 6b83279fcf..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.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.slicehost.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.VolumeBuilder; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; -import org.jclouds.slicehost.domain.Slice; -import org.jclouds.slicehost.xml.SliceHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "SliceToNodeMetadataTest") -public class SliceToNodeMetadataTest { - Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); - GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class); - - @Test - public void testApplyWhereImageAndHardwareNotFound() { - Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; - Set images = ImmutableSet.of(); - Set hardwares = ImmutableSet.of(); - Slice slice = SliceHandlerTest.parseSlice(); - - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers - .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers - .> ofInstance(hardwares), namingConvention); - - NodeMetadata metadata = parser.apply(slice); - - assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") - .imageId("2").id("1").providerId("1").name("jclouds-foo").hostname("jclouds-foo").location(provider) - .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } - - @Test - public void testApplyWhereImageFoundAndHardwareNotFound() { - Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; - org.jclouds.compute.domain.Image jcImage = SlicehostImageToImageTest.convertImage(); - Set images = ImmutableSet.of(jcImage); - Set hardwares = ImmutableSet.of(); - Slice slice = SliceHandlerTest.parseSlice(); - - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers - .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers - .> ofInstance(hardwares), namingConvention); - - NodeMetadata metadata = parser.apply(slice); - assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") - .imageId("2").operatingSystem( - new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") - .is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").hostname( - "jclouds-foo").location(provider).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } - - @Test - public void testApplyWhereImageAndHardwareFound() { - Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; - Set images = ImmutableSet.of(SlicehostImageToImageTest.convertImage()); - Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); - Slice slice = SliceHandlerTest.parseSlice(); - - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers - .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers - .> ofInstance(hardwares), namingConvention); - - NodeMetadata metadata = parser.apply(slice); - assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") - .imageId("2").hardware( - new HardwareBuilder().ids("1").name("256 slice").processors( - ImmutableList.of(new Processor(0.25, 1.0))).ram(256).volumes( - ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(1.0f).durable(true) - .bootDevice(true).build())).build()).operatingSystem( - new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") - .is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").hostname( - "jclouds-foo").location(provider).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java deleted file mode 100644 index b28cca2627..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java +++ /dev/null @@ -1,92 +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.slicehost.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.UnknownHostException; - -import org.jclouds.compute.config.BaseComputeServiceContextModule; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.json.Json; -import org.jclouds.json.config.GsonModule; -import org.jclouds.slicehost.xml.ImageHandlerTest; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "SlicehostImageToImageTest") -public class SlicehostImageToImageTest { - Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); - - @Test - public void test() throws UnknownHostException { - Image toTest = convertImage(); - assertEquals( - toTest, - new ImageBuilder() - .name("CentOS 5.2") - .operatingSystem( - new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2") - .is64Bit(true).build()).description("CentOS 5.2").ids("2") - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build()); - assertEquals(toTest.getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - } - - @Test - public void test32() throws UnknownHostException { - Image toTest = convertImage("/test_get_image32.xml"); - assertEquals( - toTest, - new ImageBuilder() - .name("Ubuntu 10.10 (maverick) 32-bit") - .operatingSystem( - new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("10.10") - .description("Ubuntu 10.10 (maverick) 32-bit").build()) - .description("Ubuntu 10.10 (maverick) 32-bit").ids("70") - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build()); - assertEquals(toTest.getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - } - - public static Image convertImage() { - return convertImage("/test_get_image.xml"); - } - - public static Image convertImage(String resource) { - org.jclouds.slicehost.domain.Image image = ImageHandlerTest.parseImage(resource); - - SlicehostImageToImage parser = new SlicehostImageToImage(new SlicehostImageToOperatingSystem( - new BaseComputeServiceContextModule() { - }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule()) - .getInstance(Json.class)))); - - return parser.apply(image); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorHandlerTest.java deleted file mode 100644 index 7e01f862c6..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorHandlerTest.java +++ /dev/null @@ -1,59 +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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.slicehost.domain.Flavor; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code FlavorHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class FlavorHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = (ParseSax) injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(FlavorHandler.class)); - return parser; - } - - public static Flavor parseFlavor() { - InputStream is = FlavorHandlerTest.class.getResourceAsStream("/test_get_flavor.xml"); - return createParser().parse(is); - } - - public void test() { - Flavor expects = new Flavor(1, "256 slice", 2000, 256); - - assertEquals(parseFlavor(), expects); - } - -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorsHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorsHandlerTest.java deleted file mode 100644 index 0a97e1cbb1..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/FlavorsHandlerTest.java +++ /dev/null @@ -1,55 +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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Flavor; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code FlavorsHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "FlavorsHandlerTest") -public class FlavorsHandlerTest extends BaseHandlerTest { - - ParseSax> createParser() { - ParseSax> parser = (ParseSax>) factory.create(injector - .getInstance(FlavorsHandler.class)); - return parser; - } - - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_flavors.xml"); - Set expects = ImmutableSet.of(new Flavor(1, "256 slice", 2000, 256), new Flavor(2, "512 slice", - 3800, 512), new Flavor(3, "1GB slice", 7000, 1024), new Flavor(4, "2GB slice", 13000, 2048)); - assertEquals(createParser().parse(is), expects); - } - -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImageHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImageHandlerTest.java deleted file mode 100644 index e366a0e294..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImageHandlerTest.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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.slicehost.domain.Image; -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(2, "CentOS 5.2"); - assertEquals(parseImage(), expects); - } - - public void test32() { - Image expects = new Image(70, "Ubuntu 10.10 (maverick) 32-bit"); - assertEquals(parseImage("/test_get_image32.xml"), expects); - } - -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImagesHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImagesHandlerTest.java deleted file mode 100644 index 802756baee..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/ImagesHandlerTest.java +++ /dev/null @@ -1,77 +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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Image; -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 { - - ParseSax> createParser() { - ParseSax> parser = (ParseSax>) factory.create(injector - .getInstance(ImagesHandler.class)); - return parser; - } - - public void test() { - InputStream is = getClass().getResourceAsStream("/test_list_images.xml"); - Set expects = ImmutableSet.of( - - new Image(2, "CentOS 5.2"), new Image(3, "Gentoo 2008.0"), - - new Image(4, "Debian 5.0 (lenny)"), - - new Image(5, "Fedora 10 (Cambridge)"), - - new Image(7, "CentOS 5.3"), - - new Image(8, "Ubuntu 9.04 (jaunty)"), - - new Image(9, "Arch 2009.02"), - - new Image(10, "Ubuntu 8.04.2 LTS (hardy)"), - - new Image(11, "Ubuntu 8.10 (intrepid)"), - - new Image(70, "Ubuntu 10.10 (maverick) 32-bit"), - - new Image(12, "Red Hat EL 5.3"), - - new Image(13, "Fedora 11 (Leonidas)") - - ); - assertEquals(createParser().parse(is), expects); - } -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SliceHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SliceHandlerTest.java deleted file mode 100644 index 42578bb527..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SliceHandlerTest.java +++ /dev/null @@ -1,75 +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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.slicehost.domain.Slice; -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 SliceHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SliceHandlerTest") -public class SliceHandlerTest extends BaseHandlerTest { - - static ParseSax createParser() { - Injector injector = Guice.createInjector(new SaxParserModule()); - ParseSax parser = (ParseSax) injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(SliceHandler.class)); - return parser; - } - - public static Slice parseSlice() { - return parseSlice("/test_get_slice.xml"); - } - - public static Slice parseSlice(String resource) { - InputStream is = SliceHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } - - public void test() { - Slice expects = new Slice(1, "jclouds-foo", 1, 2, null, Slice.Status.BUILD, 0, 0, 0, ImmutableSet. of( - "174.143.212.229", "10.176.164.199"), null); - - assertEquals(parseSlice("/test_get_slice.xml"), expects); - } - - public void testNew() { - Slice expects = new Slice(71907, "slicetest", 1, 11, null, Slice.Status.BUILD, 0, 0, 0, ImmutableSet. of( - "10.176.168.15", "67.23.20.114"), "fooadfa1231"); - - assertEquals(parseSlice("/test_new_slice.xml"), expects); - - } - -} diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SlicesHandlerTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SlicesHandlerTest.java deleted file mode 100644 index 509f284ad3..0000000000 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/xml/SlicesHandlerTest.java +++ /dev/null @@ -1,56 +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.slicehost.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.slicehost.domain.Slice; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code SlicesHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SlicesHandlerTest") -public class SlicesHandlerTest extends BaseHandlerTest { - - ParseSax> createParser() { - ParseSax> parser = (ParseSax>) factory.create(injector - .getInstance(SlicesHandler.class)); - return parser; - } - - public void test() { - InputStream is = getClass().getResourceAsStream("/test_get_slice.xml"); - Set expects = ImmutableSet.of(new Slice(1, "jclouds-foo", 1, 2, null, Slice.Status.BUILD, 0, 0, - 0, ImmutableSet. of("174.143.212.229", "10.176.164.199"), null)); - - assertEquals(createParser().parse(is), expects); - } - -} diff --git a/providers/slicehost/src/test/resources/log4j.xml b/providers/slicehost/src/test/resources/log4j.xml deleted file mode 100644 index bcf0171697..0000000000 --- a/providers/slicehost/src/test/resources/log4j.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/providers/slicehost/src/test/resources/test_errors.xml b/providers/slicehost/src/test/resources/test_errors.xml deleted file mode 100644 index 6555aa11d5..0000000000 --- a/providers/slicehost/src/test/resources/test_errors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Slice parameters are not properly nested - diff --git a/providers/slicehost/src/test/resources/test_get_flavor.xml b/providers/slicehost/src/test/resources/test_get_flavor.xml deleted file mode 100644 index d15457e55a..0000000000 --- a/providers/slicehost/src/test/resources/test_get_flavor.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 1 - 256 slice - 2000 - 256 - \ No newline at end of file diff --git a/providers/slicehost/src/test/resources/test_get_image.xml b/providers/slicehost/src/test/resources/test_get_image.xml deleted file mode 100644 index 144e73e43b..0000000000 --- a/providers/slicehost/src/test/resources/test_get_image.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - CentOS 5.2 - 2 - - diff --git a/providers/slicehost/src/test/resources/test_get_image32.xml b/providers/slicehost/src/test/resources/test_get_image32.xml deleted file mode 100644 index bf94c5d172..0000000000 --- a/providers/slicehost/src/test/resources/test_get_image32.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Ubuntu 10.10 (maverick) 32-bit - 70 - - diff --git a/providers/slicehost/src/test/resources/test_get_slice.xml b/providers/slicehost/src/test/resources/test_get_slice.xml deleted file mode 100644 index a4b373fe2c..0000000000 --- a/providers/slicehost/src/test/resources/test_get_slice.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - jclouds-foo - 2 - -

174.143.212.229
-
10.176.164.199
- - 0 - 1 - 0.0 - 0.0 - 1 - build - 174.143.212.229 - - diff --git a/providers/slicehost/src/test/resources/test_list_flavors.xml b/providers/slicehost/src/test/resources/test_list_flavors.xml deleted file mode 100644 index fc1651c386..0000000000 --- a/providers/slicehost/src/test/resources/test_list_flavors.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - 1 - 256 slice - 2000 - 256 - - - 2 - 512 slice - 3800 - 512 - - - 3 - 1GB slice - 7000 - 1024 - - - 4 - 2GB slice - 13000 - 2048 - - diff --git a/providers/slicehost/src/test/resources/test_list_images.xml b/providers/slicehost/src/test/resources/test_list_images.xml deleted file mode 100644 index 45ec21ece6..0000000000 --- a/providers/slicehost/src/test/resources/test_list_images.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - CentOS 5.2 - 2 - - - Gentoo 2008.0 - 3 - - - Debian 5.0 (lenny) - 4 - - - Fedora 10 (Cambridge) - 5 - - - CentOS 5.3 - 7 - - - Ubuntu 9.04 (jaunty) - 8 - - - Arch 2009.02 - 9 - - - Ubuntu 8.04.2 LTS (hardy) - 10 - - - Ubuntu 8.10 (intrepid) - 11 - - - Ubuntu 10.10 (maverick) 32-bit - 70 - - - Red Hat EL 5.3 - 12 - - - Fedora 11 (Leonidas) - 13 - - diff --git a/providers/slicehost/src/test/resources/test_list_slices.xml b/providers/slicehost/src/test/resources/test_list_slices.xml deleted file mode 100644 index 701d272b7c..0000000000 --- a/providers/slicehost/src/test/resources/test_list_slices.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - slicehost-1 - 50 - -
10.179.78.86
-
173.203.51.27
-
- 100 - 281343 - 0.0 - 0.07 - 1 - active - 10.179.78.86 -
- - slicehost-602 - 50 - -
10.179.78.89
-
173.203.51.32
-
- 100 - 281347 - 0.0 - 0.07 - 1 - active - 10.179.78.89 -
- - slicehostblock-a7 - 50 - -
10.179.78.91
-
173.203.51.33
-
- 100 - 281357 - 0.0 - 0.0 - 1 - build - 10.179.78.91 -
-
diff --git a/providers/slicehost/src/test/resources/test_new_slice.xml b/providers/slicehost/src/test/resources/test_new_slice.xml deleted file mode 100644 index 2257f2660d..0000000000 --- a/providers/slicehost/src/test/resources/test_new_slice.xml +++ /dev/null @@ -1,16 +0,0 @@ - - slicetest - 11 - -
10.176.168.15
-
67.23.20.114
-
- fooadfa1231 - 0 - 71907 - 0.0 - 0.0 - 1 - build - 10.176.168.15 -