Search in sources :

Example 1 with QuotaConsumptionParameter

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

the class ImportVmCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    for (Disk disk : getParameters().getVm().getDiskMap().values()) {
        // TODO: handle import more than once;
        if (disk instanceof DiskImage) {
            DiskImage diskImage = (DiskImage) disk;
            list.add(new QuotaStorageConsumptionParameter(diskImage.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, imageToDestinationDomainMap.get(diskImage.getId()), (double) diskImage.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) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with QuotaConsumptionParameter

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

the class RemoveVmTemplateCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    getImageTemplates();
    if (imageTemplates != null) {
        for (DiskImage disk : imageTemplates) {
            if (disk.getQuotaId() != null && !Guid.Empty.equals(disk.getQuotaId())) {
                for (Guid storageId : disk.getStorageIds()) {
                    list.add(new QuotaStorageConsumptionParameter(disk.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, storageId, (double) disk.getSizeInGigabytes()));
                }
            }
        }
    }
    return list;
}
Also used : QuotaStorageConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with QuotaConsumptionParameter

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

the class RemoveVmCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    if (getParameters().isRemoveDisks()) {
        List<QuotaConsumptionParameter> list = new ArrayList<>();
        imagesHandler.fillImagesBySnapshots(getVm());
        for (DiskImage disk : getVm().getDiskList()) {
            for (DiskImage snapshot : disk.getSnapshots()) {
                if (snapshot.getQuotaId() != null && !Guid.Empty.equals(snapshot.getQuotaId())) {
                    if (snapshot.getActive()) {
                        list.add(new QuotaStorageConsumptionParameter(snapshot.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, disk.getStorageIds().get(0), (double) snapshot.getSizeInGigabytes()));
                    } else {
                        list.add(new QuotaStorageConsumptionParameter(snapshot.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, disk.getStorageIds().get(0), snapshot.getActualSize()));
                    }
                }
            }
        }
        return list;
    }
    return Collections.emptyList();
}
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 4 with QuotaConsumptionParameter

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

the class RestoreAllSnapshotsCommand method getQuotaStorageConsumptionParameters.

@Override
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    List<DiskImage> disks = getImagesList();
    if (disks != null && !disks.isEmpty()) {
        // TODO: need to be fixed. sp id should be available
        setStoragePoolId(disks.get(0).getStoragePoolId());
        for (DiskImage image : disks) {
            if (!image.getImage().isActive() && image.getQuotaId() != null && !Guid.Empty.equals(image.getQuotaId())) {
                list.add(new QuotaStorageConsumptionParameter(image.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.RELEASE, image.getStorageIds().get(0), image.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) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 5 with QuotaConsumptionParameter

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

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