use of org.eclipse.che.plugin.docker.client.json.network.IpamConfig in project che by eclipse.
the class OpenShiftConnector method inspectNetwork.
@Override
public Network inspectNetwork(InspectNetworkParams params) throws IOException {
String netId = params.getNetworkId();
ServiceList services = openShiftClient.services().inNamespace(this.openShiftCheProjectName).list();
Map<String, ContainerInNetwork> containers = new HashMap<>();
for (Service svc : services.getItems()) {
String selector = svc.getSpec().getSelector().get(OPENSHIFT_DEPLOYMENT_LABEL);
if (selector == null || !selector.startsWith(CHE_OPENSHIFT_RESOURCES_PREFIX)) {
continue;
}
PodList pods = openShiftClient.pods().inNamespace(openShiftCheProjectName).withLabel(OPENSHIFT_DEPLOYMENT_LABEL, selector).list();
for (Pod pod : pods.getItems()) {
String podName = pod.getMetadata().getName();
ContainerInNetwork container = new ContainerInNetwork().withName(podName).withIPv4Address(svc.getSpec().getClusterIP());
String podId = KubernetesStringUtils.getLabelFromContainerID(pod.getMetadata().getLabels().get(CHE_CONTAINER_IDENTIFIER_LABEL_KEY));
if (podId == null) {
continue;
}
containers.put(podId, container);
}
}
List<IpamConfig> ipamConfig = new ArrayList<>();
Ipam ipam = new Ipam().withDriver("bridge").withOptions(Collections.emptyMap()).withConfig(ipamConfig);
return new Network().withName("OpenShift").withId(netId).withContainers(containers).withLabels(Collections.emptyMap()).withOptions(Collections.emptyMap()).withDriver("default").withIPAM(ipam).withScope("local").withInternal(false).withEnableIPv6(false);
}
Aggregations