use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class LiveMigrateDiskCommand method moveDiskInDB.
private void moveDiskInDB(final Guid sourceStorageDomainId, final Guid targetStorageDomainId, final Guid targetQuota, final Guid targetDiskProfile) {
if (isMoveDiskInDbSucceded(targetStorageDomainId)) {
return;
}
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
for (DiskImage di : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(di.getImageId(), sourceStorageDomainId));
imageStorageDomainMapDao.save(new ImageStorageDomainMap(di.getImageId(), targetStorageDomainId, targetQuota, targetDiskProfile));
// an exception, we store locally the old quota and disk profile id.
if (sourceQuotaId == null) {
sourceQuotaId = di.getQuotaId();
}
if (sourceDiskProfileId == null) {
sourceDiskProfileId = di.getDiskProfileId();
}
}
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class LiveMigrateDiskCommand method validateDestDomainsSpaceRequirements.
protected boolean validateDestDomainsSpaceRequirements() {
if (!isStorageDomainWithinThresholds(getDstStorageDomain())) {
return false;
}
DiskImage diskImage = getDiskImageByImageId(getParameters().getImageId());
List<DiskImage> allImageSnapshots = diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId());
diskImage.getSnapshots().addAll(allImageSnapshots);
StorageDomainValidator storageDomainValidator = createStorageDomainValidator(getDstStorageDomain());
if (!validate(storageDomainValidator.hasSpaceForClonedDisks(Collections.singleton(diskImage)))) {
return false;
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class LiveMigrateDiskCommand method updateImagesInfo.
private void updateImagesInfo() {
for (DiskImage image : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
VDSReturnValue ret = runVdsCommand(VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getTargetStorageDomainId(), getParameters().getImageGroupID(), image.getImageId()));
DiskImage imageFromIRS = (DiskImage) ret.getReturnValue();
setQcowCompatForSnapshot(image, imageFromIRS);
DiskImageDynamic diskImageDynamic = diskImageDynamicDao.get(image.getImageId());
// Update image's actual size in DB
if (imageFromIRS != null && diskImageDynamic != null) {
diskImageDynamic.setActualSize(imageFromIRS.getActualSizeInBytes());
diskImageDynamicDao.update(diskImageDynamic);
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddStoragePoolWithStoragesCommand method registerOvfStoreDisks.
private void registerOvfStoreDisks() {
for (final Guid storageDomainId : getParameters().getStorages()) {
if (storageDomainStaticDao.get(storageDomainId).getStorageDomainType().isDataDomain()) {
resetOvfStoreAndUnregisteredDisks();
TransactionSupport.executeInNewTransaction(() -> {
List<DiskImage> ovfStoreDiskImages = getAllOVFDisks(storageDomainId, getStoragePool().getId());
registerAllOvfDisks(ovfStoreDiskImages, storageDomainId);
List<OvfEntityData> entitiesFromStorageOvfDisk = getEntitiesFromStorageOvfDisk(storageDomainId, getStoragePool().getId());
// Update unregistered entities
for (Object ovf : entitiesFromStorageOvfDisk) {
OvfEntityData ovfEntityData = (OvfEntityData) ovf;
unregisteredOVFDataDao.removeEntity(ovfEntityData.getEntityId(), storageDomainId);
unregisteredOVFDataDao.saveOVFData(ovfEntityData);
log.info("Adding OVF data of entity id '{}' and entity name '{}'", ovfEntityData.getEntityId(), ovfEntityData.getEntityName());
}
initUnregisteredDisksToDB(storageDomainId);
return null;
});
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class RunVmCommandTest method initDiskImage.
private Guid initDiskImage(VM vm) {
DiskImage image = new DiskImage();
Guid storageDomainId = Guid.newGuid();
image.setId(Guid.newGuid());
image.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomainId)));
vm.getDiskMap().put(image.getId(), image);
return storageDomainId;
}
Aggregations