use of org.eclipse.linuxtools.docker.core.IDockerNetworkCreation in project linuxtools by eclipse.
the class DockerConnection method createNetwork.
@Override
public IDockerNetworkCreation createNetwork(IDockerNetworkConfig cfg) throws DockerException, InterruptedException {
try {
Ipam.Builder ipamBuilder = Ipam.builder().driver(cfg.ipam().driver());
List<IDockerIpamConfig> ipamCfgs = cfg.ipam().config();
for (IDockerIpamConfig ipamCfg : ipamCfgs) {
ipamBuilder = ipamBuilder.config(ipamCfg.subnet(), ipamCfg.ipRange(), ipamCfg.gateway());
}
Ipam ipam = ipamBuilder.build();
NetworkConfig.Builder networkConfigBuilder = NetworkConfig.builder().name(cfg.name()).driver(cfg.driver()).ipam(ipam);
networkConfigBuilder.options(cfg.options());
NetworkConfig networkConfig = networkConfigBuilder.build();
com.spotify.docker.client.messages.NetworkCreation creation = client.createNetwork(networkConfig);
return new DockerNetworkCreation(creation);
} catch (com.spotify.docker.client.exceptions.DockerException e) {
throw new DockerException(e.getMessage(), e.getCause());
}
}
Aggregations