public FormValidation doVerifyConfiguration( @QueryParameter String subscriptionId, @QueryParameter String serviceManagementCert, @QueryParameter String passPhrase, @QueryParameter String serviceManagementURL) { if (AzureUtil.isNull(subscriptionId)) { return FormValidation.error("Error: Subscription ID is missing"); } if (AzureUtil.isNull(serviceManagementCert)) { return FormValidation.error("Error: Management service certificate is missing"); } if (AzureUtil.isNull(serviceManagementURL)) { serviceManagementURL = Constants.DEFAULT_MANAGEMENT_URL; } String response = AzureManagementServiceDelegate.verifyConfiguration( subscriptionId, serviceManagementCert, passPhrase, serviceManagementURL); if (response.equalsIgnoreCase("Success")) { return FormValidation.ok(Messages.Azure_Config_Success()); } else { return FormValidation.error(response); } }
public void execute(TaskListener arg0) throws IOException, InterruptedException { for (Computer computer : Hudson.getInstance().getComputers()) { if (computer instanceof AzureComputer) { AzureComputer azureComputer = (AzureComputer) computer; AzureSlave slaveNode = azureComputer.getNode(); try { if (azureComputer.isOffline()) { if (!slaveNode.isDeleteSlave()) { // Find out if node exists in azure , if not continue with delete else do not delete // node // although it is offline. May be JNLP or SSH launch is in progress if (AzureManagementServiceDelegate.isVirtualMachineExists(slaveNode)) { LOGGER.info( "AzureSlaveCleanUpTask: execute: VM " + slaveNode.getDisplayName() + " exists in cloud"); continue; } } int retryCount = 0; boolean successful = false; // Retrying for 30 times with 30 seconds wait time between each retry while (retryCount < 30 && !successful) { try { slaveNode.idleTimeout(); successful = true; } catch (Exception e) { retryCount++; LOGGER.info( "AzureSlaveCleanUpTask: execute: Exception occured while calling timeout on node , \n" + "Will retry again after 30 seconds. Current retry count " + retryCount + "\n" + "Error code " + e.getMessage()); // We won't get exception for RNF , so for other exception types we can retry try { Thread.sleep(30 * 1000); } catch (InterruptedException e1) { e1.printStackTrace(); } } } Hudson.getInstance().removeNode(slaveNode); } } catch (Exception e) { LOGGER.severe("AzureSlaveCleanUpTask: execute: failed to remove node " + e); } } } }