/** * suspend the node, given its id. This will result in * {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state. * <p/> * <h4>note</h4> * <p/> * affected nodes may not resume with the same IP address(es) * * @throws UnsupportedOperationException if the underlying provider doesn't support suspend/resume */ @Override public void suspendNode(String id) { computeService.suspendNode(id); }
/** * suspend the node, given its id. This will result in * {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state. * <p/> * <h4>note</h4> * <p/> * affected nodes may not resume with the same IP address(es) * * @throws UnsupportedOperationException if the underlying provider doesn't support suspend/resume */ @Override public void suspendNode(String id) { computeService.suspendNode(id); }
@Override public void suspendNode(String id) { delegate.suspendNode(id); }
@Override protected Object doExecute() throws Exception { ComputeService service = null; try { service = getComputeService(); } catch (Throwable t) { System.err.println(t.getMessage()); t.printStackTrace(System.err); return null; } service.suspendNode(id); return null; } }
/** * Stops running server on EC2 with specified name. * * @param serverName */ public void stopServer(String serverName) { final List<NodeMetadata> serverList = new ArrayList<>(); serverList.addAll(getServers(serverName)); if (serverList.size() != 1) { throw new RuntimeException("There are multiple servers (" + serverList.size() + ") in the inventory with specified name!"); } else { final NodeMetadata server = serverList.get(0); computeService.suspendNode(server.getId()); } }
@Override public void stopVM(VMInstance a) { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); try{ novaComputeService.suspendNode(a.getId()); }catch(Exception exception){ journal.log(Level.INFO, ">> Check VM status!"); } }
@Override public void stopVM(VMInstance a) { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); compute.suspendNode(a.getId()); }
/** * Destroy the node. * If stopOnTerminate is {@code true}, calls {@link ComputeService#suspendNode}, * otherwise {@link ComputeService#destroyNode}. */ @Override protected void _terminate(TaskListener listener) throws IOException, InterruptedException { final ComputeService compute = JCloudsCloud.getByName(cloudName).getCompute(); if (compute.getNodeMetadata(nodeId) != null && compute.getNodeMetadata(nodeId).getStatus().equals(NodeMetadata.Status.RUNNING)) { if (stopOnTerminate) { LOGGER.info("Suspending slave : " + getNodeName()); compute.suspendNode(nodeId); } else { LOGGER.info("Terminating slave : " + getNodeName()); compute.destroyNode(nodeId); } } else { LOGGER.info("Slave " + getNodeName() + " is already not running."); } ProvisioningActivity activity = CloudStatistics.get().getActivityFor(this); if (activity != null) { activity.enterIfNotAlready(ProvisioningActivity.Phase.COMPLETED); } }
computeService.suspendNode("az-1.region-a.geo-1/71752");
/** * Test failed suspend/resume via ComputeService which depends on * Admin extension being installed in OpenStack. Throws UOE if extension is missing. */ @Test(expectedExceptions = UnsupportedOperationException.class) public void testSuspendWithoutAdminExtensionThrowsUOE() throws Exception { HttpRequest suspendServer = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752/action") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( "{\"suspend\":null}", "application/json")) .build(); HttpResponse suspendServerResponse = HttpResponse.builder() .statusCode(202) .build(); HttpResponse serverDetailSuspendedResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/server_details_suspended.json")).build(); Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) .put(extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse) .put(listDetail, listDetailResponse) .put(listFlavorsDetail, listFlavorsDetailResponse) .put(suspendServer, suspendServerResponse) .put(serverDetail, serverDetailSuspendedResponse).build(); Injector forAdminExtension = requestsSendResponses(requestResponseMap); ComputeService compute = forAdminExtension.getInstance(ComputeService.class); compute.suspendNode("az-1.region-a.geo-1/71752"); }
@Test public void testCreateImage() throws RunNodesException { NodeMetadata node = getOnlyElement(view.getComputeService().createNodesInGroup(group, 1, resourceGroup(group))); IdReference vmIdRef = IdReference.create(node.getProviderId()); view.getComputeService().suspendNode(node.getId()); api.getVirtualMachineApi(group).generalize(node.getName()); image = imageApi.createOrUpdate(imageName, location, ImageProperties.builder() .sourceVirtualMachine(vmIdRef).build()); assertNotNull(image); }