コード例 #1
0
  /**
   * 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;
  }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
  /**
   * 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;
  }
コード例 #4
0
  /**
   * 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();
  }
コード例 #5
0
  /**
   * Get the list of all the images.
   *
   * @return the liste of images.
   */
  public ArrayList<VirtualMachineImage> describeImages() {
    log_.debug("Getting the images from the image repository");
    NetworkAddress imageRepositoryAddress = ec2Configuration_.getImageRepositorySettings();

    ImagesRepositoryAPI imagesRepositoryCommunicator =
        org.inria.myriads.snoozeimages.communication.rest.CommunicatorFactory
            .newImagesRepositoryCommunicator(imageRepositoryAddress);

    VirtualMachineImageList images = imagesRepositoryCommunicator.getImagesList();
    log_.debug("Returning the images list from the repository" + images.getImages().size());
    for (VirtualMachineImage image : images.getImages()) {
      log_.debug(image.getName());
    }

    return images.getImages();
  }
コード例 #6
0
  /**
   * 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;
  }