Search in sources :

Example 11 with QuotaConsumptionParameter

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

the class UpdateVmDiskCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    if (isInternalManagedDisk()) {
        DiskImage oldDiskImage = (DiskImage) getOldDisk();
        DiskImage newDiskImage = (DiskImage) getNewDisk();
        boolean emptyOldQuota = oldDiskImage.getQuotaId() == null || Guid.Empty.equals(oldDiskImage.getQuotaId());
        boolean differentNewQuota = !emptyOldQuota && !oldDiskImage.getQuotaId().equals(newDiskImage.getQuotaId());
        long diskExtendingDiff = newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes();
        if (emptyOldQuota || differentNewQuota) {
            list.add(generateQuotaConsumeParameters(newDiskImage, newDiskImage.getSizeInGigabytes()));
        } else if (diskExtendingDiff > 0L) {
            list.add(generateQuotaConsumeParameters(newDiskImage, diskExtendingDiff));
        }
        if (differentNewQuota) {
            list.add(new QuotaStorageConsumptionParameter(oldDiskImage.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, // TODO: Shared Disk?
            oldDiskImage.getStorageIds().get(0), (double) oldDiskImage.getSizeInGigabytes()));
        }
    }
    return list;
}
Also used : QuotaStorageConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 12 with QuotaConsumptionParameter

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

the class ImportRepoImageCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    list.add(new QuotaStorageConsumptionParameter(getParameters().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getParameters().getStorageDomainId(), (double) getDiskImage().getSizeInGigabytes()));
    return list;
}
Also used : QuotaStorageConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 13 with QuotaConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter 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 14 with QuotaConsumptionParameter

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

the class UpdateVmTemplateCommand method getQuotaVdsConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    list.add(new QuotaSanityParameter(getParameters().getVmTemplateData().getQuotaId(), null));
    return list;
}
Also used : QuotaSanityParameter(org.ovirt.engine.core.bll.quota.QuotaSanityParameter) ArrayList(java.util.ArrayList) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Example 15 with QuotaConsumptionParameter

use of org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter 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)

Aggregations

QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)18 ArrayList (java.util.ArrayList)17 QuotaStorageConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 QuotaClusterConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter)5 QuotaSanityParameter (org.ovirt.engine.core.bll.quota.QuotaSanityParameter)4 Guid (org.ovirt.engine.core.compat.Guid)2 InvalidQuotaParametersException (org.ovirt.engine.core.bll.quota.InvalidQuotaParametersException)1 QuotaConsumptionParametersWrapper (org.ovirt.engine.core.bll.quota.QuotaConsumptionParametersWrapper)1 AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1