/** * Terminates a VM. * * @param applicationName the application name * @param rootInstance the root instance associated with a machine */ public void terminateMachine(String applicationName, Instance rootInstance) { try { ManagedApplication ma = this.appNameToManagedApplication.get(applicationName); if (ma == null) { this.logger.severe( "Machine " + rootInstance.getName() + " failed to be resolved for application " + applicationName + "."); } else { this.logger.fine("Machine " + rootInstance.getName() + " is about to be deleted."); IaasInterface iaasInterface = this.iaasResolver.findIaasInterface(ma, rootInstance); String machineId = rootInstance.getData().get(Instance.MACHINE_ID); iaasInterface.terminateVM(machineId); this.logger.fine("Machine " + rootInstance.getName() + " was successfully deleted."); rootInstance.setStatus(InstanceStatus.NOT_DEPLOYED); } } catch (IaasException e) { rootInstance.setStatus(InstanceStatus.PROBLEM); this.logger.severe( "Machine " + rootInstance.getName() + " could not be deleted. " + e.getMessage()); this.logger.finest(Utils.writeException(e)); } catch (CommunicationToIaasException e) { rootInstance.setStatus(InstanceStatus.PROBLEM); this.logger.severe( "Machine " + rootInstance.getName() + " could not be deleted. " + e.getMessage()); this.logger.finest(Utils.writeException(e)); } }