/** * Terminate a specified node * @param id id of the node */ public void destroyNode(String id){ compute.destroyNode(id); }
private void destroy(ComputeService computeService) { if (nodeElement.getId() != null) { log(String.format("destroy id: %s", nodeElement.getId())); computeService.destroyNode(nodeElement.getId()); } else { log(String.format("destroy group: %s", nodeElement.getGroup())); computeService.destroyNodesMatching(NodePredicates.inGroup(nodeElement.getGroup())); } }
/** * Terminate a specified VM * @param id id of the VM */ public void destroyVM(String id){ compute.destroyNode(id); }
/** * Terminate a specified VM * @param id id of the VM */ public void destroyVM(String id){ novaComputeService.destroyNode(id); }
@Override public void destroyNode(String id) { delegate.destroyNode(id); }
public RuntimeException destroyBadNodesAndPropagate(RunNodesException e) { for (Entry<? extends NodeMetadata, ? extends Throwable> nodeError : e.getNodeErrors().entrySet()) compute.destroyNode(nodeError.getKey().getId()); throw propagate(e); }
@Override protected void doCall(ComputeService computeService, String indent) throws Exception { for (String instanceId : names) { NodeMetadata instance = computeService.getNodeMetadata(instanceId); if (instance == null) { stderr.println(indent+"Cannot terminate instance; could not find "+instanceId); } else { boolean confirmed = confirm(indent, "terminate "+instanceId+" ("+instance+")"); if (confirmed) { computeService.destroyNode(instanceId); } } } } }
@Override public void run() { try{ waitForSsh(getUserName(node), node.getPublicAddresses().iterator().next()); //wait for ssh to be ready postStartupSetup(node); }catch (Exception e){ String msg = String.format("There was problem in setting up machine: %s, this node will be destroyed.",node.getId()); logger.error(msg ,e); computeService.destroyNode(node.getId()); throw new RuntimeException(msg,e); } } }
private void destroyBadNodes(RunNodesException e) { for (Map.Entry<? extends NodeMetadata, ? extends Throwable> nodeError : e.getNodeErrors().entrySet()) { getCloud().getCompute().destroyNode(nodeError.getKey().getId()); } }
protected void releaseNode(String instanceId) { ComputeService computeService = null; try { computeService = JcloudsUtil.findComputeService(getConfigBag()); computeService.destroyNode(instanceId); } finally { /* //don't close, so can re-use... if (computeService != null) { try { computeService.getContext().close(); } catch (Exception e) { LOG.error "Problem closing compute-service's context; continuing...", e } } */ } }
/** * destroy the node, given its id. If it is the only node in a tag set, the dependent resources * will also be destroyed. */ @Override public void destroyNode(String id) { NodeMetadata node = null; try { node = computeService.getNodeMetadata(id); } catch (Exception ex) { LOGGER.error("Error while retrieving node metadata.", ex); } computeService.destroyNode(id); try { for (NodeListener listener : getNodeListeners()) { listener.nodeDestroyed(node); } } catch (Exception ex) { LOGGER.error("Error while notifying node listeners.", ex); } }
@SuppressWarnings("unchecked") public static void kill(String clustername, ComputeService computeService) { int nodesToKill = 0; for (NodeMetadata n : (Set<NodeMetadata>) computeService.listNodes()) { if (n.getStatus() != Status.TERMINATED && n.getGroup() != null && n.getGroup().toLowerCase().equals(clustername.toLowerCase()) && n.getUserMetadata().containsKey("daemons")) { // Destroy now computeService.destroyNode(n.getId()); nodesToKill++; } } log.info("Terminated " + nodesToKill + " nodes"); } }
public void destroyInstance(ClusterSpec clusterSpec, String instanceId) throws IOException { LOG.info("Destroying instance {}", instanceId); /* Destroy the instance */ ComputeService computeService = getCompute().apply(clusterSpec).getComputeService(); computeService.destroyNode(instanceId); /* .. and update the cluster state storage */ ClusterStateStore store = getClusterStateStore(clusterSpec); Cluster cluster = store.load(); cluster.removeInstancesMatching(withIds(instanceId)); store.save(cluster); LOG.info("Instance {} destroyed", instanceId); }
public void destroyInstance(ClusterSpec clusterSpec, String instanceId) throws IOException { LOG.info("Destroying instance {}", instanceId); /* Destroy the instance */ ComputeService computeService = getCompute().apply(clusterSpec).getComputeService(); computeService.destroyNode(instanceId); /* .. and update the cluster state storage */ ClusterStateStore store = getClusterStateStore(clusterSpec); Cluster cluster = store.load(); cluster.removeInstancesMatching(withIds(instanceId)); store.save(cluster); LOG.info("Instance {} destroyed", instanceId); }
@Override public void destroy(Container container) { assertValid(); CreateContainerMetadata metadata = container.getMetadata(); if (!(metadata instanceof CreateJCloudsContainerMetadata)) { throw new IllegalStateException("Container doesn't have valid create container metadata type"); } else { CreateJCloudsContainerMetadata jCloudsContainerMetadata = (CreateJCloudsContainerMetadata) metadata; CreateJCloudsContainerOptions options = jCloudsContainerMetadata.getCreateOptions(); String nodeId = jCloudsContainerMetadata.getNodeId(); ComputeService computeService = getOrCreateComputeService(options); computeService.destroyNode(nodeId); } }
@Override @AfterClass(groups = { "integration", "live" }) protected void tearDown() { try { computeService.destroyNode(serverId); awaitComplete(api, api.getDomainApi().delete(ImmutableList.<Integer> of(domainId), true)); } catch (TimeoutException e) { e.printStackTrace(); } super.tearDown(); } }
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage") public void testSpawnNodeFromImage() throws RunNodesException { ComputeService computeService = view.getComputeService(); Optional<? extends Image> optImage = getImage(); assertTrue(optImage.isPresent()); NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, view .getComputeService() // fromImage does not use the arg image's id (but we do need to set location) .templateBuilder().imageId(optImage.get().getId()).fromImage(optImage.get()).build())); checkReachable(node); view.getComputeService().destroyNode(node.getId()); }
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage") public void testSpawnNodeFromImage() throws RunNodesException { ComputeService computeService = view.getComputeService(); Optional<? extends Image> optImage = getImage(); assertTrue(optImage.isPresent()); NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup(imageGroup, 1, getNodeTemplate() // fromImage does not use the arg image's id (but we do need to set location) .imageId(optImage.get().getId()).fromImage(optImage.get()).build())); checkReachable(node); view.getComputeService().destroyNode(node.getId()); }
@Test(groups = { "integration", "live" }, singleThreaded = true) public void testCreateImage() throws RunNodesException, InterruptedException, ExecutionException { ComputeService computeService = view.getComputeService(); Optional<ImageExtension> imageExtension = computeService.getImageExtension(); assertTrue(imageExtension.isPresent(), "image extension was not present"); Template template = getNodeTemplate(); NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, template)); checkReachable(node); logger.info("Creating image from node %s, started with template: %s", node, template); ImageTemplate newImageTemplate = imageExtension.get().buildImageTemplateFromNode("test-create-image", node.getId()); Image image = imageExtension.get().createImage(newImageTemplate).get(); logger.info("Image created: %s", image); assertEquals("test-create-image", image.getName()); imageId = image.getId(); computeService.destroyNode(node.getId()); Optional<? extends Image> optImage = getImage(); assertTrue(optImage.isPresent()); }
@Test public void testLaunchClusterWithDomainName() throws RunNodesException { int numNodes = 1; final String name = "node"; Template template = view.getComputeService().templateBuilder().build(); // test passing custom options SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class); options.domainName("live.org"); //tags options.tags(ImmutableList.of("jclouds")); Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(name, numNodes, template); assertEquals(numNodes, nodes.size(), "wrong number of nodes"); for (NodeMetadata node : nodes) { logger.debug("Created Node: %s", node); SshClient client = view.utils().sshForNode().apply(node); client.connect(); ExecResponse hello = client.exec("mount"); logger.debug(hello.getOutput().trim()); view.getComputeService().destroyNode(node.getId()); } }