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