http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java deleted file mode 100644 index 3394cde..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * work for additional information regarding copyright ownership. - * The ASF licenses file to You under the Apache License, Version 2.0 - * (the "License"); you may not use 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.docker.compute.functions; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; -import java.util.List; -import java.util.Map; - -import org.easymock.EasyMock; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.docker.domain.Config; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.HostConfig; -import org.jclouds.docker.domain.NetworkSettings; -import org.jclouds.docker.domain.Port; -import org.jclouds.docker.domain.State; -import org.jclouds.providers.ProviderMetadata; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; - -/** - * Unit tests for the {@link org.jclouds.docker.compute.functions.ContainerToNodeMetadata} class. - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "ContainerToNodeMetadataTest") -public class ContainerToNodeMetadataTest { - private ContainerToNodeMetadata function; - - private Container container; - - @BeforeMethod - public void setup() { - Config config = Config.builder() - .hostname("6d35806c1bd2") - .domainName("") - .user("") - .memory(0) - .memorySwap(0) - .cpuShares(0) - .attachStdin(false) - .attachStdout(false) - .attachStderr(false) - .exposedPorts(ImmutableMap.of("22/tcp", ImmutableMap.of())) - .tty(false) - .openStdin(false) - .stdinOnce(false) - .env(null) - .cmd(ImmutableList.of("/usr/sbin/sshd", "-D")) - .imageId("jclouds/ubuntu") - .volumesFrom("") - .workingDir("") - .entrypoint(null) - .networkDisabled(false) - .onBuild(null) - .build(); - State state = State.builder() - .pid(3626) - .running(true) - .exitCode(0) - .startedAt("2014-03-24T20:28:37.537659054Z") - .finishedAt("0001-01-01T00:00:00Z") - .ghost(false) - .build(); - container = Container.builder() - .id("6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9") - .name("/hopeful_mclean") - .created("2014-03-22T07:16:45.784120972Z") - .path("/usr/sbin/sshd") - .args(new String[] {"-D"}) - .config(config) - .state(state) - .image("af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6") - .networkSettings(NetworkSettings.builder() - .ipAddress("172.17.0.2") - .ipPrefixLen(16) - .gateway("172.17.42.1") - .bridge("docker0") - .ports(ImmutableMap.<String, List<Map<String, String>>>of("22/tcp", - ImmutableList.<Map<String, String>>of(ImmutableMap.of("HostIp", "0.0.0.0", "HostPort", - "49199")))) - .build()) - .resolvConfPath("/etc/resolv.conf") - .driver("aufs") - .execDriver("native-0.1") - .volumes(ImmutableMap.<String, String>of()) - .volumesRw(ImmutableMap.<String, Boolean>of()) - .command("") - .status("") - .hostConfig(HostConfig.builder().publishAllPorts(true).build()) - .ports(ImmutableList.<Port>of()) - .build(); - ProviderMetadata providerMetadata = EasyMock.createMock(ProviderMetadata.class); - expect(providerMetadata.getEndpoint()).andReturn("http://127.0.0.1:4243"); - replay(providerMetadata); - - GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class); - - function = new ContainerToNodeMetadata(providerMetadata, toPortableStatus(), namingConvention); - } - - private Function<State, NodeMetadata.Status> toPortableStatus() { - StateToStatus function = EasyMock.createMock(StateToStatus.class); - expect(function.apply(anyObject(State.class))).andReturn(NodeMetadata.Status.RUNNING); - replay(function); - return function; - } - - public void testVirtualMachineToNodeMetadata() { - Container mockContainer = mockContainer(); - - NodeMetadata node = function.apply(mockContainer); - - verify(mockContainer); - - assertEquals(node.getId(), "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9"); - assertEquals(node.getGroup(), "hopeful_mclean"); - assertEquals(node.getImageId(), "af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6"); - assertEquals(node.getLoginPort(), 49199); - assertEquals(node.getPrivateAddresses().size(), 1); - assertEquals(node.getPublicAddresses().size(), 1); - } - - @SuppressWarnings("unchecked") - private Container mockContainer() { - Container mockContainer = EasyMock.createMock(Container.class); - - expect(mockContainer.getId()).andReturn(container.getId()); - expect(mockContainer.getName()).andReturn(container.getName()); - expect(mockContainer.getConfig()).andReturn(container.getConfig()).anyTimes(); - expect(mockContainer.getNetworkSettings()).andReturn(container.getNetworkSettings()).anyTimes(); - expect(mockContainer.getState()).andReturn(container.getState()); - expect(mockContainer.getImage()).andReturn(container.getImage()); - replay(mockContainer); - - return mockContainer; - } -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java deleted file mode 100644 index c46bdb1..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * work for additional information regarding copyright ownership. - * The ASF licenses file to You under the Apache License, Version 2.0 - * (the "License"); you may not use 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.docker.compute.functions; - -import com.google.common.collect.ImmutableList; -import org.easymock.EasyMock; -import org.jclouds.compute.domain.Image; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -/** - * Unit tests for the {@link org.jclouds.docker.compute.functions.ImageToImage} class. - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "ImageToImageTest") -public class ImageToImageTest { - private ImageToImage function; - - private org.jclouds.docker.domain.Image image; - - @BeforeMethod - public void setup() { - image = org.jclouds.docker.domain.Image.builder() - .id("id") - .parent("parent") - .created("created") - .architecture("x86_64") - .repoTags(ImmutableList.of("repoTag1:version")) - .size(0l) - .build(); - function = new ImageToImage(); - } - - public void testImageToImage() { - org.jclouds.docker.domain.Image mockImage = mockImage(); - - Image image = function.apply(mockImage); - - verify(mockImage); - - assertEquals(mockImage.getId(), image.getId().toString()); - } - - @SuppressWarnings("unchecked") - private org.jclouds.docker.domain.Image mockImage() { - org.jclouds.docker.domain.Image mockImage = EasyMock.createMock(org.jclouds.docker.domain.Image.class); - - expect(mockImage.getId()).andReturn(image.getId()).anyTimes(); - expect(mockImage.getRepoTags()).andReturn(image.getRepoTags()).anyTimes(); - expect(mockImage.getArchitecture()).andReturn(image.getArchitecture()).anyTimes(); - replay(mockImage); - - return mockImage; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java deleted file mode 100644 index c1a8002..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * work for additional information regarding copyright ownership. - * The ASF licenses file to You under the Apache License, Version 2.0 - * (the "License"); you may not use 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.docker.compute.functions; - -import org.easymock.EasyMock; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.docker.domain.State; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -/** - * Unit tests for the {@link StateToStatus} class. - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "StateToStatusTest") -public class StateToStatusTest { - private StateToStatus function; - - @BeforeMethod - public void setup() { - function = new StateToStatus(); - } - - public void testStateRunningToStatusRunning() { - State mockState = mockStateRunning(); - - NodeMetadata.Status status = function.apply(mockState); - - verify(mockState); - - assertEquals(mockState.isRunning(), true); - assertEquals(status, NodeMetadata.Status.RUNNING); - } - - public void testStateNotRunningToStatusSuspended() { - State mockState = mockStateNotRunning(); - - NodeMetadata.Status status = function.apply(mockState); - - verify(mockState); - - assertEquals(mockState.isRunning(), false); - assertEquals(status, NodeMetadata.Status.SUSPENDED); - } - - private State mockStateRunning() { - State mockState = EasyMock.createMock(State.class); - - expect(mockState.isRunning()).andReturn(true).anyTimes(); - replay(mockState); - - return mockState; - } - - private State mockStateNotRunning() { - State mockState = EasyMock.createMock(State.class); - - expect(mockState.isRunning()).andReturn(false).anyTimes(); - replay(mockState); - - return mockState; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java deleted file mode 100644 index 23d387d..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java +++ /dev/null @@ -1,102 +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.docker.config; - -import static org.jclouds.docker.config.DockerParserModule.ContainerTypeAdapter; -import static org.jclouds.docker.config.DockerParserModule.ImageTypeAdapter; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.Image; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -/** - * Unit tests for the {@link org.jclouds.docker.config.DockerParserModule} class. - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "DockerParserModuleTest") -public class DockerParserModuleTest { - - private Gson gson; - - @BeforeMethod - public void setup() { - gson = new GsonBuilder() - .registerTypeAdapter(Container.class, new ContainerTypeAdapter()) - .registerTypeAdapter(Image.class, new ImageTypeAdapter()) - .create(); - } - - @Test - public void testContainerID() { - Container container = gson.fromJson( - "{ \"ID\": \"1111111111111111111111111111111111111111111111111111111111111111\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getId(), "1111111111111111111111111111111111111111111111111111111111111111"); - } - - - @Test - public void testContainerId() { - Container container = gson.fromJson( - "{ \"Id\": \"2222222222222222222222222222222222222222222222222222222222222222\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getId(), "2222222222222222222222222222222222222222222222222222222222222222"); - } - - @Test - public void testContainerName() { - Container container = gson.fromJson( - "{ \"Name\": \"example\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getName(), "example"); - } - - - @Test - public void testContainerNames() { - Container container = gson.fromJson("{ \"Names\": [\"/jclouds-b45\"] }", Container.class); - assertNotNull(container); - assertEquals(container.getName(), "/jclouds-b45"); - } - - @Test - public void testImageid() { - Image image = gson.fromJson( - "{ \"id\": \"3333333333333333333333333333333333333333333333333333333333333333\" }", Image.class); - assertNotNull(image); - assertEquals(image.getId(), "3333333333333333333333333333333333333333333333333333333333333333"); - } - - - @Test - public void testImageId() { - Image image = gson.fromJson( - "{ \"Id\": \"4444444444444444444444444444444444444444444444444444444444444444\" }", Image.class); - assertNotNull(image); - assertEquals(image.getId(), "4444444444444444444444444444444444444444444444444444444444444444"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java deleted file mode 100644 index c0fe074..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java +++ /dev/null @@ -1,119 +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.docker.internal; - -import com.google.common.base.Charsets; -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.inject.Module; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import com.squareup.okhttp.mockwebserver.RecordedRequest; -import org.jclouds.ContextBuilder; -import org.jclouds.concurrent.config.ExecutorServiceModule; -import org.jclouds.docker.DockerApi; - -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.net.URL; -import java.util.Properties; -import java.util.Set; - -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; -import static org.jclouds.http.utils.Queries.encodeQueryLine; -import static org.jclouds.util.Strings2.toStringAndClose; -import static org.testng.Assert.assertEquals; - -/** - * Base class for all Docker mock tests. - * - * @author Andrea Turli - */ -public class BaseDockerMockTest { - private final Set<Module> modules = ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), - sameThreadExecutor())); - - protected String provider; - - public BaseDockerMockTest() { - provider = "docker"; - } - - public DockerApi api(URL url) { - return ContextBuilder.newBuilder(provider) - .credentials("clientid", "apikey") - .endpoint(url.toString()) - .modules(modules) - .overrides(setupProperties()) - .buildApi(DockerApi.class); - } - - protected Properties setupProperties() { - return new Properties(); - } - - public static MockWebServer mockWebServer() throws IOException { - MockWebServer server = new MockWebServer(); - server.play(); - return server; - } - - public byte[] payloadFromResource(String resource) { - try { - return toStringAndClose(getClass().getResourceAsStream(resource)).getBytes(Charsets.UTF_8); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - protected static void assertRequestHasCommonFields(final RecordedRequest request, final String path) - throws InterruptedException { - assertRequestHasParameters(request, "GET", path, ImmutableMultimap.<String, String> of()); - } - - protected static void assertRequestHasCommonFields(final RecordedRequest request, - final String verb, final String path) - throws InterruptedException { - assertRequestHasParameters(request, verb, path, ImmutableMultimap.<String, String> of()); - } - - protected static void assertRequestHasParameters(final RecordedRequest request, final String path, - Multimap<String, String> parameters) throws InterruptedException { - assertRequestHasParameters(request, "GET", path, parameters); - } - - protected static void assertRequestHasParameters(final RecordedRequest request, String verb, final String path, - Multimap<String, String> parameters) throws InterruptedException { - String queryParameters = ""; - if (!parameters.isEmpty()) { - Multimap<String, String> allparams = ImmutableMultimap.<String, String>builder() - .putAll(parameters) - .build(); - - assertRequestHasAcceptHeader(request); - queryParameters = "?" + encodeQueryLine(allparams); - } - assertEquals(request.getRequestLine(), verb + " " + path + queryParameters + " HTTP/1.1"); - } - - protected static void assertRequestHasAcceptHeader(final RecordedRequest request) throws InterruptedException { - assertEquals(request.getHeader(HttpHeaders.ACCEPT), MediaType.APPLICATION_JSON); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile deleted file mode 100644 index 1318715..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile +++ /dev/null @@ -1,29 +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. -# - -FROM centos:6.4 -MAINTAINER Andrea Turli <[email protected]> - -# RUN yum -y groupinstall 'Development Tools' -RUN yum -y install openssh-server openssh-clients - -RUN chkconfig sshd on -RUN service sshd start -RUN echo 'root:password' | chpasswd - -EXPOSE 22 -CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json deleted file mode 100644 index 3e34e0b..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json +++ /dev/null @@ -1 +0,0 @@ -{"Id":"c6c74153ae4b1d1633d68890a68d89c40aa5e284a1ea016cbc6ef0e634ee37b2","Warnings":null} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json deleted file mode 100644 index acb4a21..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "ID": "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9", - "Created": "2014-03-22T07:16:45.784120972Z", - "Path": "/usr/sbin/sshd", - "Args": [ - "-D" - ], - "Config": { - "Hostname": "6d35806c1bd2", - "Domainname": "", - "User": "", - "Memory": 0, - "MemorySwap": 0, - "CpuShares": 0, - "AttachStdin": false, - "AttachStdout": false, - "AttachStderr": false, - "PortSpecs": null, - "ExposedPorts": { - "22/tcp": {} - }, - "Tty": false, - "OpenStdin": false, - "StdinOnce": false, - "Env": null, - "Cmd": [ - "/usr/sbin/sshd", - "-D" - ], - "Dns": null, - "Image": "jclouds/ubuntu", - "Volumes": null, - "VolumesFrom": "", - "WorkingDir": "", - "Entrypoint": null, - "NetworkDisabled": false, - "OnBuild": null - }, - "State": { - "Running": true, - "Pid": 7051, - "ExitCode": 0, - "StartedAt": "2014-03-22T07:16:45.845347434Z", - "FinishedAt": "0001-01-01T00:00:00Z", - "Ghost": false - }, - "Image": "af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6", - "NetworkSettings": { - "IPAddress": "172.17.0.2", - "IPPrefixLen": 16, - "Gateway": "172.17.42.1", - "Bridge": "docker0", - "PortMapping": null, - "Ports": { - "22/tcp": [ - { - "HostIp": "0.0.0.0", - "HostPort": "49231" - } - ] - } - }, - "ResolvConfPath": "/etc/resolv.conf", - "HostnamePath": "/mnt/sda1/var/lib/docker/containers/6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9/hostname", - "HostsPath": "/mnt/sda1/var/lib/docker/containers/6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9/hosts", - "Name": "/hopeful_mclean", - "Driver": "aufs", - "ExecDriver": "native-0.1", - "Volumes": {}, - "VolumesRW": {}, - "HostConfig": { - "Binds": null, - "ContainerIDFile": "", - "LxcConf": [], - "Privileged": false, - "PortBindings": { - "22/tcp": [ - { - "HostIp": "0.0.0.0", - "HostPort": "49231" - } - ] - }, - "Links": null, - "PublishAllPorts": false - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json deleted file mode 100644 index 8f789b7..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "Command": "/usr/sbin/sshd -D", - "Created": 1395472605, - "Id": "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9", - "Image": "jclouds/ubuntu:latest", - "Names": [ - "/hopeful_mclean" - ], - "Ports": [ - { - "IP": "0.0.0.0", - "PrivatePort": 22, - "PublicPort": 49231, - "Type": "tcp" - } - ], - "Status": "Up 55 seconds" - } -] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml deleted file mode 100644 index 94f5938..0000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.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. - ---> -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>- %msg%n</pattern> - </encoder> - </appender> - <root level="info"> - <appender-ref ref="STDOUT"/> - </root> - <logger name="jclouds.compute" level="debug"/> - <logger name="net.schmizz" level="warn"/> - <logger name="jclouds.wire" level="debug"/> - <logger name="jclouds.headers" level="debug"/> - <logger name="jclouds.ssh" level="debug"/> -</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/README.md ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/README.md b/dependencies/jclouds/apis/docker/1.8.0-stratos/README.md new file mode 100644 index 0000000..3ce8cf0 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/README.md @@ -0,0 +1,52 @@ +# Docker as a local cloud provider +jclouds-docker is a local cloud provider modelled on [docker](http://www.docker.io). Similar to other jclouds supported +providers, it supports the same portable abstractions offered by jclouds. + +##Setup + +Please follow these steps to configure your workstation for jclouds-docker: + +- install the latest Docker release (please visit http://www.docker.io/gettingstarted/) + +If you are on OS X, please consider [boot2docker](http://docs.docker.io/en/latest/installation/mac/) as simplified +way to install docker locally. + +#How it works + + + --------------- ------------- + | Image(s) | | Node(s) | + --------------- ------------- + --------- docker remote api ---------------------------------------- + | jclouds | ---------------------------> | DOCKER_HOST | + --------- ---------------------------------------- + +##Components + +- jclouds \- acts as a java client to access to docker features +- DOCKER_HOST \- hosts Docker API, NB: jclouds-docker assumes that the latest Docker is installed +- Image \- it is a docker image that can be started. +- Node \- is a docker container + +## Assumptions + +- jclouds-docker assumes that the images specified using the template are ssh'able. +- jclouds-docker will mount ${user.home} to /root of the container + +-------------- + +#Notes: +- jclouds-docker is still at alpha stage please report any issues you find at [jclouds issues](https://github.com/jclouds/jclouds/issues?state=open) +- jclouds-docker has been tested on Mac OSX, it might work on Linux iff vbox is running and set up correctly. However, it will not currently run on Windows. + +-------------- + +#Troubleshooting +As jclouds docker support is quite new, issues may occasionally arise. Please follow these steps to get things going again: + +1. Remove all containers + + `$ docker ps -a -q | xargs docker stop | xargs docker rm` +2. remove all the images + + `$ docker images -q | xargs docker rmi` http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml b/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml new file mode 100644 index 0000000..d2a3cca --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml @@ -0,0 +1,145 @@ +<?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>1.8.0</version> + </parent> + + <!-- TODO: when out of labs, switch to org.jclouds.provider --> + <groupId>org.apache.stratos</groupId> + <artifactId>docker</artifactId> + <name>jclouds docker API</name> + <version>1.8.0-stratos</version> + <description>ComputeService binding to the Docker API</description> + <packaging>bundle</packaging> + + <properties> + <jclouds.version>1.8.0</jclouds.version> + <test.docker.endpoint>https://localhost:4243</test.docker.endpoint> + <test.docker.api-version>1.10</test.docker.api-version> + <test.docker.identity>FIXME</test.docker.identity> + <test.docker.credential>FIXME</test.docker.credential> + <jclouds.osgi.export>org.jclouds.docker*;version="${project.version}"</jclouds.osgi.export> + <jclouds.osgi.import> + org.jclouds.compute.internal;version="${jclouds.version}", + org.jclouds.rest.internal;version="${jclouds.version}", + org.jclouds*;version="${jclouds.version}", + * + </jclouds.osgi.import> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.jclouds</groupId> + <artifactId>jclouds-core</artifactId> + <version>${jclouds.version}</version> + </dependency> + <dependency> + <groupId>org.apache.jclouds</groupId> + <artifactId>jclouds-compute</artifactId> + <version>${jclouds.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + <version>1.5</version> + </dependency> + + <dependency> + <groupId>org.apache.jclouds.driver</groupId> + <artifactId>jclouds-sshj</artifactId> + <version>${jclouds.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.jclouds</groupId> + <artifactId>jclouds-core</artifactId> + <version>${jclouds.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.jclouds</groupId> + <artifactId>jclouds-compute</artifactId> + <version>${jclouds.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.jclouds.driver</groupId> + <artifactId>jclouds-slf4j</artifactId> + <version>${jclouds.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <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> + <systemPropertyVariables> + <test.docker.endpoint>${test.docker.endpoint}</test.docker.endpoint> + <test.docker.api-version>${test.docker.api-version}</test.docker.api-version> + <test.docker.credential>${test.docker.identity}</test.docker.credential> + <test.docker.credential>${test.docker.credential}</test.docker.credential> + </systemPropertyVariables> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java new file mode 100644 index 0000000..54bf5c9 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java @@ -0,0 +1,37 @@ +/* + * 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.docker; + +import org.jclouds.docker.features.RemoteApi; +import org.jclouds.rest.annotations.Delegate; + +import java.io.Closeable; + +/** + * Provides synchronous access to Docker Remote API. + * + * @see <a href="https://docs.docker.com/reference/api/docker_remote_api/"></a> + */ +public interface DockerApi extends Closeable { + + /** + * Provides synchronous access to Docker Remote API features. + */ + @Delegate + RemoteApi getRemoteApi(); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java new file mode 100644 index 0000000..b281eb7 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; +import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.config.ComputeServiceProperties; +import org.jclouds.docker.compute.config.DockerComputeServiceContextModule; +import org.jclouds.docker.config.DockerHttpApiModule; +import org.jclouds.docker.config.DockerParserModule; +import org.jclouds.rest.internal.BaseHttpApiMetadata; + +import java.net.URI; +import java.util.Properties; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; +import static org.jclouds.reflect.Reflection2.typeToken; + +/** + * Implementation of {@link BaseHttpApiMetadata} for the Docker API + */ +public class DockerApiMetadata extends BaseHttpApiMetadata<DockerApi> { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public DockerApiMetadata() { + this(new Builder()); + } + + protected DockerApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = BaseHttpApiMetadata.defaultProperties(); + properties.setProperty(Constants.PROPERTY_MAX_RETRIES, "15"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + properties.setProperty(Constants.PROPERTY_CONNECTION_TIMEOUT, "1200000"); // 15 minutes + properties.setProperty(ComputeServiceProperties.IMAGE_LOGIN_USER, "root:password"); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,os64Bit=true,osVersionMatches=1[012].[01][04]"); + return properties; + } + + public static class Builder extends BaseHttpApiMetadata.Builder<DockerApi, Builder> { + + protected Builder() { + super(DockerApi.class); + id("docker") + .name("Docker API") + .identityName("user") + .credentialName("password") + .documentation(URI.create("https://docs.docker.com/reference/api/docker_remote_api/")) + .version("1.12") + .defaultEndpoint("http://127.0.0.1:2375") + .defaultProperties(DockerApiMetadata.defaultProperties()) + .view(typeToken(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.<Class<? extends Module>>of( + DockerHttpApiModule.class, + DockerParserModule.class, + DockerComputeServiceContextModule.class)); + } + + @Override + public DockerApiMetadata build() { + return new DockerApiMetadata(this); + } + + @Override + protected Builder self() { + return this; + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + return this; + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java new file mode 100644 index 0000000..855a2e5 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java @@ -0,0 +1,68 @@ +/* + * 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.docker.binders; + +import com.google.common.base.Throwables; +import com.google.common.io.Files; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.docker.features.internal.Archives; +import org.jclouds.http.HttpRequest; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.logging.Logger; +import org.jclouds.rest.Binder; + +import javax.annotation.Resource; +import javax.inject.Named; +import javax.inject.Singleton; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +@Singleton +public class BindInputStreamToRequest implements Binder { + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + @Override + public <R extends HttpRequest> R bindToRequest(R request, Object input) { + checkArgument(checkNotNull(input, "input") instanceof File, "this binder is only valid for File!"); + checkNotNull(request, "request"); + + File dockerFile = (File) input; + File tmpDir = Files.createTempDir(); + final File targetFile = new File(tmpDir + File.separator + "Dockerfile"); + try { + Files.copy(dockerFile, targetFile); + File archive = Archives.tar(tmpDir, File.createTempFile("archive", ".tar")); + FileInputStream data = new FileInputStream(archive); + Payload payload = Payloads.newInputStreamPayload(data); + payload.getContentMetadata().setContentLength(data.getChannel().size()); + payload.getContentMetadata().setContentType("application/tar"); + request.setPayload(payload); + } catch (IOException e) { + logger.error(e, "Couldn't create a tarball for %s", targetFile); + throw Throwables.propagate(e); + } + return request; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java new file mode 100644 index 0000000..063d6c9 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java @@ -0,0 +1,59 @@ +/* + * 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.docker.compute.config; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.config.ComputeServiceAdapterContextModule; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.docker.compute.functions.ContainerToNodeMetadata; +import org.jclouds.docker.compute.functions.ImageToImage; +import org.jclouds.docker.compute.functions.StateToStatus; +import org.jclouds.docker.compute.options.DockerTemplateOptions; +import org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter; +import org.jclouds.docker.domain.Container; +import org.jclouds.docker.domain.Image; +import org.jclouds.docker.domain.State; +import org.jclouds.domain.Location; +import org.jclouds.functions.IdentityFunction; + +public class DockerComputeServiceContextModule extends + ComputeServiceAdapterContextModule<Container, Hardware, Image, Location> { + + @SuppressWarnings("unchecked") + @Override + protected void configure() { + super.configure(); + bind(new TypeLiteral<ComputeServiceAdapter<Container, Hardware, Image, Location>>() { + }).to(DockerComputeServiceAdapter.class); + bind(new TypeLiteral<Function<Container, NodeMetadata>>() { + }).to(ContainerToNodeMetadata.class); + bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() { + }).to(ImageToImage.class); + bind(new TypeLiteral<Function<Hardware, Hardware>>() { + }).to(Class.class.cast(IdentityFunction.class)); + bind(new TypeLiteral<Function<Location, Location>>() { + }).to(Class.class.cast(IdentityFunction.class)); + bind(new TypeLiteral<Function<State, NodeMetadata.Status>>() { + }).to(StateToStatus.class); + bind(TemplateOptions.class).to(DockerTemplateOptions.class); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java new file mode 100644 index 0000000..72c16af --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.getOnlyElement; +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.collect.Memoized; +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.Processor; +import org.jclouds.compute.functions.GroupNamingConvention; +import org.jclouds.docker.domain.Container; +import org.jclouds.docker.domain.Port; +import org.jclouds.docker.domain.State; +import org.jclouds.domain.Location; +import org.jclouds.providers.ProviderMetadata; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.inject.Singleton; + +@Singleton +public class ContainerToNodeMetadata implements Function<Container, NodeMetadata> { + + private final ProviderMetadata providerMetadata; + private final Function<State, NodeMetadata.Status> toPortableStatus; + private final GroupNamingConvention nodeNamingConvention; + private final Supplier<Map<String, ? extends Image>> images; + private final Supplier<Set<? extends Location>> locations; + + @Inject + public ContainerToNodeMetadata(ProviderMetadata providerMetadata, Function<State, + NodeMetadata.Status> toPortableStatus, GroupNamingConvention.Factory namingConvention, + Supplier<Map<String, ? extends Image>> images, + @Memoized Supplier<Set<? extends Location>> locations) { + this.providerMetadata = checkNotNull(providerMetadata, "providerMetadata"); + this.toPortableStatus = checkNotNull(toPortableStatus, "toPortableStatus cannot be null"); + this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); + this.images = checkNotNull(images, "images cannot be null"); + this.locations = checkNotNull(locations, "locations"); + } + + @Override + public NodeMetadata apply(Container container) { + String name = cleanUpName(container.getName()); + String group = nodeNamingConvention.extractGroup(name); + NodeMetadataBuilder builder = new NodeMetadataBuilder(); + builder.ids(container.getId()) + .name(name) + .group(group) + .hostname(container.getContainerConfig().getHostname()) + // TODO Set up hardware + .hardware(new HardwareBuilder() + .id("") + .ram(container.getContainerConfig().getMemory()) + .processor(new Processor(container.getContainerConfig().getCpuShares(), container.getContainerConfig().getCpuShares())) + .build()); + builder.status(toPortableStatus.apply(container.getState())); + builder.imageId(container.getImage()); + builder.loginPort(getLoginPort(container)); + builder.publicAddresses(getPublicIpAddresses()); + builder.privateAddresses(getPrivateIpAddresses(container)); + builder.location(Iterables.getOnlyElement(locations.get())); + Image image = images.get().get(container.getImage()); + builder.imageId(image.getId()); + builder.operatingSystem(image.getOperatingSystem()); + + return builder.build(); + } + + private String cleanUpName(String name) { + return name.startsWith("/") ? name.substring(1) : name; + } + + private Iterable<String> getPrivateIpAddresses(Container container) { + if (container.getNetworkSettings() == null) return ImmutableList.of(); + return ImmutableList.of(container.getNetworkSettings().getIpAddress()); + } + + private List<String> getPublicIpAddresses() { + String dockerIpAddress = URI.create(providerMetadata.getEndpoint()).getHost(); + return ImmutableList.of(dockerIpAddress); + } + + protected static int getLoginPort(Container container) { + if (container.getNetworkSettings() != null) { + Map<String, List<Map<String, String>>> ports = container.getNetworkSettings().getPorts(); + if (ports != null) { + return Integer.parseInt(getOnlyElement(ports.get("22/tcp")).get("HostPort")); + } + // this is needed in case the container list is coming from listContainers + } else if (container.getPorts() != null) { + for (Port port : container.getPorts()) { + if (port.getPrivatePort() == 22) { + return port.getPublicPort(); + } + } + } + throw new IllegalStateException("Cannot determine the login port for " + container.getId()); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java new file mode 100644 index 0000000..4e3358d --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.compute.functions; + +import com.google.common.base.Function; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +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.logging.Logger; + +import javax.annotation.Resource; +import javax.inject.Named; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.get; + +public class ImageToImage implements Function<org.jclouds.docker.domain.Image, org.jclouds.compute.domain.Image> { + + private static final String CENTOS = "centos"; + private static final String UBUNTU = "ubuntu"; + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + @Override + public Image apply(org.jclouds.docker.domain.Image from) { + checkNotNull(from, "image"); + String description = checkNotNull(Iterables.getFirst(from.getRepoTags(), "image must have at least one repo tag")); + + OsFamily osFamily = osFamily().apply(description); + String osVersion = parseVersion(description); + + OperatingSystem os = OperatingSystem.builder() + .description(description) + .family(osFamily) + .version(osVersion) + .is64Bit(is64bit(from)) + .build(); + + return new ImageBuilder() + .ids(from.getId()) + .name(get(Splitter.on(":").split(description), 0)) + .description(description) + .operatingSystem(os) + .status(Image.Status.AVAILABLE) + .build(); + } + + private boolean is64bit(org.jclouds.docker.domain.Image inspectedImage) { + if (inspectedImage.getArchitecture() == null) return true; + return inspectedImage.getArchitecture().matches("x86_64|amd64"); + } + + /** + * Parses the item description to determine the OSFamily + * + * @return the @see OsFamily or OsFamily.UNRECOGNIZED + */ + private Function<String, OsFamily> osFamily() { + return new Function<String, OsFamily>() { + + @Override + public OsFamily apply(final String description) { + if (description != null) { + if (description.contains(CENTOS)) return OsFamily.CENTOS; + else if (description.contains(UBUNTU)) return OsFamily.UBUNTU; + } + return OsFamily.UNRECOGNIZED; + } + }; + } + + private String parseVersion(String description) { + String version = get(Splitter.on(":").split(description), 1); + logger.debug("os version for item: %s is %s", description, version); + return version; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java new file mode 100644 index 0000000..2d87384 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java @@ -0,0 +1,38 @@ +/* + * 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.docker.compute.functions; + +import javax.inject.Singleton; + +import org.jclouds.compute.domain.NodeMetadata.Status; +import org.jclouds.docker.domain.State; + +import com.google.common.base.Function; + +/** + * Transforms an {@link org.jclouds.docker.domain.Container} to the jclouds portable model. + */ +@Singleton +public class StateToStatus implements Function<State, Status> { + + @Override + public Status apply(final State state) { + if (state == null) return Status.UNRECOGNIZED; + return state.isRunning() ? Status.RUNNING : Status.TERMINATED; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java new file mode 100644 index 0000000..5e4669b --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java @@ -0,0 +1,485 @@ +/* + * 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.docker.compute.options; + +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.scriptbuilder.domain.Statement; + +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Contains options supported in the {@code ComputeService#runNode} operation on the + * "docker" provider. <h2>Usage</h2> The recommended way to instantiate a + * DockerTemplateOptions object is to statically import DockerTemplateOptions.* and invoke a static + * creation method followed by an instance mutator (if needed): + * <p/> + * <code> + * import static org.jclouds.docker.compute.options.DockerTemplateOptions.Builder.*; + * <p/> + * ComputeService api = // get connection + * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); + * Set<? extends NodeMetadata> set = api.createNodesInGroup(tag, 2, templateBuilder.build()); + * <code> + */ +public class DockerTemplateOptions extends TemplateOptions implements Cloneable { + + protected Optional<String> dns = Optional.absent(); + protected Optional<String> hostname = Optional.absent(); + protected Optional<Integer> memory = Optional.absent(); + protected Optional<Integer> cpuShares = Optional.absent(); + protected Optional<List<String>> commands = Optional.absent(); + protected Optional<Map<String, String>> volumes = Optional.absent(); + + @Override + public DockerTemplateOptions clone() { + DockerTemplateOptions options = new DockerTemplateOptions(); + copyTo(options); + return options; + } + + @Override + public void copyTo(TemplateOptions to) { + super.copyTo(to); + if (to instanceof DockerTemplateOptions) { + DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); + if (volumes.isPresent()) { + eTo.volumes(getVolumes().get()); + } + if (hostname.isPresent()) { + eTo.hostname(hostname.get()); + } + if (dns.isPresent()) { + eTo.dns(dns.get()); + } + if (memory.isPresent()) { + eTo.memory(memory.get()); + } + if (commands.isPresent()) { + eTo.commands(commands.get()); + } + if (cpuShares.isPresent()) { + eTo.cpuShares(cpuShares.get()); + } + } + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + DockerTemplateOptions that = DockerTemplateOptions.class.cast(o); + return super.equals(that) && equal(this.volumes, that.volumes) && + equal(this.hostname, that.hostname) && + equal(this.dns, that.dns) && + equal(this.memory, that.memory) && + equal(this.commands, that.commands) && + equal(this.cpuShares, that.cpuShares); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), volumes, hostname, dns, memory, commands, cpuShares); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("dns", dns) + .add("hostname", hostname) + .add("memory", memory) + .add("cpuShares", cpuShares) + .add("commands", commands) + .add("volumes", volumes) + .toString(); + } + + public static final DockerTemplateOptions NONE = new DockerTemplateOptions(); + + public DockerTemplateOptions volumes(Map<String, String> volumes) { + this.volumes = Optional.<Map<String, String>> of(ImmutableMap.copyOf(volumes)); + return this; + } + + public TemplateOptions dns(@Nullable String dns) { + this.dns = Optional.fromNullable(dns); + return this; + } + + public TemplateOptions hostname(@Nullable String hostname) { + this.hostname = Optional.fromNullable(hostname); + return this; + } + + public TemplateOptions memory(@Nullable Integer memory) { + this.memory = Optional.fromNullable(memory); + return this; + } + + public TemplateOptions commands(Iterable<String> commands) { + for (String command : checkNotNull(commands, "commands")) + checkNotNull(command, "all commands must be non-empty"); + this.commands = Optional.<List<String>> of(ImmutableList.copyOf(commands)); + return this; + } + + public TemplateOptions commands(String... commands) { + return commands(ImmutableList.copyOf(checkNotNull(commands, "commands"))); + } + + public TemplateOptions cpuShares(@Nullable Integer cpuShares) { + this.cpuShares = Optional.fromNullable(cpuShares); + return this; + } + + public Optional<Map<String, String>> getVolumes() { + return volumes; + } + + public Optional<String> getDns() { return dns; } + + public Optional<String> getHostname() { return hostname; } + + public Optional<Integer> getMemory() { return memory; } + + public Optional<List<String>> getCommands() { + return commands; + } + + public Optional<Integer> getCpuShares() { return cpuShares; } + + public static class Builder { + + /** + * @see DockerTemplateOptions#volumes(java.util.Map) + */ + public static DockerTemplateOptions volumes(Map<String, String> volumes) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.volumes(volumes)); + } + + /** + * @see DockerTemplateOptions#dns(String) + */ + public static DockerTemplateOptions dns(String dns) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.dns(dns)); + } + + /** + * @see DockerTemplateOptions#hostname(String) + */ + public static DockerTemplateOptions hostname(String hostname) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.hostname(hostname)); + } + + /** + * @see DockerTemplateOptions#memory(int) + */ + public static DockerTemplateOptions memory(int memory) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.memory(memory)); + } + + /** + * @see DockerTemplateOptions#commands(Iterable) + */ + public static DockerTemplateOptions commands(String... commands) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.commands(commands)); + } + + public static DockerTemplateOptions commands(Iterable<String> commands) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.commands(commands)); + } + + /** + * @see DockerTemplateOptions#cpuShares(int) + */ + public static DockerTemplateOptions cpuShares(int cpuShares) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.cpuShares(cpuShares)); + } + + // methods that only facilitate returning the correct object type + + /** + * @see TemplateOptions#inboundPorts + */ + public static DockerTemplateOptions inboundPorts(int... ports) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.inboundPorts(ports)); + } + + /** + * @see TemplateOptions#port + */ + public static DockerTemplateOptions blockOnPort(int port, int seconds) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.blockOnPort(port, seconds)); + } + + /** + * @see TemplateOptions#installPrivateKey + */ + public static DockerTemplateOptions installPrivateKey(String rsaKey) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.installPrivateKey(rsaKey)); + } + + /** + * @see TemplateOptions#authorizePublicKey + */ + public static DockerTemplateOptions authorizePublicKey(String rsaKey) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.authorizePublicKey(rsaKey)); + } + + /** + * @see TemplateOptions#userMetadata + */ + public static DockerTemplateOptions userMetadata(Map<String, String> userMetadata) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.userMetadata(userMetadata)); + } + + /** + * @see TemplateOptions#nodeNames(Iterable) + */ + public static DockerTemplateOptions nodeNames(Iterable<String> nodeNames) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.nodeNames(nodeNames)); + } + + /** + * @see TemplateOptions#networks(Iterable) + */ + public static DockerTemplateOptions networks(Iterable<String> networks) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.networks(networks)); + } + + /** + * @see TemplateOptions#overrideLoginUser + */ + public static DockerTemplateOptions overrideLoginUser(String user) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.overrideLoginUser(user); + } + + /** + * @see TemplateOptions#overrideLoginPassword + */ + public static DockerTemplateOptions overrideLoginPassword(String password) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.overrideLoginPassword(password); + } + + /** + * @see TemplateOptions#overrideLoginPrivateKey + */ + public static DockerTemplateOptions overrideLoginPrivateKey(String privateKey) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.overrideLoginPrivateKey(privateKey); + } + + /** + * @see TemplateOptions#overrideAuthenticateSudo + */ + public static DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.overrideAuthenticateSudo(authenticateSudo); + } + + /** + * @see TemplateOptions#overrideLoginCredentials + */ + public static DockerTemplateOptions overrideLoginCredentials(LoginCredentials credentials) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.overrideLoginCredentials(credentials); + } + + /** + * @see TemplateOptions#blockUntilRunning + */ + public static DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return options.blockUntilRunning(blockUntilRunning); + } + + } + + // methods that only facilitate returning the correct object type + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions blockOnPort(int port, int seconds) { + return DockerTemplateOptions.class.cast(super.blockOnPort(port, seconds)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions inboundPorts(int... ports) { + return DockerTemplateOptions.class.cast(super.inboundPorts(ports)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions authorizePublicKey(String publicKey) { + return DockerTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions installPrivateKey(String privateKey) { + return DockerTemplateOptions.class.cast(super.installPrivateKey(privateKey)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning) { + return DockerTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions dontAuthorizePublicKey() { + return DockerTemplateOptions.class.cast(super.dontAuthorizePublicKey()); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions nameTask(String name) { + return DockerTemplateOptions.class.cast(super.nameTask(name)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions runAsRoot(boolean runAsRoot) { + return DockerTemplateOptions.class.cast(super.runAsRoot(runAsRoot)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions runScript(Statement script) { + return DockerTemplateOptions.class.cast(super.runScript(script)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { + return DockerTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions overrideLoginPassword(String password) { + return DockerTemplateOptions.class.cast(super.overrideLoginPassword(password)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions overrideLoginPrivateKey(String privateKey) { + return DockerTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions overrideLoginUser(String loginUser) { + return DockerTemplateOptions.class.cast(super.overrideLoginUser(loginUser)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { + return DockerTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions userMetadata(Map<String, String> userMetadata) { + return DockerTemplateOptions.class.cast(super.userMetadata(userMetadata)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions userMetadata(String key, String value) { + return DockerTemplateOptions.class.cast(super.userMetadata(key, value)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions nodeNames(Iterable<String> nodeNames) { + return DockerTemplateOptions.class.cast(super.nodeNames(nodeNames)); + } + + /** + * {@inheritDoc} + */ + @Override + public DockerTemplateOptions networks(Iterable<String> networks) { + return DockerTemplateOptions.class.cast(super.networks(networks)); + } + +}
