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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations