@Override public Void call() throws Exception { try { vm.deallocate(); } catch (CloudException e) { log.error("Error deallocating " + vm.resourceGroupName() + " " + vm.name() + ": " + e.getMessage(), e); throw new RuntimeException(e); } catch (IOException e) { log.error("Error deallocating " + vm.resourceGroupName() + " " + vm.name() + ": " + e.getMessage(), e); throw new RuntimeException(e); } return null; } }));
/** * Shutdowns Azure virtual machine. * * @param agent * @throws Exception */ public void shutdownVirtualMachine(AzureVMAgent agent) { LOGGER.log(Level.INFO, "AzureVMManagementServiceDelegate: shutdownVirtualMachine: called for {0}", agent.getNodeName()); try { azureClient.virtualMachines() .getByResourceGroup(agent.getResourceGroupName(), agent.getNodeName()).deallocate(); } catch (Exception e) { LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: provision: could not terminate or shutdown {0}, {1}", new Object[]{agent.getNodeName(), e}); } }