Search in sources :

Example 1 with QuotaClusterConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter in project ovirt-engine by oVirt.

the class HotSetAmountOfMemoryCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    // Calculate the change in memory consumption,
    // result above Zero means we add memory to the VM (consume)
    // result bellow Zero means we subtracted memory from the VM (release)
    QuotaConsumptionParameter.QuotaAction quotaAction = (getParameters().getMemoryDeviceSizeMb() > 0) ? QuotaConsumptionParameter.QuotaAction.CONSUME : QuotaConsumptionParameter.QuotaAction.RELEASE;
    list.add(new QuotaClusterConsumptionParameter(getVm().getQuotaId(), null, quotaAction, getVm().getClusterId(), 0, Math.abs(getParameters().getMemoryDeviceSizeMb())));
    return list;
}
Also used : QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 2 with QuotaClusterConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter in project ovirt-engine by oVirt.

the class HotSetNumberOfCpusCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    // Calculate the change in CPU consumption, result above Zero means we add CPUs to
    // the VM
    // result bellow Zero means we subtracted CPUs from the VM
    int cpuToConsume = getParameters().getVm().getNumOfCpus() - getVm().getNumOfCpus();
    if (cpuToConsume > 0) {
        // Consume CPU quota
        list.add(new QuotaClusterConsumptionParameter(getVm().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getVm().getClusterId(), getVm().getCpuPerSocket() * getVm().getThreadsPerCpu() * cpuToConsume, 0));
    } else if (cpuToConsume < 0) {
        // Release CPU quota
        list.add(new QuotaClusterConsumptionParameter(getVm().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.RELEASE, getVm().getClusterId(), getVm().getCpuPerSocket() * getVm().getThreadsPerCpu() * Math.abs(cpuToConsume), 0));
    }
    return list;
}
Also used : QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 3 with QuotaClusterConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter in project ovirt-engine by oVirt.

the class UpdateVmCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    // The cases must be persistent with the create_functions_sp
    if (!getQuotaManager().isVmStatusQuotaCountable(getVm().getStatus())) {
        list.add(new QuotaSanityParameter(getQuotaId(), null));
        quotaSanityOnly = true;
    } else {
        if (!getQuotaId().equals(getVm().getQuotaId())) {
            list.add(new QuotaClusterConsumptionParameter(getVm().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.RELEASE, getClusterId(), getVm().getNumOfCpus(), getVm().getMemSizeMb()));
            list.add(new QuotaClusterConsumptionParameter(getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getParameters().getVmStaticData().getClusterId(), getParameters().getVmStaticData().getNumOfCpus(), getParameters().getVmStaticData().getMemSizeMb()));
        }
    }
    return list;
}
Also used : QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) QuotaSanityParameter(org.ovirt.engine.core.bll.quota.QuotaSanityParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 4 with QuotaClusterConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter in project ovirt-engine by oVirt.

the class RunVmCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    list.add(new QuotaClusterConsumptionParameter(getVm().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getVm().getClusterId(), getVm().getCpuPerSocket() * getVm().getNumOfSockets(), getVm().getMemSizeMb()));
    return list;
}
Also used : QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 5 with QuotaClusterConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter in project ovirt-engine by oVirt.

the class AttachUserToVmFromPoolAndRunCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    VM vm = getVm();
    if (vm != null) {
        setStoragePoolId(vm.getStoragePoolId());
        list.add(new QuotaClusterConsumptionParameter(vm.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, vm.getClusterId(), vm.getCpuPerSocket() * vm.getNumOfSockets(), vm.getMemSizeMb()));
    }
    return list;
}
Also used : QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Aggregations

ArrayList (java.util.ArrayList)5 QuotaClusterConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter)5 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)5 QuotaSanityParameter (org.ovirt.engine.core.bll.quota.QuotaSanityParameter)1 VM (org.ovirt.engine.core.common.businessentities.VM)1