use of org.eclipse.linuxtools.docker.core.IDockerNetworkSettings in project linuxtools by eclipse.
the class ContainerInspectContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
final Object propertyValue = ((Object[]) parentElement)[1];
if (propertyValue instanceof IDockerContainerState) {
final IDockerContainerState containerState = (IDockerContainerState) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "ExitCode", containerState.exitCode() }, // $NON-NLS-1$
new Object[] { "Finished at", LabelProviderUtils.toFinishedDate(containerState.finishDate()) }, // $NON-NLS-1$
new Object[] { "Running", containerState.running() }, // $NON-NLS-1$
new Object[] { "Paused", containerState.paused() }, // $NON-NLS-1$
new Object[] { "Pid", containerState.pid() } };
} else if (propertyValue instanceof IDockerHostConfig) {
final DockerHostConfig hostConfig = (DockerHostConfig) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "Binds", LabelProviderUtils.reduce(hostConfig.binds()) }, // $NON-NLS-1$
new Object[] { "CapAdd", hostConfig.capAdd() }, // $NON-NLS-1$
new Object[] { "CapDrop", hostConfig.capDrop() }, // $NON-NLS-1$
new Object[] { "ContainerIDFile", hostConfig.containerIDFile() }, // $NON-NLS-1$
new Object[] { "Dns", LabelProviderUtils.reduce(hostConfig.dns()) }, // $NON-NLS-1$
new Object[] { "DnsSearch", LabelProviderUtils.reduce(hostConfig.dnsSearch()) }, // $NON-NLS-1$
new Object[] { "Links", splitLinks(hostConfig.links()) }, // $NON-NLS-1$
new Object[] { "LxcConf", hostConfig.lxcConf() }, // $NON-NLS-1$
new Object[] { "NetworkMode", hostConfig.networkMode() }, // $NON-NLS-1$
new Object[] { "PortBindings", LabelProviderUtils.reduce(hostConfig.portBindings()) }, // $NON-NLS-1$
new Object[] { "Privileged", hostConfig.privileged() }, // $NON-NLS-1$
new Object[] { "PublishAllPorts", hostConfig.publishAllPorts() }, new Object[] { // $NON-NLS-1$
"ReadonlyRootfs", hostConfig.readonlyRootfs() }, // $NON-NLS-1$
new Object[] { "SecurityOpt", hostConfig.securityOpt() }, // $NON-NLS-1$
new Object[] { "Tmpfs", hostConfig.tmpfs() }, // $NON-NLS-1$
new Object[] { "VolumesFrom", LabelProviderUtils.reduce(hostConfig.volumesFrom()) } };
} else if (propertyValue instanceof IDockerContainerConfig) {
final IDockerContainerConfig config = (IDockerContainerConfig) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "AttachStderr", config.attachStderr() }, // $NON-NLS-1$
new Object[] { "AttachStdin", config.attachStdin() }, // $NON-NLS-1$
new Object[] { "AttachStdout", config.attachStdout() }, // $NON-NLS-1$
new Object[] { "Cmd", LabelProviderUtils.reduce(config.cmd()) }, // $NON-NLS-1$
new Object[] { "CpuSet", config.cpuset() }, // $NON-NLS-1$
new Object[] { "CpuShares", config.cpuShares() }, // $NON-NLS-1$
new Object[] { "Domainname", config.domainname() }, // $NON-NLS-1$
new Object[] { "Entrypoint", LabelProviderUtils.reduce(config.entrypoint()) }, // $NON-NLS-1$
new Object[] { "Env", LabelProviderUtils.reduce(config.env()) }, // $NON-NLS-1$
new Object[] { "ExposedPorts", LabelProviderUtils.reduce(config.exposedPorts()) }, // $NON-NLS-1$
new Object[] { "Hostname", config.hostname() }, // $NON-NLS-1$
new Object[] { "Image", config.image() }, new Object[] { // $NON-NLS-1$
"Labels", ((DockerContainerConfig) config).labels() }, // $NON-NLS-1$
new Object[] { "Memory", config.memory() }, // $NON-NLS-1$
new Object[] { "MemorySwap", config.memorySwap() }, // $NON-NLS-1$
new Object[] { "NetworkDisabled", config.networkDisabled() }, // $NON-NLS-1$
new Object[] { "OnBuild", config.onBuild() }, // $NON-NLS-1$
new Object[] { "OpenStdin", config.openStdin() }, // $NON-NLS-1$
new Object[] { "PortSpecs", LabelProviderUtils.reduce(config.portSpecs()) }, // $NON-NLS-1$
new Object[] { "StdinOnce", config.stdinOnce() }, // $NON-NLS-1$
new Object[] { "Tty", config.tty() }, new Object[] { // $NON-NLS-1$
"Volumes", LabelProviderUtils.reduce(config.volumes().keySet()) }, // $NON-NLS-1$
new Object[] { "WorkingDir", config.workingDir() } };
} else if (propertyValue instanceof IDockerPortBinding) {
final IDockerPortBinding portBinding = (IDockerPortBinding) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "Host IP/Port", LabelProviderUtils.toString(portBinding) } };
} else if (propertyValue instanceof IDockerNetworkSettings) {
final IDockerNetworkSettings networkSettings = (IDockerNetworkSettings) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "Bridge", networkSettings.bridge() }, // $NON-NLS-1$
new Object[] { "Gateway", networkSettings.gateway() }, // $NON-NLS-1$
new Object[] { "IPAddress", networkSettings.ipAddress() }, // $NON-NLS-1$
new Object[] { "IPPrefixLen", networkSettings.ipPrefixLen() }, // $NON-NLS-1$
new Object[] { "PortMapping", networkSettings.portMapping() }, // $NON-NLS-1$
new Object[] { "Ports", LabelProviderUtils.reduce(networkSettings.ports()) } };
} else if (propertyValue instanceof List<?>) {
@SuppressWarnings("unchecked") final List<Object> propertyValues = (List<Object>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
for (int i = 0; i < propertyValues.size(); i++) {
// $NON-NLS-1$
result[i] = new Object[] { "", LabelProviderUtils.toString(propertyValues.get(i)) };
}
return result;
} else if (propertyValue instanceof Set<?>) {
@SuppressWarnings("unchecked") final Set<Object> propertyValues = (Set<Object>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
Iterator<Object> iterator = propertyValues.iterator();
for (int i = 0; i < propertyValues.size(); i++) {
result[i] = new Object[] { // $NON-NLS-1$
"", LabelProviderUtils.toString(iterator.next()) };
}
return result;
} else if (propertyValue instanceof Map<?, ?>) {
final Map<?, ?> propertyValues = (Map<?, ?>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
int i = 0;
for (Entry<?, ?> entry : propertyValues.entrySet()) {
result[i] = new Object[] { entry.getKey(), entry.getValue() };
i++;
}
return result;
}
return EMPTY;
}
use of org.eclipse.linuxtools.docker.core.IDockerNetworkSettings in project linuxtools by eclipse.
the class DockerExplorerContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parentElement) {
if (parentElement instanceof IDockerConnection) {
// check the connection availability before returning the
// 'containers' and 'images' child nodes.
final IDockerConnection connection = (IDockerConnection) parentElement;
if (connection.isOpen()) {
return new Object[] { new DockerImagesCategory(connection), new DockerContainersCategory(connection) };
} else if (connection.getState() == EnumDockerConnectionState.UNKNOWN) {
open(connection);
return new Object[] { new LoadingStub(connection) };
} else if (connection.getState() == EnumDockerConnectionState.CLOSED) {
synchronized (openRetryJobs) {
Job job = openRetryJobs.get(connection);
if (job == null) {
openRetry(connection);
}
}
return new Object[] { new LoadingStub(connection) };
}
return new Object[0];
} else if (parentElement instanceof DockerContainersCategory) {
final DockerContainersCategory containersCategory = (DockerContainersCategory) parentElement;
final IDockerConnection connection = containersCategory.getConnection();
if (connection.isContainersLoaded()) {
return connection.getContainers().toArray();
}
loadContainers(containersCategory);
return new Object[] { new LoadingStub(containersCategory) };
} else if (parentElement instanceof DockerImagesCategory) {
final DockerImagesCategory imagesCategory = (DockerImagesCategory) parentElement;
final IDockerConnection connection = imagesCategory.getConnection();
if (connection.isImagesLoaded()) {
// here we duplicate the images to show one org/repo with all
// its tags per node in the tree
final List<IDockerImage> allImages = connection.getImages();
final List<IDockerImage> explorerImages = splitImageTagsByRepo(allImages);
return explorerImages.toArray();
}
loadImages(imagesCategory);
return new Object[] { new LoadingStub(imagesCategory) };
} else if (parentElement instanceof IDockerContainer) {
final DockerContainer container = (DockerContainer) parentElement;
if (container.isInfoLoaded()) {
final IDockerContainerInfo info = container.info();
final IDockerNetworkSettings networkSettings = (info != null) ? info.networkSettings() : null;
final IDockerHostConfig hostConfig = (info != null) ? info.hostConfig() : null;
return new Object[] { new DockerContainerPortMappingsCategory(container, (networkSettings != null) ? networkSettings.ports() : Collections.<String, List<IDockerPortBinding>>emptyMap()), new DockerContainerVolumesCategory(container, (hostConfig != null) ? hostConfig.binds() : Collections.<String>emptyList()), new DockerContainerLinksCategory(container, (hostConfig != null) ? hostConfig.links() : Collections.<String>emptyList()) };
}
loadContainerInfo(container);
return new Object[] { new LoadingStub(container) };
} else if (parentElement instanceof DockerContainerLinksCategory) {
final DockerContainerLinksCategory linksCategory = (DockerContainerLinksCategory) parentElement;
return linksCategory.getLinks().toArray();
} else if (parentElement instanceof DockerContainerPortMappingsCategory) {
final DockerContainerPortMappingsCategory portMappingsCategory = (DockerContainerPortMappingsCategory) parentElement;
return portMappingsCategory.getPortMappings().toArray();
} else if (parentElement instanceof DockerContainerVolumesCategory) {
final DockerContainerVolumesCategory volumesCategory = (DockerContainerVolumesCategory) parentElement;
return volumesCategory.getVolumes().toArray();
}
return EMPTY;
}
Aggregations