Search in sources :

Example 6 with QuotaStorageConsumptionParameter

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

the class RegisterDiskCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    refreshDiskImageIfNecessery();
    list.add(new QuotaStorageConsumptionParameter(getParameters().getDiskImage().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getStorageDomainId(), getDiskImage().getActualSize()));
    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 7 with QuotaStorageConsumptionParameter

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

the class TransferDiskImageCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    if (getParameters().getAddDiskParameters() != null) {
        AddDiskParameters parameters = getAddDiskParameters();
        list.add(new QuotaStorageConsumptionParameter(((DiskImage) parameters.getDiskInfo()).getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getStorageDomainId(), (double) parameters.getDiskInfo().getSize() / SizeConverter.BYTES_IN_GB));
    }
    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) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 8 with QuotaStorageConsumptionParameter

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

the class MoveOrCopyDiskCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    list.add(new QuotaStorageConsumptionParameter(getDestinationQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, getParameters().getStorageDomainId(), (double) getImage().getSizeInGigabytes()));
    if (isMoveOperation()) {
        if (getImage().getQuotaId() != null && !Guid.Empty.equals(getImage().getQuotaId())) {
            list.add(new QuotaStorageConsumptionParameter(getImage().getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.RELEASE, getParameters().getSourceDomainId(), (double) getImage().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 9 with QuotaStorageConsumptionParameter

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

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

Aggregations

QuotaStorageConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter)10 ArrayList (java.util.ArrayList)9 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)7 Guid (org.ovirt.engine.core.compat.Guid)2 Test (org.junit.Test)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1