http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java b/docker/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java deleted file mode 100644 index 690b50e..0000000 --- a/docker/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java +++ /dev/null @@ -1,353 +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.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.find; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.docker.DockerApi; -import org.jclouds.docker.compute.options.DockerTemplateOptions; -import org.jclouds.docker.domain.Config; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.ContainerSummary; -import org.jclouds.docker.domain.HostConfig; -import org.jclouds.docker.domain.Image; -import org.jclouds.docker.domain.ImageSummary; -import org.jclouds.docker.options.CreateImageOptions; -import org.jclouds.docker.options.ListContainerOptions; -import org.jclouds.docker.options.RemoveContainerOptions; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.logging.Logger; - -/** - * defines the connection between the {@link org.jclouds.docker.DockerApi} implementation and - * the jclouds {@link org.jclouds.compute.ComputeService} - */ -@Singleton -public class DockerComputeServiceAdapter implements - ComputeServiceAdapter<Container, Hardware, Image, Location> { - - - /** - * Some Docker versions returns host prefix even for images from Docker hub in repoTags field. We use this constant - * to correctly identify requested image name. - */ - public static final String PREFIX_DOCKER_HUB_HOST = "docker.io/"; - - /** - * (Optional) Suffix used, when image version is not used during searching images. - */ - public static final String SUFFIX_LATEST_VERSION = ":latest"; - - private static final String PATTERN_IMAGE_PREFIX = "^(" + Pattern.quote(PREFIX_DOCKER_HUB_HOST) + ")?"; - private static final String PATTERN_IMAGE_SUFFIX = "(" + Pattern.quote(SUFFIX_LATEST_VERSION) + ")?$"; - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final DockerApi api; - - @Inject - public DockerComputeServiceAdapter(DockerApi api) { - this.api = checkNotNull(api, "api"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public NodeAndInitialCredentials<Container> createNodeWithGroupEncodedIntoName(String group, String name, - Template template) { - checkNotNull(template, "template was null"); - TemplateOptions options = template.getOptions(); - checkNotNull(options, "template options was null"); - - String imageId = checkNotNull(template.getImage().getId(), "template image id must not be null"); - String loginUser = template.getImage().getDefaultCredentials().getUser(); - String loginUserPassword = template.getImage().getDefaultCredentials().getOptionalPassword().or("password"); - - DockerTemplateOptions templateOptions = DockerTemplateOptions.class.cast(options); - - Config containerConfig = null; - Config.Builder containerConfigBuilder = templateOptions.getConfigBuilder(); - if (containerConfigBuilder == null) { - containerConfigBuilder = Config.builder().image(imageId); - - containerConfigBuilder.entrypoint(templateOptions.getEntrypoint()); - containerConfigBuilder.cmd(templateOptions.getCommands()); - containerConfigBuilder.memory(templateOptions.getMemory()); - containerConfigBuilder.hostname(templateOptions.getHostname()); - containerConfigBuilder.cpuShares(templateOptions.getCpuShares()); - containerConfigBuilder.openStdin(templateOptions.getOpenStdin()); - containerConfigBuilder.env(templateOptions.getEnv()); - - if (!templateOptions.getVolumes().isEmpty()) { - Map<String, Object> volumes = Maps.newLinkedHashMap(); - for (String containerDir : templateOptions.getVolumes().values()) { - volumes.put(containerDir, Maps.newHashMap()); - } - containerConfigBuilder.volumes(volumes); - } - - HostConfig.Builder hostConfigBuilder = HostConfig.builder() - .publishAllPorts(true) - .privileged(templateOptions.getPrivileged()); - - if (!templateOptions.getPortBindings().isEmpty()) { - Map<String, List<Map<String, String>>> portBindings = Maps.newHashMap(); - for (Map.Entry<Integer, Integer> entry : templateOptions.getPortBindings().entrySet()) { - portBindings.put(entry.getValue() + "/tcp", - Lists.<Map<String, String>>newArrayList(ImmutableMap.of("HostIp", "0.0.0.0", "HostPort", Integer.toString(entry.getKey())))); - } - hostConfigBuilder.portBindings(portBindings); - } - - if (!templateOptions.getDns().isEmpty()) { - hostConfigBuilder.dns(templateOptions.getDns()); - } - - if (!templateOptions.getExtraHosts().isEmpty()) { - List<String> extraHosts = Lists.newArrayList(); - for (Map.Entry<String, String> entry : templateOptions.getExtraHosts().entrySet()) { - extraHosts.add(entry.getKey() + ":" + entry.getValue()); - } - hostConfigBuilder.extraHosts(extraHosts); - } - - if (!templateOptions.getVolumes().isEmpty()) { - for (Map.Entry<String, String> entry : templateOptions.getVolumes().entrySet()) { - hostConfigBuilder.binds(ImmutableList.of(entry.getKey() + ":" + entry.getValue())); - } - } - - if (!templateOptions.getVolumesFrom().isEmpty()) { - hostConfigBuilder.volumesFrom(templateOptions.getVolumesFrom()); - } - - hostConfigBuilder.networkMode(templateOptions.getNetworkMode()); - - containerConfigBuilder.hostConfig(hostConfigBuilder.build()); - - // add the inbound ports into exposed ports map - containerConfig = containerConfigBuilder.build(); - Map<String, Object> exposedPorts = Maps.newHashMap(); - if (containerConfig.exposedPorts() == null) { - exposedPorts.putAll(containerConfig.exposedPorts()); - } - for (int inboundPort : templateOptions.getInboundPorts()) { - String portKey = inboundPort + "/tcp"; - if (!exposedPorts.containsKey(portKey)) { - exposedPorts.put(portKey, Maps.newHashMap()); - } - } - containerConfigBuilder.exposedPorts(exposedPorts); - - // build once more after setting inboundPorts - containerConfig = containerConfigBuilder.build(); - - // finally update port bindings - Map<String, List<Map<String, String>>> portBindings = Maps.newHashMap(); - Map<String, List<Map<String, String>>> existingBindings = containerConfig.hostConfig().portBindings(); - if (existingBindings != null) { - portBindings.putAll(existingBindings); - } - for (String exposedPort : containerConfig.exposedPorts().keySet()) { - if (!portBindings.containsKey(exposedPort)) { - portBindings.put(exposedPort, Lists.<Map<String, String>>newArrayList(ImmutableMap.of("HostIp", "0.0.0.0"))); - } - } - hostConfigBuilder = HostConfig.builder().fromHostConfig(containerConfig.hostConfig()); - hostConfigBuilder.portBindings(portBindings); - containerConfigBuilder.hostConfig(hostConfigBuilder.build()); - } else { - containerConfigBuilder.image(imageId); - } - - containerConfig = containerConfigBuilder.build(); - - logger.debug(">> creating new container with containerConfig(%s)", containerConfig); - Container container = api.getContainerApi().createContainer(name, containerConfig); - logger.trace("<< container(%s)", container.id()); - - if (templateOptions.getNetworks() != null) { - logger.debug(">> connecting container(%s) to networks(%s)", container.id(), Iterables.toString(templateOptions.getNetworks())); - for (String networkIdOrName : templateOptions.getNetworks()) { - api.getNetworkApi().connectContainerToNetwork(networkIdOrName, container.id()); - } - logger.trace("<< connected(%s)", container.id()); - } - - HostConfig hostConfig = containerConfig.hostConfig(); - - logger.debug(">> starting container(%s) with hostConfig(%s)", container.id(), hostConfig); - api.getContainerApi().startContainer(container.id(), hostConfig); - logger.trace("<< started(%s)", container.id()); - - container = api.getContainerApi().inspectContainer(container.id()); - if (container.state().exitCode() != 0) { - destroyNode(container.id()); - throw new IllegalStateException(String.format("Container %s has not started correctly", container.id())); - } - return new NodeAndInitialCredentials(container, container.id(), - LoginCredentials.builder().user(loginUser).password(loginUserPassword).build()); - } - - @Override - public Iterable<Hardware> listHardwareProfiles() { - Set<Hardware> hardware = Sets.newLinkedHashSet(); - // todo they are only placeholders at the moment - hardware.add(new HardwareBuilder().ids("micro").hypervisor("lxc").name("micro").processor(new Processor(1, 1)).ram(512).build()); - hardware.add(new HardwareBuilder().ids("small").hypervisor("lxc").name("small").processor(new Processor(1, 1)).ram(1024).build()); - hardware.add(new HardwareBuilder().ids("medium").hypervisor("lxc").name("medium").processor(new Processor(2, 1)).ram(2048).build()); - hardware.add(new HardwareBuilder().ids("large").hypervisor("lxc").name("large").processor(new Processor(2, 1)).ram(3072).build()); - return hardware; - } - - /** - * Method based on {@link org.jclouds.docker.features.ImageApi#listImages()}. It retrieves additional - * information by inspecting each image. - * - * @see org.jclouds.compute.ComputeServiceAdapter#listImages() - */ - @Override - public Set<Image> listImages() { - Set<Image> images = Sets.newHashSet(); - for (ImageSummary imageSummary : api.getImageApi().listImages()) { - // less efficient than just listImages but returns richer json that needs repoTags coming from listImages - Image inspected = api.getImageApi().inspectImage(imageSummary.id()); - inspected = Image.create(inspected.id(), inspected.author(), inspected.comment(), inspected.config(), - inspected.containerConfig(), inspected.parent(), inspected.created(), inspected.container(), - inspected.dockerVersion(), inspected.architecture(), inspected.os(), inspected.size(), - inspected.virtualSize(), imageSummary.repoTags()); - images.add(inspected); - } - return images; - } - - @Override - public Image getImage(final String imageIdOrName) { - checkNotNull(imageIdOrName); - if (imageIdOrName.startsWith("sha256")) { - // less efficient than just inspectImage but listImages return repoTags - return find(listImages(), new Predicate<Image>() { - @Override - public boolean apply(Image input) { - // Only attempt match on id as we should try to pull again anyway if using name - return input.id().equals(imageIdOrName); - } - }, null); - } - - // Image is not cached or getting image by name so try to pull it - api.getImageApi().createImage(CreateImageOptions.Builder.fromImage(imageIdOrName)); - - // as above this ensure repotags are returned - return find(listImages(), createPredicateMatchingRepoTags(imageIdOrName), null); - } - - @Override - public Iterable<Container> listNodes() { - Set<Container> containers = Sets.newHashSet(); - for (ContainerSummary containerSummary : api.getContainerApi().listContainers(ListContainerOptions.Builder.all(true))) { - // less efficient than just listNodes but returns richer json - containers.add(api.getContainerApi().inspectContainer(containerSummary.id())); - } - return containers; - } - - @Override - public Iterable<Container> listNodesByIds(final Iterable<String> ids) { - Set<Container> containers = Sets.newHashSet(); - for (String id : ids) { - containers.add(api.getContainerApi().inspectContainer(id)); - } - return containers; - } - - @Override - public Iterable<Location> listLocations() { - return ImmutableSet.of(); - } - - @Override - public Container getNode(String id) { - return api.getContainerApi().inspectContainer(id); - } - - @Override - public void destroyNode(String id) { - api.getContainerApi().removeContainer(id, RemoveContainerOptions.Builder.force(true)); - } - - @Override - public void rebootNode(String id) { - api.getContainerApi().stopContainer(id); - api.getContainerApi().startContainer(id); - } - - @Override - public void resumeNode(String id) { - api.getContainerApi().unpause(id); - } - - @Override - public void suspendNode(String id) { - api.getContainerApi().pause(id); - } - - protected static Predicate<Image> createPredicateMatchingRepoTags(final String imageIdOrName) { - final Pattern imgPattern = Pattern - .compile(PATTERN_IMAGE_PREFIX + Pattern.quote(imageIdOrName) + PATTERN_IMAGE_SUFFIX); - return new Predicate<Image>() { - @Override - public boolean apply(Image input) { - for (String tag : input.repoTags()) { - if (imgPattern.matcher(tag).matches()) { - return true; - } - } - return false; - } - }; - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java b/docker/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java deleted file mode 100644 index afd8e36..0000000 --- a/docker/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java +++ /dev/null @@ -1,68 +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 com.google.common.base.Supplier; -import com.google.inject.AbstractModule; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; -import com.google.inject.util.Modules; -import org.jclouds.docker.DockerApi; -import org.jclouds.docker.handlers.DockerErrorHandler; -import org.jclouds.docker.suppliers.DockerUntrustedSSLContextSupplier; -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.OkHttpClientSupplier; -import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; - -import javax.net.ssl.SSLContext; - -/** - * Configures the Docker connection. - */ -@ConfiguresHttpApi -@ConfiguresHttpCommandExecutorService -public class DockerHttpApiModule extends HttpApiModule<DockerApi> { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(DockerErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(DockerErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(DockerErrorHandler.class); - } - - /** - * This configures SSL certificate authentication when the Docker daemon is set to use an encrypted TCP socket - */ - @Override - protected void configure() { - super.configure(); - install(Modules.override(new OkHttpCommandExecutorServiceModule()).with(new AbstractModule() { - @Override - protected void configure() { - bind(new TypeLiteral<Supplier<SSLContext>>() {}).annotatedWith(Names.named("untrusted")).to(DockerUntrustedSSLContextSupplier.class); - } - })); - bind(OkHttpClientSupplier.class).to(DockerOkHttpClientSupplier.class); - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/config/DockerOkHttpClientSupplier.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/config/DockerOkHttpClientSupplier.java b/docker/src/main/java/org/jclouds/docker/config/DockerOkHttpClientSupplier.java deleted file mode 100644 index f9278f0..0000000 --- a/docker/src/main/java/org/jclouds/docker/config/DockerOkHttpClientSupplier.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.docker.config; - -import java.io.File; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.docker.suppliers.DockerSSLContextSupplier; -import org.jclouds.domain.Credentials; -import org.jclouds.http.okhttp.OkHttpClientSupplier; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableList; -import com.squareup.okhttp.ConnectionSpec; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.TlsVersion; - -@Singleton -public class DockerOkHttpClientSupplier implements OkHttpClientSupplier { - - private final DockerSSLContextSupplier dockerSSLContextSupplier; - private final Supplier<Credentials> creds; - - @Inject - DockerOkHttpClientSupplier(DockerSSLContextSupplier dockerSSLContextSupplier, @Provider Supplier<Credentials> creds) { - this.dockerSSLContextSupplier = dockerSSLContextSupplier; - this.creds = creds; - } - - @Override - public OkHttpClient get() { - OkHttpClient client = new OkHttpClient(); - ConnectionSpec tlsSpec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) - .tlsVersions(TlsVersion.TLS_1_0, TlsVersion.TLS_1_1, TlsVersion.TLS_1_2) - .build(); - ConnectionSpec cleartextSpec = new ConnectionSpec.Builder(ConnectionSpec.CLEARTEXT) - .build(); - client.setConnectionSpecs(ImmutableList.of(tlsSpec, cleartextSpec)); - // check if identity and credential are files, to set up sslContext - if (new File(creds.get().identity).isFile() && new File(creds.get().credential).isFile()) { - client.setSslSocketFactory(dockerSSLContextSupplier.get().getSocketFactory()); - } - return client; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/config/DockerParserModule.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/config/DockerParserModule.java b/docker/src/main/java/org/jclouds/docker/config/DockerParserModule.java deleted file mode 100644 index 383f99e..0000000 --- a/docker/src/main/java/org/jclouds/docker/config/DockerParserModule.java +++ /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. - */ -package org.jclouds.docker.config; - -import org.jclouds.json.config.GsonModule; - -import com.google.inject.AbstractModule; - -public class DockerParserModule extends AbstractModule { - - @Override protected void configure() { - bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Config.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Config.java b/docker/src/main/java/org/jclouds/docker/domain/Config.java deleted file mode 100644 index 58658de..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Config.java +++ /dev/null @@ -1,265 +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.domain; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import static org.jclouds.docker.internal.NullSafeCopies.copyWithNullOf; - -import java.util.List; -import java.util.Map; - -import org.jclouds.docker.domain.HostConfig.Builder; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -@AutoValue -public abstract class Config { - @Nullable public abstract String hostname(); - - @Nullable public abstract String domainname(); - - @Nullable public abstract String user(); - - public abstract int memory(); - - public abstract int memorySwap(); - - public abstract int cpuShares(); - - public abstract boolean attachStdin(); - - public abstract boolean attachStdout(); - - public abstract boolean attachStderr(); - - public abstract boolean tty(); - - public abstract boolean openStdin(); - - public abstract boolean stdinOnce(); - - @Nullable public abstract List<String> env(); - - @Nullable public abstract List<String> cmd(); - - @Nullable public abstract List<String> entrypoint(); - - public abstract String image(); - - @Nullable public abstract Map<String, ?> volumes(); - - @Nullable public abstract String workingDir(); - - public abstract boolean networkDisabled(); - - public abstract Map<String, ?> exposedPorts(); - - public abstract List<String> securityOpts(); - - @Nullable public abstract HostConfig hostConfig(); - - Config() { - } - - @SerializedNames( - { - "Hostname", "Domainname", "User", "Memory", "MemorySwap", "CpuShares", "AttachStdin", "AttachStdout", - "AttachStderr", "Tty", "OpenStdin", "StdinOnce", "Env", "Cmd", "Entrypoint", "Image", "Volumes", - "WorkingDir", "NetworkDisabled", "ExposedPorts", "SecurityOpts", "HostConfig" - }) - public static Config create(String hostname, String domainname, String user, int memory, int memorySwap, - int cpuShares, boolean attachStdin, boolean attachStdout, boolean attachStderr, boolean tty, - boolean openStdin, boolean stdinOnce, List<String> env, List<String> cmd, List<String> entrypoint, - String image, Map<String, ?> volumes, String workingDir, boolean networkDisabled, - Map<String, ?> exposedPorts, List<String> securityOpts, HostConfig hostConfig) { - return new AutoValue_Config(hostname, domainname, user, memory, memorySwap, cpuShares, attachStdin, - attachStdout, attachStderr, tty, openStdin, stdinOnce, copyWithNullOf(env), copyWithNullOf(cmd), - copyWithNullOf(entrypoint), image, copyWithNullOf(volumes), workingDir, networkDisabled, - copyOf(exposedPorts), copyOf(securityOpts), hostConfig); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromConfig(this); - } - - public static final class Builder { - private String hostname; - private String domainname; - private String user; - private int memory; - private int memorySwap; - private int cpuShares; - private boolean attachStdin; - private boolean attachStdout; - private boolean attachStderr; - private boolean tty; - private boolean openStdin; - private boolean stdinOnce; - private List<String> env; - private List<String> cmd; - private List<String> entrypoint; - private String image; - private Map<String, ?> volumes; - private String workingDir; - private boolean networkDisabled; - private Map<String, ?> exposedPorts = Maps.newHashMap(); - private List<String> securityOpts = Lists.newArrayList(); - private HostConfig hostConfig; - - public Builder hostname(String hostname) { - this.hostname = hostname; - return this; - } - - public Builder domainname(String domainname) { - this.domainname = domainname; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder memory(Integer memory) { - if (memory != null) { - this.memory = memory; - } - return this; - } - - public Builder memorySwap(Integer memorySwap) { - if (memorySwap != null) { - this.memorySwap = memorySwap; - } - return this; - } - - public Builder cpuShares(Integer cpuShares) { - if (cpuShares != null) { - this.cpuShares = cpuShares; - } - return this; - } - - public Builder attachStdin(boolean attachStdin) { - this.attachStdin = attachStdin; - return this; - } - - public Builder attachStdout(boolean attachStdout) { - this.attachStdout = attachStdout; - return this; - } - - public Builder attachStderr(boolean attachStderr) { - this.attachStderr = attachStderr; - return this; - } - - public Builder tty(boolean tty) { - this.tty = tty; - return this; - } - - public Builder openStdin(boolean openStdin) { - this.openStdin = openStdin; - return this; - } - - public Builder stdinOnce(boolean stdinOnce) { - this.stdinOnce = stdinOnce; - return this; - } - - public Builder env(List<String> env) { - this.env = env; - return this; - } - - public Builder cmd(List<String> cmd) { - this.cmd = cmd; - return this; - } - - public Builder entrypoint(List<String> entrypoint) { - this.entrypoint = entrypoint; - return this; - } - - public Builder image(String image) { - this.image = checkNotNull(image, "image"); - return this; - } - - public Builder volumes(Map<String, ?> volumes) { - this.volumes = volumes; - return this; - } - - public Builder workingDir(String workingDir) { - this.workingDir = workingDir; - return this; - } - - public Builder networkDisabled(boolean networkDisabled) { - this.networkDisabled = networkDisabled; - return this; - } - - public Builder exposedPorts(Map<String, ?> exposedPorts) { - this.exposedPorts = exposedPorts; - return this; - } - - public Builder securityOpts(List<String> securityOpts) { - this.securityOpts = securityOpts; - return this; - } - - public Builder hostConfig(HostConfig hostConfig) { - this.hostConfig = hostConfig; - return this; - } - - public Config build() { - return Config.create(hostname, domainname, user, memory, memorySwap, cpuShares, attachStdin, attachStdout, - attachStderr, tty, openStdin, stdinOnce, env, cmd, entrypoint, image, volumes, workingDir, - networkDisabled, exposedPorts, securityOpts, hostConfig); - } - - public Builder fromConfig(Config in) { - return hostname(in.hostname()).domainname(in.domainname()).user(in.user()).memory(in.memory()) - .memorySwap(in.memorySwap()).cpuShares(in.cpuShares()).attachStdin(in.attachStdin()) - .attachStdout(in.attachStdout()).attachStderr(in.attachStderr()).tty(in.tty()) - .openStdin(in.openStdin()).stdinOnce(in.stdinOnce()).env(in.env()).cmd(in.cmd()) - .entrypoint(in.entrypoint()).image(in.image()).volumes(in.volumes()).workingDir(in.workingDir()) - .networkDisabled(in.networkDisabled()).exposedPorts(in.exposedPorts()) - .securityOpts(in.securityOpts()).hostConfig(in.hostConfig()); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Container.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Container.java b/docker/src/main/java/org/jclouds/docker/domain/Container.java deleted file mode 100644 index d0c10c9..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Container.java +++ /dev/null @@ -1,273 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class Container { - public abstract String id(); - - @Nullable public abstract Date created(); - - @Nullable public abstract String path(); - - @Nullable public abstract String name(); - - public abstract List<String> args(); - - @Nullable public abstract Config config(); - - @Nullable public abstract State state(); - - @Nullable public abstract String image(); - - @Nullable public abstract NetworkSettings networkSettings(); - - @Nullable public abstract String sysInitPath(); - - @Nullable public abstract String resolvConfPath(); - - public abstract Map<String, String> volumes(); - - @Nullable public abstract HostConfig hostConfig(); - - @Nullable public abstract String driver(); - - @Nullable public abstract String execDriver(); - - public abstract Map<String, Boolean> volumesRW(); - - @Nullable public abstract String command(); - - @Nullable public abstract String status(); - - public abstract List<Port> ports(); - - @Nullable public abstract String hostnamePath(); - - @Nullable public abstract String hostsPath(); - - @Nullable public abstract String mountLabel(); - - @Nullable public abstract String processLabel(); - - public abstract Optional<Node> node(); - - Container() { - } - - @SerializedNames( - { - "Id", "Created", "Path", "Name", "Args", "Config", "State", "Image", "NetworkSettings", "SysInitPath", - "ResolvConfPath", "Volumes", "HostConfig", "Driver", "ExecDriver", "VolumesRW", "Command", "Status", - "Ports", "HostnamePath", "HostsPath", "MountLabel", "ProcessLabel", "Node" - }) - public static Container create(String id, Date created, String path, String name, List<String> args, Config config, - State state, String image, NetworkSettings networkSettings, String sysInitPath, - String resolvConfPath, Map<String, String> volumes, HostConfig hostConfig, - String driver, String execDriver, Map<String, Boolean> volumesRW, String command, - String status, List<Port> ports, String hostnamePath, String hostsPath, - String mountLabel, String processLabel, Optional<Node> node) { - return new AutoValue_Container(id, created, path, name, copyOf(args), config, state, image, networkSettings, - sysInitPath, resolvConfPath, copyOf(volumes), hostConfig, driver, execDriver, copyOf(volumesRW), command, - status, copyOf(ports), hostnamePath, hostsPath, mountLabel, processLabel, node); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromContainer(this); - } - - public static final class Builder { - - private String id; - private Date created; - private String path; - private String name; - private List<String> args; - private Config config; - private State state; - private String image; - private NetworkSettings networkSettings; - private String sysInitPath; - private String resolvConfPath; - private Map<String, String> volumes = ImmutableMap.of(); - private HostConfig hostConfig; - private String driver; - private String execDriver; - private Map<String, Boolean> volumesRW = ImmutableMap.of(); - private String command; - private String status; - private List<Port> ports = ImmutableList.of(); - private String hostnamePath; - private String hostsPath; - private String mountLabel; - private String processLabel; - private Optional<Node> node = Optional.absent(); - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder created(Date created) { - this.created = created; - return this; - } - - public Builder path(String path) { - this.path = path; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder args(List<String> args) { - this.args = args; - return this; - } - - public Builder config(Config config) { - this.config = config; - return this; - } - - public Builder state(State state) { - this.state = state; - return this; - } - - public Builder image(String imageName) { - this.image = imageName; - return this; - } - - public Builder networkSettings(NetworkSettings networkSettings) { - this.networkSettings = networkSettings; - return this; - } - - public Builder sysInitPath(String sysInitPath) { - this.sysInitPath = sysInitPath; - return this; - } - - public Builder resolvConfPath(String resolvConfPath) { - this.resolvConfPath = resolvConfPath; - return this; - } - - public Builder volumes(Map<String, String> volumes) { - this.volumes = volumes; - return this; - } - - public Builder hostConfig(HostConfig hostConfig) { - this.hostConfig = hostConfig; - return this; - } - - public Builder driver(String driver) { - this.driver = driver; - return this; - } - - public Builder execDriver(String execDriver) { - this.execDriver = execDriver; - return this; - } - - public Builder volumesRW(Map<String, Boolean> volumesRW) { - this.volumesRW = volumesRW; - return this; - } - - public Builder command(String command) { - this.command = command; - return this; - } - - public Builder status(String status) { - this.status = status; - return this; - } - - public Builder ports(List<Port> ports) { - this.ports = ports; - return this; - } - - public Builder hostnamePath(String hostnamePath) { - this.hostnamePath = hostnamePath; - return this; - } - - public Builder hostsPath(String hostsPath) { - this.hostsPath = hostsPath; - return this; - } - - public Builder mountLabel(String mountLabel) { - this.mountLabel = mountLabel; - return this; - } - - public Builder processLabel(String processLabel) { - this.processLabel = processLabel; - return this; - } - - public Builder node(Node node) { - this.node = Optional.fromNullable(node); - return this; - } - - public Container build() { - return Container.create(id, created, path, name, args, config, state, image, networkSettings, - sysInitPath, resolvConfPath, volumes, hostConfig, driver, execDriver, volumesRW, command, status, - ports, hostnamePath, hostsPath, mountLabel, processLabel, node); - } - - public Builder fromContainer(Container in) { - return this.id(in.id()).name(in.name()).created(in.created()).path(in.path()).args(in.args()) - .config(in.config()).state(in.state()).image(in.image()).networkSettings(in.networkSettings()) - .sysInitPath(in.sysInitPath()).resolvConfPath(in.resolvConfPath()).driver(in.driver()) - .execDriver(in.execDriver()).volumes(in.volumes()).hostConfig(in.hostConfig()).volumesRW(in.volumesRW()) - .command(in.command()).status(in.status()).ports(in.ports()).hostnamePath(in.hostnamePath()) - .hostsPath(in.hostsPath()).mountLabel(in.mountLabel()).processLabel(in.processLabel()).node(in.node().orNull()); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ContainerSummary.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ContainerSummary.java b/docker/src/main/java/org/jclouds/docker/domain/ContainerSummary.java deleted file mode 100644 index 25bd595..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ContainerSummary.java +++ /dev/null @@ -1,52 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -// TODO it may be redundant (we already have Container value class) -@AutoValue -public abstract class ContainerSummary { - - public abstract String id(); - - public abstract List<String> names(); - - public abstract String created(); - - public abstract String image(); - - public abstract String command(); - - public abstract List<Port> ports(); - - public abstract String status(); - - ContainerSummary() { - } - - @SerializedNames({"Id", "Names", "Created", "Image", "Command", "Ports", "Status"}) - public static ContainerSummary create(String id, List<String> names, String created, String image, String command, List<Port> ports, String status) { - return new AutoValue_ContainerSummary(id, copyOf(names), created, image, command, copyOf(ports), status); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Exec.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Exec.java b/docker/src/main/java/org/jclouds/docker/domain/Exec.java deleted file mode 100644 index 7511f63..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Exec.java +++ /dev/null @@ -1,35 +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.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Represents a response from Exec Create call (<code>POST /containers/(id)/exec</code>). - */ -@AutoValue -public abstract class Exec { - - public abstract String id(); - - @SerializedNames({ "Id"}) - public static Exec create(String id) { - return new AutoValue_Exec(id); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ExecCreateParams.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ExecCreateParams.java b/docker/src/main/java/org/jclouds/docker/domain/ExecCreateParams.java deleted file mode 100644 index 3f6009b..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ExecCreateParams.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; - -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Json Parameters (some of them) of Exec Create call. - */ -@AutoValue -public abstract class ExecCreateParams { - - public abstract boolean attachStdout(); - - public abstract boolean attachStderr(); - - public abstract List<String> cmd(); - - @SerializedNames({ "AttachStdout", "AttachStderr", "Cmd" }) - private static ExecCreateParams create(boolean attachStdout, boolean attachStderr, List<String> cmd) { - return builder().attachStdout(attachStdout).attachStderr(attachStderr).cmd(cmd).build(); - } - - /** - * Creates builder for {@link ExecCreateParams}, it sets - * {@link #attachStderr()} and {@link #attachStdout()} to true as a default. - * - * @return new {@link ExecCreateParams.Builder} instance - */ - public static Builder builder() { - return new AutoValue_ExecCreateParams.Builder().attachStderr(true).attachStdout(true); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder attachStdout(boolean b); - - public abstract Builder attachStderr(boolean b); - - public abstract Builder cmd(List<String> cmd); - - abstract List<String> cmd(); - - abstract ExecCreateParams autoBuild(); - - public ExecCreateParams build() { - cmd(copyOf(cmd())); - return autoBuild(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ExecInspect.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ExecInspect.java b/docker/src/main/java/org/jclouds/docker/domain/ExecInspect.java deleted file mode 100644 index d15bccf..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ExecInspect.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Represents a response (part of it) from Exec Inspect call ( - * <code>GET /exec/(id)/json</code>). - */ -@AutoValue -public abstract class ExecInspect { - - public abstract String id(); - - public abstract boolean running(); - - public abstract int exitCode(); - - @SerializedNames({ "ID", "Running", "ExitCode"}) - public static ExecInspect create(String id, boolean running, int exitCode) { - return new AutoValue_ExecInspect(id, running, exitCode); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ExecStartParams.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ExecStartParams.java b/docker/src/main/java/org/jclouds/docker/domain/ExecStartParams.java deleted file mode 100644 index f8046f8..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ExecStartParams.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Json Parameter(s) (some of them) of Exec Start call. - */ -@AutoValue -public abstract class ExecStartParams { - - public abstract boolean detach(); - - @SerializedNames({ "Detach" }) - public static ExecStartParams create(boolean detach) { - return builder().detach(detach).build(); - } - - public static Builder builder() { - return new AutoValue_ExecStartParams.Builder().detach(false); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder detach(boolean b); - - public abstract ExecStartParams build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ExposedPorts.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ExposedPorts.java b/docker/src/main/java/org/jclouds/docker/domain/ExposedPorts.java deleted file mode 100644 index ac57a98..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ExposedPorts.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; - -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class ExposedPorts { - public abstract String portAndProtocol(); - - public abstract List<String> hostPorts(); - - ExposedPorts() { - } - - @SerializedNames({ "PortAndProtocol", "HostPorts" }) - public static ExposedPorts create(String portAndProtocol, List<String> hostPorts) { - return new AutoValue_ExposedPorts(portAndProtocol, copyOf(hostPorts)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/HostConfig.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/HostConfig.java b/docker/src/main/java/org/jclouds/docker/domain/HostConfig.java deleted file mode 100644 index b4ee4f3..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/HostConfig.java +++ /dev/null @@ -1,203 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import static org.jclouds.docker.internal.NullSafeCopies.copyWithNullOf; - -import java.util.List; -import java.util.Map; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -@AutoValue -public abstract class HostConfig { - @Nullable public abstract String containerIDFile(); - - @Nullable public abstract List<String> binds(); - - public abstract List<Map<String, String>> lxcConf(); - - public abstract boolean privileged(); - - @Nullable public abstract List<String> dns(); - - @Nullable public abstract List<String> dnsSearch(); - - public abstract Map<String, List<Map<String, String>>> portBindings(); - - @Nullable public abstract List<String> links(); - - @Nullable public abstract List<String> extraHosts(); - - public abstract boolean publishAllPorts(); - - @Nullable public abstract List<String> volumesFrom(); - - @Nullable public abstract String networkMode(); - - @Nullable public abstract List<String> securityOpt(); - - @Nullable public abstract List<String> capAdd(); - - @Nullable public abstract List<String> capDrop(); - - public abstract Map<String, String> restartPolicy(); - - - - HostConfig() { - } - - @SerializedNames({ "ContainerIDFile", "Binds", "LxcConf", "Privileged", "Dns", "DnsSearch", "PortBindings", - "Links", "ExtraHosts", "PublishAllPorts", "VolumesFrom", "NetworkMode", "SecurityOpt", - "CapAdd", "CapDrop", "RestartPolicy" }) - public static HostConfig create(String containerIDFile, List<String> binds, List<Map<String, String>> lxcConf, - boolean privileged, List<String> dns, List<String> dnsSearch, Map<String, List<Map<String, String>>> portBindings, - List<String> links, List<String> extraHosts, boolean publishAllPorts, List<String> volumesFrom, String networkMode, - List<String> securityOpt, List<String> capAdd, List<String> capDrop, Map<String, String> restartPolicy) { - return new AutoValue_HostConfig(containerIDFile, copyWithNullOf(binds), copyOf(lxcConf), privileged, copyWithNullOf(dns), copyWithNullOf(dnsSearch), - copyOf(portBindings), copyWithNullOf(links), copyWithNullOf(extraHosts), publishAllPorts, copyWithNullOf(volumesFrom), networkMode, - copyOf(securityOpt), copyWithNullOf(capAdd), copyWithNullOf(capDrop), copyOf(restartPolicy)); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromHostConfig(this); - } - - public static final class Builder { - - private String containerIDFile; - private List<String> binds; - private List<Map<String, String>> lxcConf = Lists.newArrayList(); - private boolean privileged; - private List<String> dns; - private List<String> dnsSearch; - private Map<String, List<Map<String, String>>> portBindings = Maps.newLinkedHashMap(); - private List<String> links; - private List<String> extraHosts; - private boolean publishAllPorts; - private List<String> volumesFrom; - private String networkMode; - private List<String> securityOpt = Lists.newArrayList(); - private List<String> capAdd; - private List<String> capDrop; - private Map<String, String> restartPolicy = Maps.newHashMap(); - - public Builder containerIDFile(String containerIDFile) { - this.containerIDFile = containerIDFile; - return this; - } - - public Builder binds(List<String> binds) { - this.binds = binds; - return this; - } - - public Builder lxcConf(List<Map<String, String>> lxcConf) { - this.lxcConf = lxcConf; - return this; - } - - public Builder privileged(boolean privileged) { - this.privileged = privileged; - return this; - } - - public Builder dns(List<String> dns) { - this.dns = dns; - return this; - } - - public Builder dnsSearch(List<String> dnsSearch) { - this.dnsSearch = dnsSearch; - return this; - } - - public Builder links(List<String> links) { - this.links = links; - return this; - } - - public Builder extraHosts(List<String> extraHosts) { - this.extraHosts = extraHosts; - return this; - } - - public Builder portBindings(Map<String, List<Map<String, String>>> portBindings) { - this.portBindings = portBindings; - return this; - } - - public Builder publishAllPorts(boolean publishAllPorts) { - this.publishAllPorts = publishAllPorts; - return this; - } - - public Builder volumesFrom(List<String> volumesFrom) { - this.volumesFrom = volumesFrom; - return this; - } - - public Builder networkMode(String networkMode) { - this.networkMode = networkMode; - return this; - } - - public Builder securityOpt(List<String> securityOpt) { - this.securityOpt = securityOpt; - return this; - } - - public Builder capAdd(List<String> capAdd) { - this.capAdd = capAdd; - return this; - } - - public Builder capDrop(List<String> capDrop) { - this.capDrop = capDrop; - return this; - } - - public Builder restartPolicy(Map<String, String> restartPolicy) { - this.restartPolicy = restartPolicy; - return this; - } - - public HostConfig build() { - return HostConfig.create(containerIDFile, binds, lxcConf, privileged, dns, dnsSearch, portBindings, links, - extraHosts, publishAllPorts, volumesFrom, networkMode, securityOpt, capAdd, capDrop, restartPolicy); - } - - public Builder fromHostConfig(HostConfig in) { - return this.containerIDFile(in.containerIDFile()).binds(in.binds()).lxcConf(in.lxcConf()) - .privileged(in.privileged()).dns(in.dns()).dnsSearch(in.dnsSearch()).links(in.links()) - .extraHosts(in.extraHosts()).portBindings(in.portBindings()).publishAllPorts(in.publishAllPorts()) - .volumesFrom(in.volumesFrom()).networkMode(in.networkMode()).securityOpt(in.securityOpt()) - .capAdd(in.capAdd()).capDrop(in.capDrop()).restartPolicy(in.restartPolicy()); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Image.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Image.java b/docker/src/main/java/org/jclouds/docker/domain/Image.java deleted file mode 100644 index a696c5f..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Image.java +++ /dev/null @@ -1,84 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; - -import java.util.Date; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Represents a response from Docker "Inspect an image" call (<code>GET /images/(name)/json</code>). - */ -@AutoValue -public abstract class Image { - - public abstract String id(); - - @Nullable public abstract String author(); - - @Nullable public abstract String comment(); - - @Nullable public abstract Config config(); - - @Nullable public abstract Config containerConfig(); - - public abstract String parent(); - - public abstract Date created(); - - public abstract String container(); - - public abstract String dockerVersion(); - - public abstract String architecture(); - - public abstract String os(); - - public abstract long size(); - - public abstract long virtualSize(); - - /** - * Tags of the image. The value is <code>null</code> when the instance comes - * from {@link org.jclouds.docker.features.ImageApi#inspectImage(String)}. - * Other methods can populate the content (e.g. - * {@link org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter#listImages()} - * call. - * <p> - * The tags are in form "ubuntu:12.10", "docker.io/busybox:1.23.2", ... - * </p> - * @return list of tags or <code>null</code> - */ - @Nullable public abstract List<String> repoTags(); - - Image() { - } - - @SerializedNames({ "Id", "Author", "Comment", "Config", "ContainerConfig", "Parent", "Created", - "Container", "DockerVersion", "Architecture", "Os", "Size", "VirtualSize", "RepoTags" }) - public static Image create(String id, String author, String comment, Config config, Config containerConfig, String parent, Date created, String container, String dockerVersion, String architecture, String os, long size, long virtualSize, List<String> repoTags) { - return new AutoValue_Image(id, author, comment, config, containerConfig, parent, created, container, - dockerVersion, architecture, os, size, virtualSize, copyOf(repoTags)); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ImageHistory.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ImageHistory.java b/docker/src/main/java/org/jclouds/docker/domain/ImageHistory.java deleted file mode 100644 index 5916a00..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ImageHistory.java +++ /dev/null @@ -1,50 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class ImageHistory { - - public abstract String id(); - - public abstract long created(); - - public abstract String createdBy(); - - @Nullable public abstract List<String> tags(); - - public abstract long size(); - - public abstract String comment(); - - - ImageHistory() { - } - - @SerializedNames({"Id", "Created", "CreatedBy", "Tags", "Size", "Comment"}) - public static ImageHistory create(String id, long created, String createdBy, List<String> tags, long size, String comment) { - return new AutoValue_ImageHistory(id, created, createdBy, copyOf(tags), size, comment); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/ImageSummary.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/ImageSummary.java b/docker/src/main/java/org/jclouds/docker/domain/ImageSummary.java deleted file mode 100644 index f4ea9b9..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/ImageSummary.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -// TODO it may be redundant (we already have Image value class) -@AutoValue -public abstract class ImageSummary { - - public abstract String id(); - - public abstract long created(); - - public abstract String parentId(); - - public abstract int size(); - - public abstract int virtualSize(); - - public abstract List<String> repoTags(); - - ImageSummary() { - } - - @SerializedNames({"Id", "Created", "ParentId", "Size", "VirtualSize", "RepoTags"}) - public static ImageSummary create(String id, long created, String parentId, int size, int virtualSize, - List<String> repoTags) { - return new AutoValue_ImageSummary(id, created, parentId, size, virtualSize, copyOf(repoTags)); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Info.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Info.java b/docker/src/main/java/org/jclouds/docker/domain/Info.java deleted file mode 100644 index 6a071c3..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Info.java +++ /dev/null @@ -1,108 +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.domain; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Info { - - public abstract int containers(); - - public abstract boolean debug(); - - public abstract String driver(); - - public abstract List<List<String>> driverStatus(); - - public abstract String executionDriver(); - - public abstract boolean iPv4Forwarding(); - - public abstract int images(); - - public abstract String indexServerAddress(); - - @Nullable public abstract String initPath(); - - @Nullable public abstract String initSha1(); - - public abstract String kernelVersion(); - - public abstract boolean memoryLimit(); - - public abstract int nEventsListener(); - - public abstract int nFd(); - - public abstract int nGoroutines(); - - public abstract String operatingSystem(); - - public abstract boolean swapLimit(); - - public abstract String dockerRootDir(); - - /** - * @return a list of daemon labels - */ - @Nullable public abstract List<String> labels(); - - /** - * @return total memory available - */ - public abstract long memTotal(); - - /** - * @return the number of CPUs available on the machine - */ - public abstract int ncpu(); - - /** - * @return a unique ID identifying the daemon - */ - public abstract String id(); - - /** - * @return a user-friendly name describing the running Docker daemon - */ - public abstract String name(); - - Info() { - } - - @SerializedNames({ - "Containers", "Debug", "Driver", "DriverStatus", "ExecutionDriver", "IPv4Forwarding", "Images", - "IndexServerAddress", "InitPath", "InitSha1", "KernelVersion", "MemoryLimit", "NEventsListener", - "NFd", "NGoroutines", "OperatingSystem", "SwapLimit", "DockerRootDir", "Labels", "MemTotal", "NCPU", - "ID", "Name" - }) - public static Info create(int containers, boolean debug, String driver, List<List<String>> driverStatus, - String executionDriver, boolean iPv4Forwarding, int images, String indexServerAddress, - String initPath, String initSha1, String kernelVersion, boolean memoryLimit, - int nEventsListener, int nFd, int nGoroutines, String operatingSystem, boolean swapLimit, - String dockerRootDir, List<String> labels, long memTotal, int ncpu, String id, String name) { - return new AutoValue_Info(containers, debug, driver, driverStatus, executionDriver, iPv4Forwarding, images, - indexServerAddress, initPath, initSha1, kernelVersion, memoryLimit, nEventsListener, nFd, nGoroutines, - operatingSystem, swapLimit, dockerRootDir, labels, memTotal, ncpu, id, name); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Network.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Network.java b/docker/src/main/java/org/jclouds/docker/domain/Network.java deleted file mode 100644 index d6de0d7..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Network.java +++ /dev/null @@ -1,215 +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.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; -import static org.jclouds.docker.internal.NullSafeCopies.copyWithNullOf; - -import java.util.List; -import java.util.Map; - -import com.google.auto.value.AutoValue; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -@AutoValue -public abstract class Network { - - @AutoValue - public abstract static class IPAM { - - IPAM() { } - - @Nullable public abstract String driver(); - - public abstract List<Config> config(); - - @SerializedNames({"Driver", "Config"}) - public static IPAM create(@Nullable String driver, List<Config> config) { - return builder() - .driver(driver) - .config(config) - .build(); - } - - public static Builder builder() { - return new AutoValue_Network_IPAM.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder driver(@Nullable String driver); - - public abstract Builder config(List<Config> config); - - abstract List<Config> config(); - - abstract IPAM autoBuild(); - - public IPAM build() { - return config(copyOf(config())) - .autoBuild(); - } - } - - @AutoValue - public abstract static class Config { - - Config() { } - - public abstract String subnet(); - - @Nullable public abstract String ipRange(); - - @Nullable public abstract String gateway(); - - @SerializedNames({"Subnet", "IPRange", "Gateway"}) - public static Config create(String subnet, @Nullable String ipRange, @Nullable String gateway) { - return builder() - .subnet(subnet) - .ipRange(ipRange) - .gateway(gateway) - .build(); - } - - public static Builder builder() { - return new AutoValue_Network_IPAM_Config.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder subnet(String subnet); - - public abstract Builder ipRange(@Nullable String ipRange); - - public abstract Builder gateway(@Nullable String gateway); - - abstract Config build(); - } - } - } - - @AutoValue - public abstract static class Details { - - Details() { } - - public abstract String endpoint(); - - public abstract String macAddress(); - - public abstract String ipv4address(); - - public abstract String ipv6address(); - - @SerializedNames({ "EndpointID", "MacAddress", "IPv4Address", "IPv6Address" }) - public static Details create(String endpoint, String macAddress, String ipv4address, String ipv6address) { - return builder() - .endpoint(endpoint) - .macAddress(macAddress) - .ipv4address(ipv4address) - .ipv6address(ipv6address) - .build(); - } - - public static Builder builder() { - return new AutoValue_Network_Details.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder endpoint(String endpoint); - - public abstract Builder macAddress(String macAddress); - - public abstract Builder ipv4address(String ipv4address); - - public abstract Builder ipv6address(String ipv6address); - - abstract Details build(); - } - } - - @Nullable public abstract String name(); - - @Nullable public abstract String id(); - - @Nullable public abstract String scope(); - - @Nullable public abstract String driver(); - - @Nullable public abstract IPAM ipam(); - - @Nullable public abstract Map<String, Details> containers(); - - @Nullable public abstract Map<String, String> options(); - - Network() { } - - @SerializedNames({ "Name", "Id", "Scope", "Driver", "IPAM", "Containers", "Options" }) - public static Network create(@Nullable String name, @Nullable String id, @Nullable String scope, - @Nullable String driver, @Nullable IPAM ipam, @Nullable Map<String, Details> containers, - @Nullable Map<String, String> options) { - return builder() - .name(name) - .id(id) - .scope(scope) - .driver(driver) - .ipam(ipam) - .containers(containers) - .options(options) - .build(); - } - - public static Builder builder() { - return new AutoValue_Network.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder name(@Nullable String name); - - public abstract Builder id(@Nullable String id); - - public abstract Builder scope(@Nullable String scope); - - public abstract Builder driver(@Nullable String driver); - - public abstract Builder ipam(@Nullable IPAM ipam); - - public abstract Builder containers(@Nullable Map<String, Details> containers); - - public abstract Builder options(@Nullable Map<String, String> options); - - abstract Map<String, Details> containers(); - - abstract Map<String, String> options(); - - abstract Network autoBuild(); - - public Network build() { - return containers(copyWithNullOf(containers())) - .options(copyOf(options())) - .autoBuild(); - } - } -}
