.put(SubnetTier.SUBNET_CIDR, Cidr.CLASS_B)
.build();
try {
// Create a new container using jclouds Docker driver
JcloudsSshMachineLocation container = host.getJcloudsLocation().obtain(dockerFlags);
setAttribute(CONTAINER_ID, container.getNode().getId());
// If Weave is enabled, attach to the network
if (getConfig(DockerInfrastructure.WEAVE_ENABLED)) {
WeaveContainer weave = Entities.attributeSupplierWhenReady(dockerHost, WeaveContainer.WEAVE_CONTAINER).get();
InetAddress subnetAddress = weave.attachNetwork(getAttribute(CONTAINER_ID));
setAttribute(Attributes.SUBNET_ADDRESS, subnetAddress.getHostAddress());
}
// Create our wrapper location around the container
LocationSpec<DockerContainerLocation> spec = LocationSpec.create(DockerContainerLocation.class)
.parent(host)
.configure(flags)
.configure(DynamicLocation.OWNER, this)
.configure("machine", container) // the underlying JcloudsLocation
.configure(container.getAllConfig(true))
.displayName(getDockerContainerName());
DockerContainerLocation location = getManagementContext().getLocationManager().createLocation(spec);
setAttribute(DYNAMIC_LOCATION, location);
setAttribute(LOCATION_NAME, location.getId());