diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..f8ce0d30 --- /dev/null +++ b/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 2fc61df1..29f405c2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ target # Ignore all log files *.log + +test-output/ diff --git a/pom.xml b/pom.xml index 7e24e77e..4ba76cd5 100644 --- a/pom.xml +++ b/pom.xml @@ -272,5 +272,17 @@ + + + deployment + Internal Releases + http://54.197.251.122:8081/nexus/content/repositories/releases/ + + + deployment + Internal Releases + http://54.197.251.122:8081/nexus/content/repositories/snapshots/ + + diff --git a/src/main/java/com/kpelykh/docker/client/DockerClient.java b/src/main/java/com/kpelykh/docker/client/DockerClient.java index 7312d5fa..4981893f 100644 --- a/src/main/java/com/kpelykh/docker/client/DockerClient.java +++ b/src/main/java/com/kpelykh/docker/client/DockerClient.java @@ -643,7 +643,7 @@ public ClientResponse build(File dockerFolder, String tag) throws DockerExceptio FileUtils.copyFileToDirectory(dockerFile, tmpDockerContextFolder); for (String cmd : dockerFileContent) { - if (StringUtils.startsWithIgnoreCase(cmd.trim(), "ADD")) { + if (StringUtils.startsWithIgnoreCase(cmd.trim(), "ADD ")) { String addArgs[] = StringUtils.split(cmd, " \t"); if (addArgs.length != 3) { throw new DockerException(String.format("Wrong format on line [%s]", cmd)); diff --git a/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java b/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java index ff7ffc4e..cf8c2441 100644 --- a/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java +++ b/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java @@ -37,6 +37,7 @@ public class ContainerConfig { @JsonProperty("Domainname") private String domainName = ""; // FIXME Is this the right type? -BJE @JsonProperty("ExposedPorts") private Map exposedPorts; + public Map getExposedPorts() { return exposedPorts; diff --git a/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java b/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java index 04d2f8c9..597677e6 100644 --- a/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java +++ b/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java @@ -1,247 +1,246 @@ -package com.kpelykh.docker.client.model; - - -import org.codehaus.jackson.annotate.JsonProperty; - -import java.util.Arrays; -import java.util.Map; - -/** - * - * @author Konstantin Pelykh (kpelykh@gmail.com) - * - */ -public class ContainerInspectResponse { - - @JsonProperty("ID") - private String id; - - @JsonProperty("Created") - private String created; - - @JsonProperty("Path") - private String path; - - @JsonProperty("Args") - private String[] args; - - @JsonProperty("Config") - public ContainerConfig config; - - @JsonProperty("State") - private ContainerState state; - - @JsonProperty("Image") - private String image; - - @JsonProperty("NetworkSettings") - private NetworkSettings networkSettings; - - @JsonProperty("SysInitPath") - private String sysInitPath; - - @JsonProperty("ResolvConfPath") - private String resolvConfPath; - - @JsonProperty("Volumes") - private Map volumes; - - @JsonProperty("VolumesRW") - private Map volumesRW; - - @JsonProperty("HostnamePath") - private String hostnamePath; - - @JsonProperty("HostsPath") - private String hostsPath; - - @JsonProperty("Name") - private String name; - - @JsonProperty("Driver") - private String driver; - - @JsonProperty("HostConfig") - private HostConfig hostConfig; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String[] getArgs() { - return args; - } - - public void setArgs(String[] args) { - this.args = args; - } - - public ContainerConfig getConfig() { - return config; - } - - public void setConfig(ContainerConfig config) { - this.config = config; - } - - public ContainerState getState() { - return state; - } - - public void setState(ContainerState state) { - this.state = state; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - this.image = image; - } - - public NetworkSettings getNetworkSettings() { - return networkSettings; - } - - public void setNetworkSettings(NetworkSettings networkSettings) { - this.networkSettings = networkSettings; - } - - public String getSysInitPath() { - return sysInitPath; - } - - public void setSysInitPath(String sysInitPath) { - this.sysInitPath = sysInitPath; - } - - public String getResolvConfPath() { - return resolvConfPath; - } - - public void setResolvConfPath(String resolvConfPath) { - this.resolvConfPath = resolvConfPath; - } - - public Map getVolumes() { - return volumes; - } - - public void setVolumes(Map volumes) { - this.volumes = volumes; - } - - public Map getVolumesRW() { - return volumesRW; - } - - public void setVolumesRW(Map volumesRW) { - this.volumesRW = volumesRW; - } - - public String getHostnamePath() { - return hostnamePath; - } - - public void setHostnamePath(String hostnamePath) { - this.hostnamePath = hostnamePath; - } - - public String getHostsPath() { - return hostsPath; - } - - public void setHostsPath(String hostsPath) { - this.hostsPath = hostsPath; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDriver() { - return driver; - } - - public void setDriver(String driver) { - this.driver = driver; - } - - public HostConfig getHostConfig() { - return hostConfig; - } - - public void setHostConfig(HostConfig hostConfig) { - this.hostConfig = hostConfig; - } - - public class NetworkSettings { - - @JsonProperty("IPAddress") public String ipAddress; - @JsonProperty("IPPrefixLen") public int ipPrefixLen; - @JsonProperty("Gateway") public String gateway; - @JsonProperty("Bridge") public String bridge; - @JsonProperty("PortMapping") public Map> portMapping; - @JsonProperty("Ports") public Ports ports; - - @Override - public String toString() { - return "NetworkSettings{" + - "ports=" + ports + - ", portMapping=" + portMapping + - ", bridge='" + bridge + '\'' + - ", gateway='" + gateway + '\'' + - ", ipPrefixLen=" + ipPrefixLen + - ", ipAddress='" + ipAddress + '\'' + - '}'; - } - } - - public class ContainerState { - - @JsonProperty("Running") public boolean running; - @JsonProperty("Pid") public int pid; - @JsonProperty("ExitCode") public int exitCode; - @JsonProperty("StartedAt") public String startedAt; - @JsonProperty("Ghost") public boolean ghost; - @JsonProperty("FinishedAt") private String finishedAt; - - @Override - public String toString() { - return "ContainerState{" + - "running=" + running + - ", pid=" + pid + - ", exitCode=" + exitCode + - ", startedAt='" + startedAt + '\'' + - ", ghost=" + ghost + - ", finishedAt='" + finishedAt + '\'' + - '}'; - } - } - -} +package com.kpelykh.docker.client.model; + + +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Konstantin Pelykh (kpelykh@gmail.com) + * + */ +public class ContainerInspectResponse { + + @JsonProperty("ID") + private String id; + + @JsonProperty("Created") + private String created; + + @JsonProperty("Path") + private String path; + + @JsonProperty("Args") + private String[] args; + + @JsonProperty("Config") + public ContainerConfig config; + + @JsonProperty("State") + private ContainerState state; + + @JsonProperty("Image") + private String image; + + @JsonProperty("NetworkSettings") + private NetworkSettings networkSettings; + + @JsonProperty("SysInitPath") + private String sysInitPath; + + @JsonProperty("ResolvConfPath") + private String resolvConfPath; + + @JsonProperty("Volumes") + private Map volumes; + + @JsonProperty("VolumesRW") + private Map volumesRW; + + @JsonProperty("HostnamePath") + private String hostnamePath; + + @JsonProperty("HostsPath") + private String hostsPath; + + @JsonProperty("Name") + private String name; + + @JsonProperty("Driver") + private String driver; + + + @JsonProperty("HostConfig") + private HostConfig hostConfig; + + public HostConfig getHostConfig() { + return hostConfig; + } + public String getDriver() { + return driver; + } + public void setHostConfig(HostConfig hostConfig) { + this.hostConfig = hostConfig; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String[] getArgs() { + return args; + } + + public void setArgs(String[] args) { + this.args = args; + } + + public ContainerConfig getConfig() { + return config; + } + + public void setConfig(ContainerConfig config) { + this.config = config; + } + + public ContainerState getState() { + return state; + } + + public void setState(ContainerState state) { + this.state = state; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public NetworkSettings getNetworkSettings() { + return networkSettings; + } + + public void setNetworkSettings(NetworkSettings networkSettings) { + this.networkSettings = networkSettings; + } + + public String getSysInitPath() { + return sysInitPath; + } + + public void setSysInitPath(String sysInitPath) { + this.sysInitPath = sysInitPath; + } + + public String getResolvConfPath() { + return resolvConfPath; + } + + public void setResolvConfPath(String resolvConfPath) { + this.resolvConfPath = resolvConfPath; + } + + public Map getVolumes() { + return volumes; + } + + public void setVolumes(Map volumes) { + this.volumes = volumes; + } + + public Map getVolumesRW() { + return volumesRW; + } + + public void setVolumesRW(Map volumesRW) { + this.volumesRW = volumesRW; + } + + public String getHostnamePath() { + return hostnamePath; + } + + public void setHostnamePath(String hostnamePath) { + this.hostnamePath = hostnamePath; + } + + public String getHostsPath() { + return hostsPath; + } + + public void setHostsPath(String hostsPath) { + this.hostsPath = hostsPath; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public void setDriver(String driver) { + this.driver = driver; + } + + public class NetworkSettings { + + @JsonProperty("IPAddress") public String ipAddress; + @JsonProperty("IPPrefixLen") public int ipPrefixLen; + @JsonProperty("Gateway") public String gateway; + @JsonProperty("Bridge") public String bridge; + @JsonProperty("PortMapping") public Map> portMapping; + @JsonProperty("Ports") public Ports ports; + + @Override + public String toString() { + return "NetworkSettings{" + + "ports=" + ports + + ", portMapping=" + portMapping + + ", bridge='" + bridge + '\'' + + ", gateway='" + gateway + '\'' + + ", ipPrefixLen=" + ipPrefixLen + + ", ipAddress='" + ipAddress + '\'' + + '}'; + } + } + + public class ContainerState { + + @JsonProperty("Running") public boolean running; + @JsonProperty("Pid") public int pid; + @JsonProperty("ExitCode") public int exitCode; + @JsonProperty("StartedAt") public String startedAt; + @JsonProperty("Ghost") public boolean ghost; + @JsonProperty("FinishedAt") private String finishedAt; + + @Override + public String toString() { + return "ContainerState{" + + "running=" + running + + ", pid=" + pid + + ", exitCode=" + exitCode + + ", startedAt='" + startedAt + '\'' + + ", ghost=" + ghost + + ", finishedAt='" + finishedAt + '\'' + + '}'; + } + } + +} diff --git a/src/main/java/com/kpelykh/docker/client/model/HostConfig.java b/src/main/java/com/kpelykh/docker/client/model/HostConfig.java index e124cf0d..e6a15093 100644 --- a/src/main/java/com/kpelykh/docker/client/model/HostConfig.java +++ b/src/main/java/com/kpelykh/docker/client/model/HostConfig.java @@ -1,144 +1,144 @@ -package com.kpelykh.docker.client.model; - -import org.codehaus.jackson.annotate.JsonProperty; - -import java.util.Arrays; - -/** - * - * @author Konstantin Pelykh (kpelykh@gmail.com) - * - */ -public class HostConfig { - - @JsonProperty("Binds") - private String[] binds; - - @JsonProperty("ContainerIDFile") - private String containerIDFile; - - @JsonProperty("LxcConf") - private LxcConf[] lxcConf; - - - @JsonProperty("Links") - private String[] links; - - @JsonProperty("PortBindings") - private Ports portBindings; - - @JsonProperty("Privileged") - private boolean privileged; - - @JsonProperty("PublishAllPorts") - private boolean publishAllPorts; - - public HostConfig() { - this.binds = null; - } - - - public String[] getBinds() { - return binds; - } - - public void setBinds(String[] binds) { - this.binds = binds; - } - - public String getContainerIDFile() { - return containerIDFile; - } - - public void setContainerIDFile(String containerIDFile) { - this.containerIDFile = containerIDFile; - } - - public LxcConf[] getLxcConf() { - return lxcConf; - } - - public void setLxcConf(LxcConf[] lxcConf) { - this.lxcConf = lxcConf; - } - - public String[] getLinks() { - return links; - } - - public void setLinks(String[] links) { - this.links = links; - } - - public Ports getPortBindings() { - return portBindings; - } - - public void setPortBindings(Ports portBindings) { - this.portBindings = portBindings; - } - - public boolean isPrivileged() { - return privileged; - } - - public void setPrivileged(boolean privileged) { - this.privileged = privileged; - } - - public boolean isPublishAllPorts() { - return publishAllPorts; - } - - public void setPublishAllPorts(boolean publishAllPorts) { - this.publishAllPorts = publishAllPorts; - } - - @Override - public String toString() { - return "HostConfig{" + - "binds=" + Arrays.toString(binds) + - ", containerIDFile='" + containerIDFile + '\'' + - ", lxcConf=" + Arrays.toString(lxcConf) + - ", links=" + Arrays.toString(links) + - ", portBindings=" + portBindings + - ", privileged=" + privileged + - ", publishAllPorts=" + publishAllPorts + - '}'; - } - - public class LxcConf { - @JsonProperty("Key") - public String key; - - @JsonProperty("Value") - public String value; - - public LxcConf(String key, String value) { - this.key = key; - this.value = value; - } - - public LxcConf() { - } - - public String getKey() { - return key; - } - - public LxcConf setKey(String key) { - this.key = key; - return this; - } - - public String getValue() { - return value; - } - - public LxcConf setValue(String value) { - this.value = value; - return this; - } - - } -} +package com.kpelykh.docker.client.model; + +import org.codehaus.jackson.annotate.JsonProperty; + +import java.util.Arrays; + +/** + * + * @author Konstantin Pelykh (kpelykh@gmail.com) + * + */ +public class HostConfig { + + @JsonProperty("Binds") + private String[] binds; + + @JsonProperty("ContainerIDFile") + private String containerIDFile; + + @JsonProperty("LxcConf") + private LxcConf[] lxcConf; + + + @JsonProperty("Links") + private String[] links; + + @JsonProperty("PortBindings") + private Ports portBindings; + + @JsonProperty("Privileged") + private boolean privileged; + + @JsonProperty("PublishAllPorts") + private boolean publishAllPorts; + + public HostConfig() { + this.binds = null; + } + + + public String[] getBinds() { + return binds; + } + + public void setBinds(String[] binds) { + this.binds = binds; + } + + public String getContainerIDFile() { + return containerIDFile; + } + + public void setContainerIDFile(String containerIDFile) { + this.containerIDFile = containerIDFile; + } + + public LxcConf[] getLxcConf() { + return lxcConf; + } + + public void setLxcConf(LxcConf[] lxcConf) { + this.lxcConf = lxcConf; + } + + public String[] getLinks() { + return links; + } + + public void setLinks(String[] links) { + this.links = links; + } + + public Ports getPortBindings() { + return portBindings; + } + + public void setPortBindings(Ports portBindings) { + this.portBindings = portBindings; + } + + public boolean isPrivileged() { + return privileged; + } + + public void setPrivileged(boolean privileged) { + this.privileged = privileged; + } + + public boolean isPublishAllPorts() { + return publishAllPorts; + } + + public void setPublishAllPorts(boolean publishAllPorts) { + this.publishAllPorts = publishAllPorts; + } + + @Override + public String toString() { + return "HostConfig{" + + "binds=" + Arrays.toString(binds) + + ", containerIDFile='" + containerIDFile + '\'' + + ", lxcConf=" + Arrays.toString(lxcConf) + + ", links=" + Arrays.toString(links) + + ", portBindings=" + portBindings + + ", privileged=" + privileged + + ", publishAllPorts=" + publishAllPorts + + '}'; + } + + public class LxcConf { + @JsonProperty("Key") + public String key; + + @JsonProperty("Value") + public String value; + + public LxcConf(String key, String value) { + this.key = key; + this.value = value; + } + + public LxcConf() { + } + + public String getKey() { + return key; + } + + public LxcConf setKey(String key) { + this.key = key; + return this; + } + + public String getValue() { + return value; + } + + public LxcConf setValue(String value) { + this.value = value; + return this; + } + + } +} diff --git a/src/main/java/com/kpelykh/docker/client/model/Info.java b/src/main/java/com/kpelykh/docker/client/model/Info.java index 30667029..06c0ffe8 100644 --- a/src/main/java/com/kpelykh/docker/client/model/Info.java +++ b/src/main/java/com/kpelykh/docker/client/model/Info.java @@ -1,215 +1,215 @@ -package com.kpelykh.docker.client.model; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import java.util.List; - -/** - * - * @author Konstantin Pelykh (kpelykh@gmail.com) - * - */ -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class Info { - - @JsonProperty("Debug") - private boolean debug; - - @JsonProperty("Containers") - private int containers; - - @JsonProperty("Driver") - private String driver; - - @JsonProperty("DriverStatus") - private List driverStatuses; - - - @JsonProperty("Images") - private int images; - - @JsonProperty("IPv4Forwarding") - private String IPv4Forwarding; - - @JsonProperty("IndexServerAddress") - private String IndexServerAddress; - - - @JsonProperty("InitPath") - private String initPath; - - @JsonProperty("InitSha1") - private String initSha1; - - @JsonProperty("KernelVersion") - private String kernelVersion; - - @JsonProperty("LXCVersion") - private String lxcVersion; - - @JsonProperty("MemoryLimit") - private boolean memoryLimit; - - @JsonProperty("NEventsListener") - private long nEventListener; - - @JsonProperty("NFd") - private int NFd; - - @JsonProperty("NGoroutines") - private int NGoroutines; - - @JsonProperty("SwapLimit") - private int swapLimit; - - public boolean isDebug() { - return debug; - } - - public void setDebug(boolean debug) { - this.debug = debug; - } - - public int getContainers() { - return containers; - } - - public void setContainers(int containers) { - this.containers = containers; - } - - public String getDriver() { - return driver; - } - - public void setDriver(String driver) { - this.driver = driver; - } - - public List getDriverStatuses() { - return driverStatuses; - } - - public void setDriverStatuses(List driverStatuses) { - this.driverStatuses = driverStatuses; - } - - public int getImages() { - return images; - } - - public void setImages(int images) { - this.images = images; - } - - public String getIPv4Forwarding() { - return IPv4Forwarding; - } - - public void setIPv4Forwarding(String IPv4Forwarding) { - this.IPv4Forwarding = IPv4Forwarding; - } - - public String getIndexServerAddress() { - return IndexServerAddress; - } - - public void setIndexServerAddress(String indexServerAddress) { - IndexServerAddress = indexServerAddress; - } - - public String getInitPath() { - return initPath; - } - - public void setInitPath(String initPath) { - this.initPath = initPath; - } - - public String getInitSha1() { - return initSha1; - } - - public void setInitSha1(String initSha1) { - this.initSha1 = initSha1; - } - - public String getKernelVersion() { - return kernelVersion; - } - - public void setKernelVersion(String kernelVersion) { - this.kernelVersion = kernelVersion; - } - - public String getLxcVersion() { - return lxcVersion; - } - - public void setLxcVersion(String lxcVersion) { - this.lxcVersion = lxcVersion; - } - - public boolean isMemoryLimit() { - return memoryLimit; - } - - public void setMemoryLimit(boolean memoryLimit) { - this.memoryLimit = memoryLimit; - } - - public long getnEventListener() { - return nEventListener; - } - - public void setnEventListener(long nEventListener) { - this.nEventListener = nEventListener; - } - - public int getNFd() { - return NFd; - } - - public void setNFd(int NFd) { - this.NFd = NFd; - } - - public int getNGoroutines() { - return NGoroutines; - } - - public void setNGoroutines(int NGoroutines) { - this.NGoroutines = NGoroutines; - } - - public int getSwapLimit() { - return swapLimit; - } - - public void setSwapLimit(int swapLimit) { - this.swapLimit = swapLimit; - } - - @Override - public String toString() { - return "Info{" + - "debug=" + debug + - ", containers=" + containers + - ", driver='" + driver + '\'' + - ", driverStatuses=" + driverStatuses + - ", images=" + images + - ", IPv4Forwarding='" + IPv4Forwarding + '\'' + - ", IndexServerAddress='" + IndexServerAddress + '\'' + - ", initPath='" + initPath + '\'' + - ", initSha1='" + initSha1 + '\'' + - ", kernelVersion='" + kernelVersion + '\'' + - ", lxcVersion='" + lxcVersion + '\'' + - ", memoryLimit=" + memoryLimit + - ", nEventListener=" + nEventListener + - ", NFd=" + NFd + - ", NGoroutines=" + NGoroutines + - ", swapLimit=" + swapLimit + - '}'; - } -} +package com.kpelykh.docker.client.model; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import java.util.List; + +/** + * + * @author Konstantin Pelykh (kpelykh@gmail.com) + * + */ +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +public class Info { + + @JsonProperty("Debug") + private boolean debug; + + @JsonProperty("Containers") + private int containers; + + @JsonProperty("Driver") + private String driver; + + @JsonProperty("DriverStatus") + private List driverStatuses; + + + @JsonProperty("Images") + private int images; + + @JsonProperty("IPv4Forwarding") + private String IPv4Forwarding; + + @JsonProperty("IndexServerAddress") + private String IndexServerAddress; + + + @JsonProperty("InitPath") + private String initPath; + + @JsonProperty("InitSha1") + private String initSha1; + + @JsonProperty("KernelVersion") + private String kernelVersion; + + @JsonProperty("LXCVersion") + private String lxcVersion; + + @JsonProperty("MemoryLimit") + private boolean memoryLimit; + + @JsonProperty("NEventsListener") + private long nEventListener; + + @JsonProperty("NFd") + private int NFd; + + @JsonProperty("NGoroutines") + private int NGoroutines; + + @JsonProperty("SwapLimit") + private int swapLimit; + + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public int getContainers() { + return containers; + } + + public void setContainers(int containers) { + this.containers = containers; + } + + public String getDriver() { + return driver; + } + + public void setDriver(String driver) { + this.driver = driver; + } + + public List getDriverStatuses() { + return driverStatuses; + } + + public void setDriverStatuses(List driverStatuses) { + this.driverStatuses = driverStatuses; + } + + public int getImages() { + return images; + } + + public void setImages(int images) { + this.images = images; + } + + public String getIPv4Forwarding() { + return IPv4Forwarding; + } + + public void setIPv4Forwarding(String IPv4Forwarding) { + this.IPv4Forwarding = IPv4Forwarding; + } + + public String getIndexServerAddress() { + return IndexServerAddress; + } + + public void setIndexServerAddress(String indexServerAddress) { + IndexServerAddress = indexServerAddress; + } + + public String getInitPath() { + return initPath; + } + + public void setInitPath(String initPath) { + this.initPath = initPath; + } + + public String getInitSha1() { + return initSha1; + } + + public void setInitSha1(String initSha1) { + this.initSha1 = initSha1; + } + + public String getKernelVersion() { + return kernelVersion; + } + + public void setKernelVersion(String kernelVersion) { + this.kernelVersion = kernelVersion; + } + + public String getLxcVersion() { + return lxcVersion; + } + + public void setLxcVersion(String lxcVersion) { + this.lxcVersion = lxcVersion; + } + + public boolean isMemoryLimit() { + return memoryLimit; + } + + public void setMemoryLimit(boolean memoryLimit) { + this.memoryLimit = memoryLimit; + } + + public long getnEventListener() { + return nEventListener; + } + + public void setnEventListener(long nEventListener) { + this.nEventListener = nEventListener; + } + + public int getNFd() { + return NFd; + } + + public void setNFd(int NFd) { + this.NFd = NFd; + } + + public int getNGoroutines() { + return NGoroutines; + } + + public void setNGoroutines(int NGoroutines) { + this.NGoroutines = NGoroutines; + } + + public int getSwapLimit() { + return swapLimit; + } + + public void setSwapLimit(int swapLimit) { + this.swapLimit = swapLimit; + } + + @Override + public String toString() { + return "Info{" + + "debug=" + debug + + ", containers=" + containers + + ", driver='" + driver + '\'' + + ", driverStatuses=" + driverStatuses + + ", images=" + images + + ", IPv4Forwarding='" + IPv4Forwarding + '\'' + + ", IndexServerAddress='" + IndexServerAddress + '\'' + + ", initPath='" + initPath + '\'' + + ", initSha1='" + initSha1 + '\'' + + ", kernelVersion='" + kernelVersion + '\'' + + ", lxcVersion='" + lxcVersion + '\'' + + ", memoryLimit=" + memoryLimit + + ", nEventListener=" + nEventListener + + ", NFd=" + NFd + + ", NGoroutines=" + NGoroutines + + ", swapLimit=" + swapLimit + + '}'; + } +} diff --git a/src/main/java/com/kpelykh/docker/client/model/Ports.java b/src/main/java/com/kpelykh/docker/client/model/Ports.java index d9fdab60..74842025 100644 --- a/src/main/java/com/kpelykh/docker/client/model/Ports.java +++ b/src/main/java/com/kpelykh/docker/client/model/Ports.java @@ -1,131 +1,131 @@ -package com.kpelykh.docker.client.model; - -import org.codehaus.jackson.*; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.node.NullNode; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * Created by ben on 16/12/13. - */ -@JsonDeserialize(using=Ports.Deserializer.class) -@JsonSerialize(using=Ports.Serializer.class) -public class Ports { - - - private final Map ports = new HashMap(); - - public Ports() { } - - public void addPort(Port port) { - ports.put(port.getPort(), port); - } - - @Override - public String toString(){ - return ports.toString(); - } - - public Map getAllPorts(){ - return ports; - } - - public static class Port{ - - private final String scheme; - private final String port; - private final String hostIp; - private final String hostPort; - - public Port(String scheme_, String port_, String hostIp_, String hostPort_) { - scheme = scheme_; - port = port_; - hostIp = hostIp_; - hostPort = hostPort_; - } - - public String getScheme() { - return scheme; - } - - public String getPort() { - return port; - } - - public String getHostIp() { - return hostIp; - } - - public String getHostPort() { - return hostPort; - } - - public static Port makePort(String full, String hostIp, String hostPort) { - if (full == null) return null; - String[] pieces = full.split("/"); - return new Port(pieces[1], pieces[0], hostIp, hostPort); - } - - @Override - public String toString() { - return "Port{" + - "scheme='" + scheme + '\'' + - ", port='" + port + '\'' + - ", hostIp='" + hostIp + '\'' + - ", hostPort='" + hostPort + '\'' + - '}'; - } - } - - public static class Deserializer extends JsonDeserializer { - @Override - public Ports deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { - - Ports out = new Ports(); - ObjectCodec oc = jsonParser.getCodec(); - JsonNode node = oc.readTree(jsonParser); - for (Iterator> it = node.getFields(); it.hasNext();) { - - Map.Entry field = it.next(); - if (!field.getValue().equals(NullNode.getInstance())) { - String hostIp = field.getValue().get(0).get("HostIp").getTextValue(); - String hostPort = field.getValue().get(0).get("HostPort").getTextValue(); - out.addPort(Port.makePort(field.getKey(), hostIp, hostPort)); - } - } - return out; - } - } - - public static class Serializer extends JsonSerializer { - - @Override - public void serialize(Ports ports, JsonGenerator jsonGen, - SerializerProvider serProvider) throws IOException, JsonProcessingException { - - jsonGen.writeStartObject();//{ - for(String portKey : ports.getAllPorts().keySet()){ - Port p = ports.getAllPorts().get(portKey); - jsonGen.writeFieldName(p.getPort() + "/" + p.getScheme()); - jsonGen.writeStartArray(); - jsonGen.writeStartObject(); - jsonGen.writeStringField("HostIp", p.hostIp); - jsonGen.writeStringField("HostPort", p.hostPort); - jsonGen.writeEndObject(); - jsonGen.writeEndArray(); - } - jsonGen.writeEndObject();//} - } - - } - -} \ No newline at end of file +package com.kpelykh.docker.client.model; + +import org.codehaus.jackson.*; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.node.NullNode; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * Created by ben on 16/12/13. + */ +@JsonDeserialize(using=Ports.Deserializer.class) +@JsonSerialize(using=Ports.Serializer.class) +public class Ports { + + + private final Map ports = new HashMap(); + + public Ports() { } + + public void addPort(Port port) { + ports.put(port.getPort(), port); + } + + @Override + public String toString(){ + return ports.toString(); + } + + public Map getAllPorts(){ + return ports; + } + + public static class Port{ + + private final String scheme; + private final String port; + private final String hostIp; + private final String hostPort; + + public Port(String scheme_, String port_, String hostIp_, String hostPort_) { + scheme = scheme_; + port = port_; + hostIp = hostIp_; + hostPort = hostPort_; + } + + public String getScheme() { + return scheme; + } + + public String getPort() { + return port; + } + + public String getHostIp() { + return hostIp; + } + + public String getHostPort() { + return hostPort; + } + + public static Port makePort(String full, String hostIp, String hostPort) { + if (full == null) return null; + String[] pieces = full.split("/"); + return new Port(pieces[1], pieces[0], hostIp, hostPort); + } + + @Override + public String toString() { + return "Port{" + + "scheme='" + scheme + '\'' + + ", port='" + port + '\'' + + ", hostIp='" + hostIp + '\'' + + ", hostPort='" + hostPort + '\'' + + '}'; + } + } + + public static class Deserializer extends JsonDeserializer { + @Override + public Ports deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { + + Ports out = new Ports(); + ObjectCodec oc = jsonParser.getCodec(); + JsonNode node = oc.readTree(jsonParser); + for (Iterator> it = node.getFields(); it.hasNext();) { + + Map.Entry field = it.next(); + if (!field.getValue().equals(NullNode.getInstance())) { + String hostIp = field.getValue().get(0).get("HostIp").getTextValue(); + String hostPort = field.getValue().get(0).get("HostPort").getTextValue(); + out.addPort(Port.makePort(field.getKey(), hostIp, hostPort)); + } + } + return out; + } + } + + public static class Serializer extends JsonSerializer { + + @Override + public void serialize(Ports ports, JsonGenerator jsonGen, + SerializerProvider serProvider) throws IOException, JsonProcessingException { + + jsonGen.writeStartObject();//{ + for(String portKey : ports.getAllPorts().keySet()){ + Port p = ports.getAllPorts().get(portKey); + jsonGen.writeFieldName(p.getPort() + "/" + p.getScheme()); + jsonGen.writeStartArray(); + jsonGen.writeStartObject(); + jsonGen.writeStringField("HostIp", p.hostIp); + jsonGen.writeStringField("HostPort", p.hostPort); + jsonGen.writeEndObject(); + jsonGen.writeEndArray(); + } + jsonGen.writeEndObject();//} + } + + } + +} diff --git a/src/main/java/com/kpelykh/docker/client/model/Version.java b/src/main/java/com/kpelykh/docker/client/model/Version.java index 915ae67e..b8f35f16 100644 --- a/src/main/java/com/kpelykh/docker/client/model/Version.java +++ b/src/main/java/com/kpelykh/docker/client/model/Version.java @@ -1,91 +1,91 @@ -package com.kpelykh.docker.client.model; - -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * - * @author Konstantin Pelykh (kpelykh@gmail.com) - * - */ -public class Version { - - - @JsonProperty("Version") - private String version; - - @JsonProperty("GitCommit") - private String gitCommit; - - @JsonProperty("GoVersion") - private String goVersion; - - @JsonProperty("KernelVersion") - private String kernelVersion; - - @JsonProperty("Arch") - private String arch; - - @JsonProperty("Os") - private String operatingSystem; - - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getGitCommit() { - return gitCommit; - } - - public void setGitCommit(String gitCommit) { - this.gitCommit = gitCommit; - } - - public String getGoVersion() { - return goVersion; - } - - public void setGoVersion(String goVersion) { - this.goVersion = goVersion; - } - - public String getKernelVersion() { - return kernelVersion; - } - - public void setKernelVersion(String kernelVersion) { - this.kernelVersion = kernelVersion; - } - - public String getArch() { - return arch; - } - - public void setArch(String arch) { - this.arch = arch; - } - - public String getOperatingSystem() { - return operatingSystem; - } - - public void setOperatingSystem(String operatingSystem) { - this.operatingSystem = operatingSystem; - } - - @Override - public String toString() { - return "Version{" + - "version='" + version + '\'' + - ", gitCommit='" + gitCommit + '\'' + - ", goVersion='" + goVersion + '\'' + - ", kernelVersion='" + kernelVersion + '\'' + - ", arch='" + arch + '\'' + - ", operatingSystem='" + operatingSystem + '\'' + - '}'; - } -} +package com.kpelykh.docker.client.model; + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Konstantin Pelykh (kpelykh@gmail.com) + * + */ +public class Version { + + + @JsonProperty("Version") + private String version; + + @JsonProperty("GitCommit") + private String gitCommit; + + @JsonProperty("GoVersion") + private String goVersion; + + @JsonProperty("KernelVersion") + private String kernelVersion; + + @JsonProperty("Arch") + private String arch; + + @JsonProperty("Os") + private String operatingSystem; + + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getGitCommit() { + return gitCommit; + } + + public void setGitCommit(String gitCommit) { + this.gitCommit = gitCommit; + } + + public String getGoVersion() { + return goVersion; + } + + public void setGoVersion(String goVersion) { + this.goVersion = goVersion; + } + + public String getKernelVersion() { + return kernelVersion; + } + + public void setKernelVersion(String kernelVersion) { + this.kernelVersion = kernelVersion; + } + + public String getArch() { + return arch; + } + + public void setArch(String arch) { + this.arch = arch; + } + + public String getOperatingSystem() { + return operatingSystem; + } + + public void setOperatingSystem(String operatingSystem) { + this.operatingSystem = operatingSystem; + } + + @Override + public String toString() { + return "Version{" + + "version='" + version + '\'' + + ", gitCommit='" + gitCommit + '\'' + + ", goVersion='" + goVersion + '\'' + + ", kernelVersion='" + kernelVersion + '\'' + + ", arch='" + arch + '\'' + + ", operatingSystem='" + operatingSystem + '\'' + + '}'; + } +} diff --git a/src/test/java/com/kpelykh/docker/client/test/DockerClientAVTest.java b/src/test/java/com/kpelykh/docker/client/test/DockerClientAVTest.java new file mode 100644 index 00000000..e9e4cc14 --- /dev/null +++ b/src/test/java/com/kpelykh/docker/client/test/DockerClientAVTest.java @@ -0,0 +1,59 @@ +package com.kpelykh.docker.client.test; + +import java.lang.reflect.Method; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.kpelykh.docker.client.DockerClient; +import com.kpelykh.docker.client.DockerException; +import com.kpelykh.docker.client.model.ContainerInspectResponse; +import com.sun.jersey.json.impl.JSONHelper; + + +public class DockerClientAVTest extends Assert { + + public static final Logger LOG = LoggerFactory + .getLogger(DockerClientAVTest.class); + + private DockerClient dockerClient; + + @BeforeTest + public void beforeTest() throws DockerException { + LOG.info("======================= BEFORETEST ======================="); + LOG.info("Connecting to Docker server at http://54.235.65.32:4243"); + dockerClient = new DockerClient("http://54.235.65.32:4243"); + + assertNotNull(dockerClient); + LOG.info("======================= END OF BEFORETEST =======================\n\n"); + } + + @AfterTest + public void afterTest() { + LOG.info("======================= END OF AFTERTEST ======================="); + } + + @BeforeMethod + public void beforeMethod(Method method) { + LOG.info(String + .format("################################## STARTING %s ##################################", + method.getName())); + } + + + @Test + public void testInspectContainer() throws DockerException { + + ContainerInspectResponse cntResp = dockerClient.inspectContainer("913bfa3c4bde"); + System.out.println("container response ====> " + cntResp.toString()); + System.out.println("NetworkSettings Ports info: " + cntResp.getNetworkSettings().ports.toString()); + System.out.println("HostConfig Ports info: " + cntResp.getHostConfig().getPortBindings().toString()); + + } + +} diff --git a/src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java b/src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java index 06656efa..0367b78f 100644 --- a/src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java +++ b/src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java @@ -774,4 +774,4 @@ private void dockerfileBuild(File baseDir, String expectedText) throws DockerExc assertThat(logwriter2.toString(), endsWith(expectedText)); } -} \ No newline at end of file +}