コード例 #1
0
  public VirtualMachine getVM(CloudVmAllocationType request) {

    VMTypeType.VMType SLA_VM;

    try {
      SLA_VM = Util.findVMByName(request.getVmType(), currentVMType);
    } catch (NoSuchElementException e1) {
      log.error("VM name " + request.getVmType() + " could not be found in SLA");
      return null;
    }

    int nbCPUs = SLA_VM.getCapacity().getVCpus().getValue();
    // the consumption of a VM if set as a percentage * number of CPU.
    // it should be demanding a certain CPU power instead.
    int consumption =
        (int)
            (nbCPUs
                * SLA_VM
                    .getExpectedLoad()
                    .getVCpuLoad()
                    .getValue()); // (int) (SLA_VM.getExpectedLoad().getVCpuLoad().getValue() *
    // REFERENCE_CPU_SPEED);
    int memory = (int) (SLA_VM.getCapacity().getVRam().getValue() * 1024);

    log.debug("creation of an Entropy VM for allocation request");
    log.debug("nbCPUs " + nbCPUs);
    log.debug("consumption " + consumption + " %");
    log.debug("memory " + memory + " MB");
    VirtualMachine vm = new SimpleVirtualMachine("new VM", nbCPUs, consumption, memory);

    return vm;
  }
コード例 #2
0
  private VirtualMachine getVM(Node node, VirtualMachineType VM) {

    // VM type should be set OR some measurements should be present
    if (VM.getCloudVmType() == null
        && (VM.getNumberOfCPUs() == null
            || VM.getActualCPUUsage() == null
            || VM.getActualMemoryUsage() == null)) {
      log.error("VM type not set for " + VM.getFrameworkID() + " and no VM measures found");
      System.exit(-1);
    }

    VMTypeType.VMType SLA_VM = null;
    if (VM.getCloudVmType() != null) {
      SLA_VM = Util.findVMByName(VM.getCloudVmType(), currentVMType);
    }

    // If the measured values are present in the VM, we take these.
    // otherwise, we take the specification values from the SLA.
    int nbCPUs;
    if (VM.getNumberOfCPUs() != null) {
      nbCPUs = VM.getNumberOfCPUs().getValue();
    } else {
      nbCPUs = SLA_VM.getCapacity().getVCpus().getValue();
    }

    double CPUUsage;
    if (VM.getActualCPUUsage() != null) {
      CPUUsage = VM.getActualCPUUsage().getValue();
    } else {
      CPUUsage = SLA_VM.getExpectedLoad().getVCpuLoad().getValue();
    }

    int memory;
    if (VM.getActualMemoryUsage() != null) {
      memory = (int) (VM.getActualMemoryUsage().getValue() * 1024);
    } else {
      memory = (int) (SLA_VM.getCapacity().getVRam().getValue() * 1024);
    }

    int consumption = (int) (CPUUsage * nbCPUs);

    log.debug("creation of an Entropy VM with name " + VM.getFrameworkID());
    log.debug("nbCPUs " + nbCPUs);
    log.debug("consumption " + consumption + " %");
    log.debug("memory " + memory + " MB");
    VirtualMachine vm = new SimpleVirtualMachine(VM.getFrameworkID(), nbCPUs, consumption, memory);
    return vm;
  }