@Override public void destroyNode(String id) { checkState(cleanupServer.apply(id), "server(%s) still there after deleting!?", id); }
if (containsMetadata(server, JCLOUDS_KP)) { if (novaApi.getKeyPairApi(regionAndId.getRegion()).isPresent()) { RegionAndName regionAndName = RegionAndName.fromRegionAndName(regionAndId.getRegion(), server.getKeyName()); if (containsMetadata(server, JCLOUDS_SG) && secGroupsPresent) { for (final String securityGroupName : ((ServerWithSecurityGroups)server).getSecurityGroupNames()) { for (SecurityGroup securityGroup : novaApi.getSecurityGroupApi(regionAndId.getRegion()).get().list().toList()) {
@Override protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) { for (NodeMetadata deadNode : deadNodes) { cleanupServer.apply(deadNode.getId()); } }
@Override public AtomicReference<NodeMetadata> apply(AtomicReference<NodeAndNovaTemplateOptions> input) { checkState(nodeRunning.apply(input.get().getNodeMetadata()), "node never achieved state running %s", input.get().getNodeMetadata()); NodeMetadata node = input.get().getNodeMetadata().get(); // node's location is a host String regionId = node.getLocation().getParent().getId(); FloatingIPApi floatingIpApi = novaApi.getFloatingIPApi(regionId).get(); Optional<Set<String>> poolNames = input.get().getNovaTemplateOptions().get().getFloatingIpPoolNames(); Optional<FloatingIP> ip = allocateFloatingIPForNode(floatingIpApi, poolNames, node.getId()); if (!ip.isPresent()) { cleanupServer.apply(node.getId()); throw new InsufficientResourcesException("Failed to allocate a FloatingIP for node(" + node.getId() + ")"); } logger.debug(">> adding floatingIp(%s) to node(%s)", ip.get().getIp(), node.getId()); floatingIpApi.addToServer(ip.get().getIp(), node.getProviderId()); input.get().getNodeMetadata().set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.get().getIp())).build()); floatingIpCache.asMap().putIfAbsent(RegionAndId.fromSlashEncoded(node.getId()), ImmutableList.of(ip.get())); return input.get().getNodeMetadata(); }