Remove Shipyard provider. Project is no longer maintained and is essentially superceded by kubernetes
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/9c19ee0c Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/9c19ee0c Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/9c19ee0c Branch: refs/heads/master Commit: 9c19ee0c826db2599b9b6d3a9c29215591abaa7a Parents: 7363290 Author: Christopher Dancy <[email protected]> Authored: Sat Jul 25 16:04:53 2015 -0400 Committer: Ignasi Barrera <[email protected]> Committed: Mon Jul 27 09:23:39 2015 +0200 ---------------------------------------------------------------------- pom.xml | 1 - shipyard/README.md | 22 --- shipyard/pom.xml | 148 ------------------ .../java/org/jclouds/shipyard/ShipyardApi.java | 44 ------ .../jclouds/shipyard/ShipyardApiMetadata.java | 81 ---------- .../shipyard/config/ShipyardHttpApiModule.java | 45 ------ .../domain/containers/ContainerImageInfo.java | 71 --------- .../domain/containers/ContainerInfo.java | 58 ------- .../domain/containers/DeployContainer.java | 82 ---------- .../shipyard/domain/engines/AddEngine.java | 45 ------ .../shipyard/domain/engines/EngineInfo.java | 37 ----- .../domain/engines/EngineSettingsInfo.java | 54 ------- .../shipyard/domain/images/ImageInfo.java | 58 ------- .../shipyard/domain/images/ImagePortsInfo.java | 41 ----- .../jclouds/shipyard/domain/roles/RoleInfo.java | 38 ----- .../shipyard/domain/servicekeys/ServiceKey.java | 38 ----- .../shipyard/fallbacks/ShipyardFallbacks.java | 61 -------- .../shipyard/features/ContainersApi.java | 69 --------- .../jclouds/shipyard/features/EnginesApi.java | 59 ------- .../jclouds/shipyard/features/ImagesApi.java | 38 ----- .../org/jclouds/shipyard/features/RolesApi.java | 63 -------- .../shipyard/features/ServiceKeysApi.java | 55 ------- .../filters/ServiceKeyAuthentication.java | 55 ------- .../shipyard/handlers/ShipyardErrorHandler.java | 111 ------------- .../shipyard/ShipyardApiMetadataTest.java | 49 ------ .../features/ContainersApiLiveTest.java | 154 ------------------- .../features/ContainersApiMockTest.java | 144 ----------------- .../shipyard/features/EnginesApiLiveTest.java | 90 ----------- .../shipyard/features/EnginesApiMockTest.java | 134 ---------------- .../shipyard/features/ImagesApiLiveTest.java | 42 ----- .../shipyard/features/ImagesApiMockTest.java | 69 --------- .../shipyard/features/RolesApiLiveTest.java | 90 ----------- .../shipyard/features/RolesApiMockTest.java | 125 --------------- .../features/ServiceKeysApiLiveTest.java | 81 ---------- .../features/ServiceKeysApiMockTest.java | 112 -------------- .../internal/BaseShipyardApiLiveTest.java | 47 ------ .../shipyard/internal/BaseShipyardMockTest.java | 112 -------------- .../internal/BaseShipyardParseTest.java | 31 ---- .../shipyard/parse/ContainersParseTest.java | 67 -------- .../shipyard/parse/EnginesParseTest.java | 51 ------ .../jclouds/shipyard/parse/ImagesParseTest.java | 51 ------ .../resources/container-deploy-response.json | 49 ------ .../src/test/resources/container-deploy.json | 18 --- shipyard/src/test/resources/container.json | 47 ------ shipyard/src/test/resources/containers.json | 49 ------ shipyard/src/test/resources/engine-add.json | 15 -- shipyard/src/test/resources/engine.json | 12 -- shipyard/src/test/resources/engines.json | 14 -- shipyard/src/test/resources/image.json | 10 -- shipyard/src/test/resources/images.json | 12 -- .../src/test/resources/role-delete-create.json | 3 - shipyard/src/test/resources/role.json | 4 - shipyard/src/test/resources/roles.json | 10 -- .../src/test/resources/servicekey-create.json | 3 - .../src/test/resources/servicekey-response.json | 5 - shipyard/src/test/resources/servicekeys.json | 9 -- 56 files changed, 3083 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7799687..023f3e4 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,6 @@ <module>joyentcloud</module> <module>abiquo</module> <module>profitbricks</module> - <module>shipyard</module> </modules> <build> http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/README.md ---------------------------------------------------------------------- diff --git a/shipyard/README.md b/shipyard/README.md deleted file mode 100644 index 0545f87..0000000 --- a/shipyard/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Shipyard provider for jclouds -============================= -jclouds-shipyard allows one to connect and administer multiple docker daemons from a single endpoint. - -## Setup -Documentation on how to standup a Shipyard cluster can be found [here](https://github.com/shipyard/shipyard). - -More detailed information (docs, API, etc..) can be found on the Shipyard [site](http://shipyard-project.com/). - -## Testing -To run integration tests we need a valid Shipyard instance/endpoint, identity-key, and docker daemon to use. Testing, for now, assumes the docker daemon does not have ssl enabled. To run integration tests you could do something like: - -``` -mvn clean install -Plive -Dtest.shipyard.endpoint=http://10.0.0.8:8080 -Dtest.shipyard.identity=zEswusMbqMR8D7QA0yJbIc1CxGYqfLAG5bZO -Dtest.shipyard.docker.endpoint=http://10.0.0.8:2375 -``` - -## Help -For help with jclouds-shipyard you can email the jclouds-dev mailing list or ask questions on [IRC](http://irc.lc/freenode/jclouds/shipyard-help). - -For help with Shipyard itself you can reach out to devs on [IRC](http://irc.lc/freenode/shipyard/jclouds-help). - -jclouds-shipyard is still at alpha stage please report any issues you find at [jclouds-shipyard-issues](https://issues.apache.org/jira/browse/JCLOUDS). \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/pom.xml ---------------------------------------------------------------------- diff --git a/shipyard/pom.xml b/shipyard/pom.xml deleted file mode 100644 index a1bbd77..0000000 --- a/shipyard/pom.xml +++ /dev/null @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.jclouds.labs</groupId> - <artifactId>jclouds-labs</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> - - <!-- TODO: when out of labs, switch to org.jclouds.provider --> - <artifactId>shipyard</artifactId> - <name>jclouds shipyard API</name> - <description>ComputeService binding to the Shipyard API</description> - <packaging>bundle</packaging> - - <properties> - <test.shipyard.endpoint>http://localhost:8080</test.shipyard.endpoint> - <test.shipyard.docker.endpoint>http://localhost:2375</test.shipyard.docker.endpoint> - <test.shipyard.identity>FIXME</test.shipyard.identity> - <test.shipyard.credential>NA</test.shipyard.credential> - <test.shipyard.api-version>2.0.8</test.shipyard.api-version> - <jclouds.osgi.export>org.jclouds.shipyard*;version="${project.version}"</jclouds.osgi.export> - <jclouds.osgi.import> - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - </jclouds.osgi.import> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-compute</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.auto.service</groupId> - <artifactId>auto-service</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-okhttp</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-slf4j</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-compute</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>mockwebserver</artifactId> - <scope>test</scope> - <exclusions> - <!-- Already provided by jclouds-sshj --> - <exclusion> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk15on</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>live</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <execution> - <id>integration</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <threadCount>1</threadCount> - <systemPropertyVariables> - <test.shipyard.endpoint>${test.shipyard.endpoint}</test.shipyard.endpoint> - <test.shipyard.docker.endpoint>${test.shipyard.docker.endpoint}</test.shipyard.docker.endpoint> - <test.shipyard.identity>${test.shipyard.identity}</test.shipyard.identity> - <test.shipyard.credential>${test.shipyard.credential}</test.shipyard.credential> - <test.shipyard.api-version>${test.shipyard.api-version}</test.shipyard.api-version> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApi.java b/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApi.java deleted file mode 100644 index 79bde85..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApi.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard; - -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.shipyard.features.ContainersApi; -import org.jclouds.shipyard.features.EnginesApi; -import org.jclouds.shipyard.features.ImagesApi; -import org.jclouds.shipyard.features.RolesApi; -import org.jclouds.shipyard.features.ServiceKeysApi; - -import java.io.Closeable; - -public interface ShipyardApi extends Closeable { - - @Delegate - ContainersApi containersApi(); - - @Delegate - ImagesApi imagesApi(); - - @Delegate - EnginesApi enginesApi(); - - @Delegate - ServiceKeysApi serviceKeysApi(); - - @Delegate - RolesApi rolesApi(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApiMetadata.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApiMetadata.java b/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApiMetadata.java deleted file mode 100644 index ea4adb3..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/ShipyardApiMetadata.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard; - -import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.rest.internal.BaseHttpApiMetadata; -import org.jclouds.shipyard.config.ShipyardHttpApiModule; - -import java.net.URI; -import java.util.Properties; - -@AutoService(ApiMetadata.class) -public class ShipyardApiMetadata extends BaseHttpApiMetadata<ShipyardApi> { - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public ShipyardApiMetadata() { - this(new Builder()); - } - - protected ShipyardApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - return BaseHttpApiMetadata.defaultProperties(); - } - - public static class Builder extends BaseHttpApiMetadata.Builder<ShipyardApi, Builder> { - - protected Builder() { - super(ShipyardApi.class); - id("shipyard") - .name("Shipyard Remote Docker Management API") - .identityName("<shipyard-service-key>") - .credentialName("not used") - .documentation(URI.create("http://shipyard-project.com/docs/api/")) - .version("2.0.4") - .defaultEndpoint("https://127.0.0.1:8080") - .defaultProperties(ShipyardApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.<Class<? extends Module>>of( - ShipyardHttpApiModule.class)); - } - - @Override - public ShipyardApiMetadata build() { - return new ShipyardApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - - @Override - public Builder fromApiMetadata(ApiMetadata in) { - return this; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/config/ShipyardHttpApiModule.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/config/ShipyardHttpApiModule.java b/shipyard/src/main/java/org/jclouds/shipyard/config/ShipyardHttpApiModule.java deleted file mode 100644 index adcfc38..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/config/ShipyardHttpApiModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.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.http.config.ConfiguresHttpCommandExecutorService; -import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; -import org.jclouds.shipyard.ShipyardApi; -import org.jclouds.shipyard.handlers.ShipyardErrorHandler; - -@ConfiguresHttpApi -@ConfiguresHttpCommandExecutorService -public class ShipyardHttpApiModule extends HttpApiModule<ShipyardApi> { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ShipyardErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ShipyardErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ShipyardErrorHandler.class); - } - - protected void configure() { - super.configure(); - install(new OkHttpCommandExecutorServiceModule()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerImageInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerImageInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerImageInfo.java deleted file mode 100644 index 315e787..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerImageInfo.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.containers; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; -import org.jclouds.shipyard.domain.images.ImagePortsInfo; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -@AutoValue -public abstract class ContainerImageInfo { - - @Nullable public abstract String name(); - - public abstract Map<String, String> environment(); - - public abstract List<String> entryPoint(); - - @Nullable public abstract String hostName(); - - public abstract List<ImagePortsInfo> bindPorts(); - - public abstract List<String> volumes(); - - public abstract Map<String, String> restartPolicy(); - - public abstract boolean publish(); - - @Nullable public abstract String networkMode(); - - ContainerImageInfo() { - } - - @SerializedNames({ "name", "environment", "entrypoint", "hostname", "bind_ports", "volumes", "restart_policy", "publish", "network_mode" }) - public static ContainerImageInfo create(String name, Map<String, String> environment, List<String> entryPoint, - String hostName, List<ImagePortsInfo> bindPorts, - List<String> volumes, Map<String, String> restartPolicy, - boolean publish, String networkMode) { - - if (environment == null) environment = Maps.newHashMap(); - if (entryPoint == null) entryPoint = Lists.newArrayList(); - if (bindPorts == null) bindPorts = Lists.newArrayList(); - if (volumes == null) volumes = Lists.newArrayList(); - if (restartPolicy == null) restartPolicy = Maps.newHashMap(); - - return new AutoValue_ContainerImageInfo(name, environment, entryPoint, - hostName, bindPorts, - volumes, restartPolicy, - publish, networkMode); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerInfo.java deleted file mode 100644 index 8e6404d..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/ContainerInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.containers; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; -import org.jclouds.shipyard.domain.engines.EngineSettingsInfo; -import org.jclouds.shipyard.domain.images.ImagePortsInfo; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; - -@AutoValue -public abstract class ContainerInfo { - - public abstract String id(); - - @Nullable public abstract String name(); - - public abstract ContainerImageInfo image(); - - public abstract EngineSettingsInfo engine(); - - public abstract String state(); - - public abstract List<ImagePortsInfo> ports(); - - ContainerInfo() { - } - - @SerializedNames({ "id", "name", "image", "engine", "state", "ports" }) - public static ContainerInfo create(String id, String name, - ContainerImageInfo image, - EngineSettingsInfo engine, - String state, List<ImagePortsInfo> ports) { - - if (state == null) state = "unknown"; - if (ports == null) ports = Lists.newArrayList(); - - return new AutoValue_ContainerInfo(id, name, image, engine, state, ports); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/DeployContainer.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/DeployContainer.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/DeployContainer.java deleted file mode 100644 index e1352ae..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/containers/DeployContainer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.containers; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; -import org.jclouds.shipyard.domain.images.ImagePortsInfo; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -@AutoValue -public abstract class DeployContainer { - - public abstract String name(); - - public abstract String containerName(); - - public abstract double cpus(); - - public abstract int memory(); - - public abstract String type(); - - @Nullable public abstract String hostName(); - - @Nullable public abstract String domain(); - - public abstract List<String> labels(); - - public abstract List<String> args(); - - public abstract Map<String, String> environment(); - - public abstract Map<String, String> restartPolicy(); - - public abstract List<ImagePortsInfo> bindPorts(); - - public abstract Map<String, String> links(); - - DeployContainer() { - } - - @SerializedNames({ "name", "container_name", "cpus", "memory", "type", "hostname", "domain", "labels", "args", "environment", "restart_policy", "bind_ports", "links" }) - public static DeployContainer create(String name, String containerName, double cpus, - int memory, String type, String hostName, - String domain, List<String> labels, List<String> args, - Map<String, String> environment, Map<String, String> restartPolicy, - List<ImagePortsInfo> bindPorts, Map<String, String> links) { - - if (labels == null) labels = Lists.newArrayList(); - if (args == null) args = Lists.newArrayList(); - if (environment == null) environment = Maps.newHashMap(); - if (restartPolicy == null) restartPolicy = Maps.newHashMap(); - if (bindPorts == null) bindPorts = Lists.newArrayList(); - if (links == null) links = Maps.newHashMap(); - - return new AutoValue_DeployContainer(name, containerName, cpus, - memory, "service", hostName, - domain, labels, args, - environment, restartPolicy, bindPorts, - links); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/AddEngine.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/AddEngine.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/AddEngine.java deleted file mode 100644 index 683568d..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/AddEngine.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.engines; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class AddEngine { - - public abstract String local(); - - @Nullable abstract String sslCert(); - - @Nullable abstract String sslKey(); - - @Nullable abstract String caCert(); - - public abstract EngineSettingsInfo engine(); - - AddEngine() { - } - - @SerializedNames({ "local", "ssl_cert", "ssl_key", "ca_cert", "engine" }) - public static AddEngine create(String local, String sslCert, - String sslKey, String caCert, EngineSettingsInfo engine) { - return new AutoValue_AddEngine(local, sslCert, sslKey, caCert, engine); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineInfo.java deleted file mode 100644 index f7bbf89..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineInfo.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.engines; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class EngineInfo { - - public abstract String id(); - - public abstract EngineSettingsInfo engine(); - - EngineInfo() { - } - - @SerializedNames({ "id", "engine" }) - public static EngineInfo create(String id, EngineSettingsInfo engine) { - return new AutoValue_EngineInfo(id, engine); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineSettingsInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineSettingsInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineSettingsInfo.java deleted file mode 100644 index 1a5f923..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/engines/EngineSettingsInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.engines; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class EngineSettingsInfo { - - public abstract String id(); - - public abstract String addr(); - - public abstract double cpus(); - - public abstract double memory(); - - public abstract List<String> labels(); - - EngineSettingsInfo() { - } - - @SerializedNames({ "id", "addr", "cpus", "memory", "labels" }) - public static EngineSettingsInfo create(String id, String addr, - double cpus, double memory, - List<String> labels) { - - checkNotNull(labels, "labels must be non-null"); - checkState(labels.size() > 0, "labels must have at least 1 entry"); - - return new AutoValue_EngineSettingsInfo(id, addr, cpus, memory, labels); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImageInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImageInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImageInfo.java deleted file mode 100644 index c18bf30..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImageInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.images; - -import java.util.List; - -import org.jclouds.domain.Location; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; - -@AutoValue -public abstract class ImageInfo { - - public abstract int created(); - - @Nullable public abstract String id(); - - public abstract String parentId(); - - public abstract List<String> repoTags(); - - public abstract int size(); - - public abstract int virtualSize(); - - @Nullable abstract Location location(); - - ImageInfo() { - } - - @SerializedNames({ "Created", "Id", "ParentId", "RepoTags", "Size", "VirtualSize" , "Location"}) - public static ImageInfo create(int created, String id, - String parentId, List<String> repoTags, - int size, int virtualSize, - Location location) { - - if (repoTags == null) repoTags = Lists.newArrayList(); - - return new AutoValue_ImageInfo(created, id, parentId, repoTags, size, virtualSize, location); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImagePortsInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImagePortsInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImagePortsInfo.java deleted file mode 100644 index 1728e2e..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/images/ImagePortsInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.images; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class ImagePortsInfo { - - public abstract String proto(); - - public abstract String hostIp(); - - public abstract int port(); - - public abstract int containerPort(); - - ImagePortsInfo() { - } - - @SerializedNames({ "proto", "host_ip", "port", "container_port" }) - public static ImagePortsInfo create(String proto, String hostIp, int port, int containerPort) { - return new AutoValue_ImagePortsInfo(proto, hostIp, port, containerPort); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/roles/RoleInfo.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/roles/RoleInfo.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/roles/RoleInfo.java deleted file mode 100644 index a56b99c..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/roles/RoleInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.roles; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class RoleInfo { - - public abstract String name(); - - @Nullable public abstract String id(); - - RoleInfo() { - } - - @SerializedNames({ "name", "id" }) - public static RoleInfo create(String name, String id) { - return new AutoValue_RoleInfo(name, id); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/domain/servicekeys/ServiceKey.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/domain/servicekeys/ServiceKey.java b/shipyard/src/main/java/org/jclouds/shipyard/domain/servicekeys/ServiceKey.java deleted file mode 100644 index ce9f754..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/domain/servicekeys/ServiceKey.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.domain.servicekeys; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class ServiceKey { - - public abstract String key(); - - @Nullable public abstract String description(); - - ServiceKey() { - } - - @SerializedNames({ "key", "description" }) - public static ServiceKey create(String key, String description) { - return new AutoValue_ServiceKey(key, description); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/fallbacks/ShipyardFallbacks.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/fallbacks/ShipyardFallbacks.java b/shipyard/src/main/java/org/jclouds/shipyard/fallbacks/ShipyardFallbacks.java deleted file mode 100644 index 4e15a32..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/fallbacks/ShipyardFallbacks.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.fallbacks; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Throwables.propagate; - -import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull; - -import org.jclouds.Fallback; - -public final class ShipyardFallbacks { - - public static final class BooleanOnServiceKeyNotFoundAnd500 implements Fallback<Boolean> { - public Boolean createOrPropagate(Throwable t) throws Exception { - if (checkNotNull(t, "throwable") != null && - t.getMessage().contains("service key does not exist") && - returnValueOnCodeOrNull(t, true, equalTo(500)) != null) { - return Boolean.FALSE; - } - throw propagate(t); - } - } - - public static final class BooleanOnRoleNotFoundAnd500 implements Fallback<Boolean> { - public Boolean createOrPropagate(Throwable t) throws Exception { - if (checkNotNull(t, "throwable") != null && - t.getMessage().contains("role does not exist") && - returnValueOnCodeOrNull(t, true, equalTo(500)) != null) { - return Boolean.FALSE; - } - throw propagate(t); - } - } - - public static final class NullOnRoleNotFoundAnd500 implements Fallback<Object> { - public Object createOrPropagate(Throwable t) throws Exception { - if (checkNotNull(t, "throwable") != null && - t.getMessage().contains("role does not exist") && - returnValueOnCodeOrNull(t, true, equalTo(500)) != null) { - return null; - } - throw propagate(t); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/features/ContainersApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/features/ContainersApi.java b/shipyard/src/main/java/org/jclouds/shipyard/features/ContainersApi.java deleted file mode 100644 index 0ca98fc..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/features/ContainersApi.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToJsonPayload; -import org.jclouds.shipyard.domain.containers.ContainerInfo; -import org.jclouds.shipyard.domain.containers.DeployContainer; -import org.jclouds.shipyard.filters.ServiceKeyAuthentication; - -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ ServiceKeyAuthentication.class }) -@Path("/api/containers") -public interface ContainersApi { - - @Named("containers:list") - @GET - List<ContainerInfo> listContainers(); - - @Named("containers:info") - @GET - @Path("/{id}") - ContainerInfo getContainer(@PathParam("id") String id); - - @Named("containers:delete") - @DELETE - @Path("/{id}") - void deleteContainer(@PathParam("id") String id); - - @Named("containers:stop") - @GET - @Path("/{id}/stop") - void stopContainer(@PathParam("id") String id); - - @Named("containers:restart") - @GET - @Path("/{id}/restart") - void restartContainer(@PathParam("id") String id); - - @Named("containers:deploy") - @POST - List<ContainerInfo> deployContainer(@BinderParam(BindToJsonPayload.class) DeployContainer deployContainer); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/features/EnginesApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/features/EnginesApi.java b/shipyard/src/main/java/org/jclouds/shipyard/features/EnginesApi.java deleted file mode 100644 index bcb027c..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/features/EnginesApi.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToJsonPayload; -import org.jclouds.shipyard.domain.engines.AddEngine; -import org.jclouds.shipyard.domain.engines.EngineInfo; -import org.jclouds.shipyard.filters.ServiceKeyAuthentication; - -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ ServiceKeyAuthentication.class }) -@Path("/api/engines") -public interface EnginesApi { - - @Named("engines:list-info") - @GET - List<EngineInfo> listEngines(); - - @Named("engines:info") - @GET - @Path("/{id}") - EngineInfo getEngine(@PathParam("id") String engineID); - - @Named("engines:add") - @POST - void addEngine(@BinderParam(BindToJsonPayload.class) AddEngine addEngine); - - @Named("engines:remove") - @DELETE - @Path("/{id}") - void removeEngine(@PathParam("id") String engineID); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/features/ImagesApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/features/ImagesApi.java b/shipyard/src/main/java/org/jclouds/shipyard/features/ImagesApi.java deleted file mode 100644 index 80dad17..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/features/ImagesApi.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.net.URI; -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.shipyard.domain.images.ImageInfo; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/images/json") -public interface ImagesApi { - - @Named("images:list") - @GET - List<ImageInfo> listImages(@EndpointParam URI rootURL); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/features/RolesApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/features/RolesApi.java b/shipyard/src/main/java/org/jclouds/shipyard/features/RolesApi.java deleted file mode 100644 index 2528fc7..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/features/RolesApi.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.WrapWith; -import org.jclouds.shipyard.domain.roles.RoleInfo; -import org.jclouds.shipyard.fallbacks.ShipyardFallbacks.BooleanOnRoleNotFoundAnd500; -import org.jclouds.shipyard.fallbacks.ShipyardFallbacks.NullOnRoleNotFoundAnd500; -import org.jclouds.shipyard.filters.ServiceKeyAuthentication; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@RequestFilters({ ServiceKeyAuthentication.class }) -@Path("/api/roles") -public interface RolesApi { - - @Named("roles:list") - @GET - List<RoleInfo> listRoles(); - - @Named("roles:info") - @Fallback(NullOnRoleNotFoundAnd500.class) - @GET - @Path("/{name}") - RoleInfo getRole(@PathParam("name") String name); - - @Named("roles:create") - @POST - void createRole(@WrapWith("name") String name); - - @Named("roles:delete") - @Fallback(BooleanOnRoleNotFoundAnd500.class) - @DELETE - boolean deleteRole(@WrapWith("name") String name); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/features/ServiceKeysApi.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/features/ServiceKeysApi.java b/shipyard/src/main/java/org/jclouds/shipyard/features/ServiceKeysApi.java deleted file mode 100644 index 9cd8aaa..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/features/ServiceKeysApi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.WrapWith; -import org.jclouds.shipyard.domain.servicekeys.ServiceKey; -import org.jclouds.shipyard.fallbacks.ShipyardFallbacks.BooleanOnServiceKeyNotFoundAnd500; -import org.jclouds.shipyard.filters.ServiceKeyAuthentication; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@RequestFilters({ ServiceKeyAuthentication.class }) -@Path("/api/servicekeys") -public interface ServiceKeysApi { - - @Named("servicekeys:list") - @GET - List<ServiceKey> listServiceKeys(); - - @Named("servicekeys:create") - @POST - ServiceKey createServiceKey(@WrapWith("description") String description); - - @Named("servicekeys:delete") - @Fallback(BooleanOnServiceKeyNotFoundAnd500.class) - @DELETE - Boolean deleteServiceKey(@WrapWith("key") String key); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/filters/ServiceKeyAuthentication.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/filters/ServiceKeyAuthentication.java b/shipyard/src/main/java/org/jclouds/shipyard/filters/ServiceKeyAuthentication.java deleted file mode 100644 index 9750bb1..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/filters/ServiceKeyAuthentication.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.filters; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.location.Provider; -import org.jclouds.rest.AuthorizationException; - -import com.google.common.base.Supplier; - -/** - * Shipyard remote API authentication is made via the HTTP header 'X-Service-Key' which in turns - * has it's value as an encoded string (Shipyard-cli generates this for you). - * - */ -@Singleton -public class ServiceKeyAuthentication implements HttpRequestFilter { - private final Supplier<Credentials> creds; - - @Inject - ServiceKeyAuthentication(@Provider Supplier<Credentials> creds) { - this.creds = creds; - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - if (currentCreds.identity == null) { - throw new AuthorizationException("Credentials identity can not be null"); - } - return request.toBuilder().addHeader("X-Service-Key", currentCreds.identity).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/main/java/org/jclouds/shipyard/handlers/ShipyardErrorHandler.java ---------------------------------------------------------------------- diff --git a/shipyard/src/main/java/org/jclouds/shipyard/handlers/ShipyardErrorHandler.java b/shipyard/src/main/java/org/jclouds/shipyard/handlers/ShipyardErrorHandler.java deleted file mode 100644 index 374ce7e..0000000 --- a/shipyard/src/main/java/org/jclouds/shipyard/handlers/ShipyardErrorHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.handlers; - -import static org.jclouds.util.Closeables2.closeQuietly; - -import java.io.IOException; - -import javax.annotation.Resource; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; - -/** - * Handle errors and propagate exception - * - */ -public class ShipyardErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - - String message = parseMessage(response); - Exception exception = null; - try { - - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); - switch (response.getStatusCode()) { - case 401: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (command.getCurrentRequest().getMethod().equals("GET")) { - if (command.getCurrentRequest().getEndpoint().getPath().endsWith("/images/json")) - exception = new HttpResponseException("Unable to reach docker daemon", command, response); - } - break; - case 409: - if (command.getCurrentRequest().getMethod().equals("POST")) { - if (command.getCurrentRequest().getEndpoint().getPath().endsWith("/containers")) - exception = new HttpResponseException("Container already exists", command, response); - } - break; - case 500: - if (command.getCurrentRequest().getMethod().equals("GET")) { - if (command.getCurrentRequest().getEndpoint().getPath().startsWith("/api/roles") && - message.contains("role does not exist")) { - exception = new ResourceNotFoundException(message, new HttpResponseException(command, response, message)); - } - } else if (command.getCurrentRequest().getMethod().equals("POST")) { - if (command.getCurrentRequest().getEndpoint().getPath().endsWith("/engines")) - exception = new HttpResponseException("Connection refused registering docker daemon", command, response); - } else if (command.getCurrentRequest().getMethod().equals("DELETE")) { - if (command.getCurrentRequest().getEndpoint().getPath().endsWith("/servicekeys") && - message.contains("service key does not exist")) { - exception = new ResourceNotFoundException(message, new HttpResponseException(command, response, message)); - } else if (command.getCurrentRequest().getEndpoint().getPath().endsWith("/roles") && - message.contains("role does not exist")) { - exception = new ResourceNotFoundException(message, new HttpResponseException(command, response, message)); - } - } - break; - default: - exception = new HttpResponseException(message, command, response); - break; - } - } catch (Exception e) { - exception = new HttpResponseException(command, response, e); - } finally { - if (exception == null) { - exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - } - closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - private String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toStringAndClose(response.getPayload().openStream()); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/test/java/org/jclouds/shipyard/ShipyardApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/shipyard/src/test/java/org/jclouds/shipyard/ShipyardApiMetadataTest.java b/shipyard/src/test/java/org/jclouds/shipyard/ShipyardApiMetadataTest.java deleted file mode 100644 index b6db473..0000000 --- a/shipyard/src/test/java/org/jclouds/shipyard/ShipyardApiMetadataTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.HashSet; -import org.jclouds.View; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.Apis; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Unit tests for the {@link ShipyardApiMetadata} class. - */ -@Test(groups = "unit", testName = "ShipyardApiMetadataTest") -public class ShipyardApiMetadataTest extends BaseApiMetadataTest { - - public ShipyardApiMetadataTest() { - super(new ShipyardApiMetadata(), new HashSet<TypeToken<? extends View>>()); - } - - public void testShipyardApiRegistered() { - ApiMetadata api = Apis.withId("shipyard"); - - assertNotNull(api); - assertTrue(api instanceof ShipyardApiMetadata); - assertEquals(api.getId(), "shipyard"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiLiveTest.java ---------------------------------------------------------------------- diff --git a/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiLiveTest.java b/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiLiveTest.java deleted file mode 100644 index 4361854..0000000 --- a/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiLiveTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.http.HttpResponseException; -import org.jclouds.shipyard.domain.containers.ContainerInfo; -import org.jclouds.shipyard.domain.containers.DeployContainer; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; - - -@Test(groups = "live", testName = "ContainersApiLiveTest", singleThreaded = true) -public class ContainersApiLiveTest extends EnginesApiLiveTest { - - private String containerName = "shipyard-jclouds-container-test"; - private String containerID = null; - - @BeforeClass - protected void init() throws Exception { - super.init(); - super.testGetAllEngines(); - } - - @AfterClass (alwaysRun = true) - protected void tearDown() { - super.tearDown(); - } - - public void testDeployContainer() throws Exception { - - DeployContainer deployContainer = DeployContainer.create("ubuntu:14.04.1", - containerName, - 1, - 512, - null, - null, - null, - Lists.newArrayList(EnginesApiLiveTest.engineName), - Lists.newArrayList("/bin/bash"), - ImmutableMap.of("shipyard-jclouds", "test"), - null, - null, - null); - - List<ContainerInfo> container = api().deployContainer(deployContainer); - assertNotNull(container, "Expected valid container but returned NULL"); - assertTrue(container.size() == 1, "Expected exactly 1 container removed and found " + container.size()); - assertTrue(container.get(0).name().endsWith(containerName), - "Expected name does not match actual name: requested=" + containerName + ", actual=" + container.get(0).name()); - assertTrue(container.get(0).engine().labels().contains(EnginesApiLiveTest.engineName), - "Expected label was not found in container: expected=" + EnginesApiLiveTest.engineName + ", found=" + container.get(0).engine().labels()); - containerID = container.get(0).id(); - } - - @Test (dependsOnMethods = "testDeployContainer", expectedExceptions = HttpResponseException.class) - public void testDeployAlreadyExistentContainer() throws Exception { - - DeployContainer deployContainer = DeployContainer.create("ubuntu:14.04.1", - containerName, - 1, - 512, - null, - null, - null, - Lists.newArrayList(EnginesApiLiveTest.engineName), - Lists.newArrayList("/bin/bash"), - ImmutableMap.of("shipyard-jclouds", "test"), - null, - null, - null); - - List<ContainerInfo> container = api().deployContainer(deployContainer); - assertNull(container); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testDeployNonExistentContainer() throws Exception { - - DeployContainer deployContainer = DeployContainer.create("jclouds-shipyard-test:99.99.99", - containerName, - 1, - 512, - null, - null, - null, - Lists.newArrayList(EnginesApiLiveTest.engineName), - Lists.newArrayList("/bin/bash"), - ImmutableMap.of("shipyard-jclouds", "test"), - null, - null, - null); - - List<ContainerInfo> container = api().deployContainer(deployContainer); - assertNull(container); - } - - @Test (dependsOnMethods = "testDeployAlreadyExistentContainer") - public void testStopContainer() throws Exception { - api().stopContainer(containerID); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testStopNonExistentContainer() throws Exception { - api().stopContainer("aaabbbccc111222333"); - } - - @Test (dependsOnMethods = "testStopContainer") - public void testRestartContainer() throws Exception { - api().restartContainer(containerID); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testRestartNonExistentContainer() throws Exception { - api().restartContainer("aaabbbccc111222333"); - } - - @Test (dependsOnMethods = "testRestartContainer") - public void testDeleteContainer() throws Exception { - api().deleteContainer(containerID); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testDeleteNonExistentContainer() throws Exception { - api().deleteContainer("aaabbbccc111222333"); - } - - private ContainersApi api() { - return api.containersApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiMockTest.java ---------------------------------------------------------------------- diff --git a/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiMockTest.java b/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiMockTest.java deleted file mode 100644 index 20de82f..0000000 --- a/shipyard/src/test/java/org/jclouds/shipyard/features/ContainersApiMockTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import java.util.List; - -import org.jclouds.shipyard.ShipyardApi; -import org.jclouds.shipyard.domain.containers.ContainerInfo; -import org.jclouds.shipyard.domain.containers.DeployContainer; -import org.jclouds.shipyard.internal.BaseShipyardMockTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Mock tests for the {@link org.jclouds.shipyard.features.ContainersApi} class. - */ -@Test(groups = "unit", testName = "ContainersApiMockTest") -public class ContainersApiMockTest extends BaseShipyardMockTest { - - - public void testListContainers() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - try { - assertEquals(api.listContainers().size(), 1); - assertSent(server, "GET", "/api/containers"); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } - - public void testGetContainer() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/container.json"))); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - String containerId = "e2f6784b75ed8768e83b7ec46ca8ef784941f6ce4c53231023804277965da1d2"; - try { - assertEquals(api.getContainer(containerId).id(), containerId); - assertSent(server, "GET", "/api/containers/" + containerId); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } - - public void testDeployContainer() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setResponseCode(201).setBody(payloadFromResource("/container-deploy-response.json"))); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - - DeployContainer deployContainer = DeployContainer.create("nkatsaros/atlassian-stash:3.5", - "atlassian-stash", - 8, - 8096, - null, - null, - null, - Lists.newArrayList("localhost"), - null, - ImmutableMap.of("STASH_HOME", "/var/atlassian/stash", "STASH_VERSION", "3.5.0"), - null, - null, - null); - try { - List<ContainerInfo> container = api.deployContainer(deployContainer); - assertNotNull(container); - assertEquals(container.get(0).id(), "e2f6784b75ed8768e83b7ec46ca8ef784941f6ce4c53231023804277965da1d2"); - assertSent(server, "POST", "/api/containers", new String(payloadFromResource("/container-deploy.json"))); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } - - public void testDeleteContainer() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - String containerId = "e2f6784b75ed8768e83b7ec46ca8ef784941f6ce4c53231023804277965da1d2"; - try { - api.deleteContainer(containerId); - assertSent(server, "DELETE", "/api/containers/" + containerId); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } - - public void testStopContainer() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - String containerId = "e2f6784b75ed8768e83b7ec46ca8ef784941f6ce4c53231023804277965da1d2"; - try { - api.stopContainer(containerId); - assertSent(server, "GET", "/api/containers/" + containerId + "/stop"); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } - - public void testStartOrRestartContainer() throws Exception { - MockWebServer server = mockShipyardWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); - ShipyardApi shipyardApi = api(server.getUrl("/")); - ContainersApi api = shipyardApi.containersApi(); - String containerId = "e2f6784b75ed8768e83b7ec46ca8ef784941f6ce4c53231023804277965da1d2"; - try { - api.restartContainer(containerId); - assertSent(server, "GET", "/api/containers/" + containerId + "/restart"); - } finally { - shipyardApi.close(); - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9c19ee0c/shipyard/src/test/java/org/jclouds/shipyard/features/EnginesApiLiveTest.java ---------------------------------------------------------------------- diff --git a/shipyard/src/test/java/org/jclouds/shipyard/features/EnginesApiLiveTest.java b/shipyard/src/test/java/org/jclouds/shipyard/features/EnginesApiLiveTest.java deleted file mode 100644 index 8a45468..0000000 --- a/shipyard/src/test/java/org/jclouds/shipyard/features/EnginesApiLiveTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.shipyard.features; - -import java.util.List; - -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.http.HttpResponseException; -import org.jclouds.shipyard.domain.engines.AddEngine; -import org.jclouds.shipyard.domain.engines.EngineInfo; -import org.jclouds.shipyard.domain.engines.EngineSettingsInfo; -import org.jclouds.shipyard.internal.BaseShipyardApiLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.Lists; - -@Test(groups = "live", testName = "EnginesApiLiveTest", singleThreaded = true) -public class EnginesApiLiveTest extends BaseShipyardApiLiveTest { - - protected static final String engineName = "jclouds-shipard-live-test"; - protected String engineID = null; - - @BeforeClass - protected void init() throws Exception { - String dockerEndpoint = System.getProperty("test.shipyard.docker.endpoint"); - EngineSettingsInfo info = EngineSettingsInfo.create(engineName, dockerEndpoint, 1, 1024, Lists.newArrayList(engineName)); - AddEngine additionalEngine = AddEngine.create("local", "", "", "", info); - api().addEngine(additionalEngine); - } - - @AfterClass (alwaysRun = true) - protected void tearDown() { - assertNotNull(engineID, "Expected engineID to be set but was not"); - api().removeEngine(engineID); - } - - public void testGetAllEngines() throws Exception { - List<EngineInfo> engines = api().listEngines(); - assertTrue(engines.size() >= 1, "Shipyard did not contain at least 1 Engine which was expected"); - boolean engineFound = false; - for (EngineInfo engine : api().listEngines()) { - if (engine.engine().id().equals(engineName)) { - engineID = engine.id(); - engineFound = true; - } - } - assertTrue(engineFound, "Expected but could not find Engine amongst " + engines.size() + " found"); - } - - @Test (dependsOnMethods = "testGetAllEngines") - public void testGetEngine() throws Exception { - assertNotNull(engineID, "Expected engineID to be set but was not"); - EngineInfo engine = api().getEngine(engineID); - assertTrue(engine.engine().id().equals(engineName), "Expected Engine name " + engineName + " but found " + engine.engine().id()); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testAddNonExistentEngine() throws Exception { - EngineSettingsInfo info = EngineSettingsInfo.create("local", "http://www.test-jclouds-shipyard:9999", 1, 1024, Lists.newArrayList("default")); - AddEngine additionalEngine = AddEngine.create("local", "", "", "", info); - api().addEngine(additionalEngine); - } - - @Test (expectedExceptions = HttpResponseException.class) - public void testRemoveNonExistentEngine() throws Exception { - api().removeEngine("1234567890-shipyard-jclouds"); - } - - private EnginesApi api() { - return api.enginesApi(); - } -}
