/** * Terminates instances. * * @param listInstances The list of instances to terminate. * @return The instanceset change state. */ public InstanceStateChangeSetType terminateInstances(List<String> listInstances) { log_.debug("Terminating instances"); NetworkAddress bootstrapAddress = ec2Configuration_.getBootstrapSettings(); BootstrapAPI bootstrapCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newBootstrapCommunicator(bootstrapAddress); InstanceStateChangeSetType instanceStateChange = new InstanceStateChangeSetType(); List<InstanceStateChangeType> instanceSet = instanceStateChange.getItem(); InstanceStateType previousState = new InstanceStateType(); previousState.setCode(EC2InstanceState.RUNNING.getCode()); previousState.setName(EC2InstanceState.RUNNING.getMessage()); for (String instance : listInstances) { InstanceStateChangeType instanceState = new InstanceStateChangeType(); boolean isTerminated = bootstrapCommunicator.destroyVirtualMachine(instance); InstanceStateType currentState = new InstanceStateType(); if (isTerminated) { currentState.setCode(EC2InstanceState.TERMINATED.getCode()); currentState.setName(EC2InstanceState.TERMINATED.getMessage()); } else { // need to be more precise here. currentState.setCode(EC2InstanceState.RUNNING.getCode()); currentState.setName(EC2InstanceState.RUNNING.getMessage()); } instanceState.setPreviousState(previousState); instanceState.setPreviousState(currentState); instanceSet.add(instanceState); } return instanceStateChange; }
/** * Run Instances. * * @param submissionRequest The submission resquest. * @return the taskIdentifier. */ public String runInstances(VirtualClusterSubmissionRequest submissionRequest) { log_.debug("Starting instances"); NetworkAddress bootstrapAddress = ec2Configuration_.getBootstrapSettings(); BootstrapAPI bootstrapCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newBootstrapCommunicator(bootstrapAddress); String taskIdentifier = bootstrapCommunicator.startVirtualCluster(submissionRequest); return taskIdentifier; }
/** * Reboot the instances. * * @param listInstances the instances to reboot. * @return true iff everything is ok. */ public boolean rebootInstances(List<String> listInstances) { log_.debug("Rebooting instances"); NetworkAddress bootstrapAddress = ec2Configuration_.getBootstrapSettings(); BootstrapAPI bootstrapCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newBootstrapCommunicator(bootstrapAddress); boolean isRebooted = true; for (String instance : listInstances) { isRebooted = isRebooted & bootstrapCommunicator.rebootVirtualMachine(instance); } return isRebooted; }
/** * Return the list of all the instances. * * @return list of virtual machines. */ public List<VirtualMachineMetaData> describeInstances() { log_.debug("Describe instances"); NetworkAddress bootstrapAddress = ec2Configuration_.getBootstrapSettings(); BootstrapAPI bootstrapCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newBootstrapCommunicator(bootstrapAddress); HostListRequest hostListRequest = new HostListRequest(); // infinite lookup ... hostListRequest.setLimit(-1); VirtualMachinesList virtualMachines = bootstrapCommunicator.getVirtualMachineDescriptions(hostListRequest); return virtualMachines.getVirtualMachines(); }
/** * Gets the virtual cluster submission response. * * @param taskIdentifier The taskidentifier. * @return The Virtual Cluster submission response. */ public VirtualClusterSubmissionResponse getVirtualClusterResponse(String taskIdentifier) { log_.debug("Describe instances"); NetworkAddress bootstrapAddress = ec2Configuration_.getBootstrapSettings(); BootstrapAPI bootstrapCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newBootstrapCommunicator(bootstrapAddress); GroupManagerDescription leaderDescription = bootstrapCommunicator.getGroupLeaderDescription(); GroupManagerAPI groupLeaderCommunicator = org.inria.myriads.snoozecommon.communication.rest.CommunicatorFactory .newGroupManagerCommunicator( leaderDescription.getListenSettings().getControlDataAddress()); VirtualClusterSubmissionResponse response = groupLeaderCommunicator.getVirtualClusterResponse(taskIdentifier); return response; }