use of org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter 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;
}
use of org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter 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;
}
use of org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter 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();
}
use of org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter 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;
}
use of org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter in project ovirt-engine by oVirt.
the class UpdateVmDiskCommandTest method testExtendingDiskWithQuota.
@Test
public void testExtendingDiskWithQuota() {
Guid quotaId = Guid.newGuid();
DiskImage oldDiskImage = createDiskImage();
oldDiskImage.setQuotaId(quotaId);
oldDiskImage.setSize(SizeConverter.convert(3L, SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
DiskImage newDiskImage = createDiskImage();
newDiskImage.setQuotaId(quotaId);
newDiskImage.setSize(SizeConverter.convert(5L, SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
command.getParameters().setDiskVmElement(new DiskVmElement(newDiskImage.getId(), vmId));
command.getParameters().setDiskInfo(newDiskImage);
long diskExtendingDiffInGB = newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes();
when(diskDao.get(diskImageGuid)).thenReturn(oldDiskImage);
initializeCommand();
QuotaStorageConsumptionParameter consumptionParameter = (QuotaStorageConsumptionParameter) command.getQuotaStorageConsumptionParameters().get(0);
assertEquals(consumptionParameter.getRequestedStorageGB().longValue(), diskExtendingDiffInGB);
}
Aggregations