public Builder toBuilder() { return builder().fromNetworkSettings(this); }
public NetworkSettings build() { return NetworkSettings.create(bridge, sandboxId, hairpinMode, linkLocalIPv6Address, linkLocalIPv6PrefixLen, ports, sandboxKey, secondaryIPAddresses, secondaryIPv6Addresses, endpointId, gateway, globalIPv6Address, globalIPv6PrefixLen, ipAddress, ipPrefixLen, ipv6Gateway, macAddress, networks, portMapping); }
public Builder fromNetworkSettings(NetworkSettings in) { return this.ipAddress(in.ipAddress()).ipPrefixLen(in.ipPrefixLen()).gateway(in.gateway()).bridge(in.bridge()) .portMapping(in.portMapping()).ports(in.ports()).sandboxId(in.sandboxId()).hairpinMode(in.hairpinMode()).linkLocalIPv6Address(in .linkLocalIPv6Address()).linkLocalIPv6PrefixLen(in.linkLocalIPv6PrefixLen()).sandboxKey(in.sandboxKey()).secondaryIPAddresses(in .secondaryIPAddresses()).secondaryIPv6Addresses(in.secondaryIPv6Addresses()).endpointId(in.endpointId()).globalIPv6Address(in .globalIPv6Address()).globalIPv6PrefixLen(in.globalIPv6PrefixLen()).ipv6Gateway(in.ipv6Gateway()).macAddress(in.macAddress()) .networks(in.networks()); } }
private Iterable<String> getPrivateIpAddresses(Container container) { // A container can be attached to multiple networks. It can therefore have multiple private // IPs. The NetworkSettings.ipAddress might in fact be blank, with the only IP being on // network objects. if (container.networkSettings() == null) return ImmutableList.of(); ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder(); NetworkSettings settings = container.networkSettings(); if (settings.ipAddress() != null && settings.ipAddress().length() > 0) { builder.add(settings.ipAddress()); } if (settings.networks() != null) { for (Map.Entry<String, NetworkSettings.Details> entry : settings.networks().entrySet()) { String ipAddress = entry.getValue().ipAddress(); if (ipAddress != null && ipAddress.length() > 0) { builder.add(ipAddress); } } } return builder.build(); }
@Override public Optional<Integer> apply(Container container) { if (container.networkSettings() != null) { Map<String, List<Map<String, String>>> ports = container.networkSettings().ports(); if (ports != null && ports.containsKey(containerPort + "/tcp")) { return Optional.of(Integer.parseInt(getOnlyElement(ports.get(containerPort + "/tcp")).get("HostPort"))); } // this is needed in case the container list is coming from // listContainers } else if (container.ports() != null) { for (Port port : container.ports()) { if (port.privatePort() == containerPort) { return Optional.of(port.publicPort()); } } } return Optional.absent(); }
public void testCreateNodeWithMultipleNetworks() { String name = "container" + new Random().nextInt(); Template template = templateBuilder.imageId(defaultImage.id()).build(); DockerTemplateOptions options = template.getOptions().as(DockerTemplateOptions.class); options.env(ImmutableList.of("ROOT_PASSWORD=password")); options.networkMode("bridge"); options.networks(network1.name(), network2.name()); guest = adapter.createNodeWithGroupEncodedIntoName("test", name, template); assertTrue(guest.getNode().networkSettings().networks().containsKey("network1")); assertTrue(guest.getNode().networkSettings().networks().containsKey("network2")); assertEquals(guest.getNode().networkSettings().networks().size(), 3); }
private Iterable<String> getPrivateIpAddresses(Container container) { // A container can be attached to multiple networks. It can therefore have multiple private // IPs. The NetworkSettings.ipAddress might in fact be blank, with the only IP being on // network objects. if (container.networkSettings() == null) return ImmutableList.of(); ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder(); NetworkSettings settings = container.networkSettings(); if (settings.ipAddress() != null && settings.ipAddress().length() > 0) { builder.add(settings.ipAddress()); } if (settings.networks() != null) { for (Map.Entry<String, NetworkSettings.Details> entry : settings.networks().entrySet()) { String ipAddress = entry.getValue().ipAddress(); if (ipAddress != null && ipAddress.length() > 0) { builder.add(ipAddress); } } } return builder.build(); }
@Override public Optional<Integer> apply(Container container) { if (container.networkSettings() != null) { Map<String, List<Map<String, String>>> ports = container.networkSettings().ports(); if (ports != null && ports.containsKey(containerPort + "/tcp")) { return Optional.of(Integer.parseInt(getOnlyElement(ports.get(containerPort + "/tcp")).get("HostPort"))); } // this is needed in case the container list is coming from // listContainers } else if (container.ports() != null) { for (Port port : container.ports()) { if (port.privatePort() == containerPort) { return Optional.of(port.publicPort()); } } } return Optional.absent(); }
@Test(dependsOnMethods = "testAttachContainerToNetwork") public void testDisconnectContainerFromNetwork() { api().disconnectContainerFromNetwork(network.id(), container.id()); container = api.getContainerApi().inspectContainer(container.id()); assertFalse(Iterables.any(container.networkSettings().networks().keySet(), Predicates.equalTo(network.name()))); }
public Builder fromNetworkSettings(NetworkSettings in) { return this.ipAddress(in.ipAddress()).ipPrefixLen(in.ipPrefixLen()).gateway(in.gateway()).bridge(in.bridge()) .portMapping(in.portMapping()).ports(in.ports()).sandboxId(in.sandboxId()).hairpinMode(in.hairpinMode()).linkLocalIPv6Address(in .linkLocalIPv6Address()).linkLocalIPv6PrefixLen(in.linkLocalIPv6PrefixLen()).sandboxKey(in.sandboxKey()).secondaryIPAddresses(in .secondaryIPAddresses()).secondaryIPv6Addresses(in.secondaryIPv6Addresses()).endpointId(in.endpointId()).globalIPv6Address(in .globalIPv6Address()).globalIPv6PrefixLen(in.globalIPv6PrefixLen()).ipv6Gateway(in.ipv6Gateway()).macAddress(in.macAddress()) .networks(in.networks()); } }
private Iterable<String> getPrivateIpAddresses(Container container) { // A container can be attached to multiple networks. It can therefore have multiple private // IPs. The NetworkSettings.ipAddress might in fact be blank, with the only IP being on // network objects. if (container.networkSettings() == null) return ImmutableList.of(); ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder(); NetworkSettings settings = container.networkSettings(); if (settings.ipAddress() != null && settings.ipAddress().length() > 0) { builder.add(settings.ipAddress()); } if (settings.networks() != null) { for (Map.Entry<String, NetworkSettings.Details> entry : settings.networks().entrySet()) { String ipAddress = entry.getValue().ipAddress(); if (ipAddress != null && ipAddress.length() > 0) { builder.add(ipAddress); } } } return builder.build(); }
public Builder toBuilder() { return builder().fromNetworkSettings(this); }
public NetworkSettings build() { return NetworkSettings.create(bridge, sandboxId, hairpinMode, linkLocalIPv6Address, linkLocalIPv6PrefixLen, ports, sandboxKey, secondaryIPAddresses, secondaryIPv6Addresses, endpointId, gateway, globalIPv6Address, globalIPv6PrefixLen, ipAddress, ipPrefixLen, ipv6Gateway, macAddress, networks, portMapping); }
@Override public Optional<Integer> apply(Container container) { if (container.networkSettings() != null) { Map<String, List<Map<String, String>>> ports = container.networkSettings().ports(); if (ports != null && ports.containsKey(containerPort + "/tcp")) { return Optional.of(Integer.parseInt(getOnlyElement(ports.get(containerPort + "/tcp")).get("HostPort"))); } // this is needed in case the container list is coming from // listContainers } else if (container.ports() != null) { for (Port port : container.ports()) { if (port.privatePort() == containerPort) { return Optional.of(port.publicPort()); } } } return Optional.absent(); }
@Test(dependsOnMethods = "testGetNetwork") public void testAttachContainerToNetwork() { api().connectContainerToNetwork(network.id(), container.id()); container = api.getContainerApi().inspectContainer(container.id()); assertTrue(Iterables.any(container.networkSettings().networks().keySet(), Predicates.equalTo(network.name()))); }
public Builder fromNetworkSettings(NetworkSettings in) { return this.ipAddress(in.ipAddress()).ipPrefixLen(in.ipPrefixLen()).gateway(in.gateway()).bridge(in.bridge()) .portMapping(in.portMapping()).ports(in.ports()).sandboxId(in.sandboxId()).hairpinMode(in.hairpinMode()).linkLocalIPv6Address(in .linkLocalIPv6Address()).linkLocalIPv6PrefixLen(in.linkLocalIPv6PrefixLen()).sandboxKey(in.sandboxKey()).secondaryIPAddresses(in .secondaryIPAddresses()).secondaryIPv6Addresses(in.secondaryIPv6Addresses()).endpointId(in.endpointId()).globalIPv6Address(in .globalIPv6Address()).globalIPv6PrefixLen(in.globalIPv6PrefixLen()).ipv6Gateway(in.ipv6Gateway()).macAddress(in.macAddress()) .networks(in.networks()); } }
private Iterable<String> getPrivateIpAddresses(Container container) { // A container can be attached to multiple networks. It can therefore have multiple private // IPs. The NetworkSettings.ipAddress might in fact be blank, with the only IP being on // network objects. if (container.networkSettings() == null) return ImmutableList.of(); ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder(); NetworkSettings settings = container.networkSettings(); if (settings.ipAddress() != null && settings.ipAddress().length() > 0) { builder.add(settings.ipAddress()); } if (settings.networks() != null) { for (Map.Entry<String, NetworkSettings.Details> entry : settings.networks().entrySet()) { String ipAddress = entry.getValue().ipAddress(); if (ipAddress != null && ipAddress.length() > 0) { builder.add(ipAddress); } } } return builder.build(); }
public Builder toBuilder() { return builder().fromNetworkSettings(this); }
public NetworkSettings build() { return NetworkSettings.create(bridge, sandboxId, hairpinMode, linkLocalIPv6Address, linkLocalIPv6PrefixLen, ports, sandboxKey, secondaryIPAddresses, secondaryIPv6Addresses, endpointId, gateway, globalIPv6Address, globalIPv6PrefixLen, ipAddress, ipPrefixLen, ipv6Gateway, macAddress, networks, portMapping); }
@Override public Optional<Integer> apply(Container container) { if (container.networkSettings() != null) { Map<String, List<Map<String, String>>> ports = container.networkSettings().ports(); if (ports != null && ports.containsKey(containerPort + "/tcp")) { return Optional.of(Integer.parseInt(getOnlyElement(ports.get(containerPort + "/tcp")).get("HostPort"))); } // this is needed in case the container list is coming from // listContainers } else if (container.ports() != null) { for (Port port : container.ports()) { if (port.privatePort() == containerPort) { return Optional.of(port.publicPort()); } } } return Optional.absent(); }