use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.
the class ImportVmTemplateFromConfigurationCommand method populateDisksCopies.
private void populateDisksCopies(List<ImageStorageDomainMap> copiedTemplateDisks, List<DiskImage> originalTemplateImages, Guid storageDomainId) {
List<Guid> imagesContainedInStorageDomain = getImagesGuidFromStorage(storageDomainId, getStoragePoolId());
for (DiskImage templateDiskImage : originalTemplateImages) {
if (storageDomainId.equals(templateDiskImage.getStorageIds().get(0))) {
// The original Storage Domain was already saved. skipping it.
continue;
}
if (imagesContainedInStorageDomain.contains(templateDiskImage.getId())) {
log.info("Found a copied image of '{}' on Storage Domain id '{}'", templateDiskImage.getId(), storageDomainId);
ImageStorageDomainMap imageStorageDomainMap = new ImageStorageDomainMap(templateDiskImage.getImageId(), storageDomainId, templateDiskImage.getQuotaId(), templateDiskImage.getDiskProfileId());
copiedTemplateDisks.add(imageStorageDomainMap);
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.
the class ImportVmTemplateFromConfigurationCommand method findAndSaveDiskCopies.
private void findAndSaveDiskCopies() {
List<OvfEntityData> ovfEntityDataList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(ovfEntityData.getEntityId(), null);
List<ImageStorageDomainMap> copiedTemplateDisks = new LinkedList<>();
for (OvfEntityData ovfEntityDataFetched : ovfEntityDataList) {
populateDisksCopies(copiedTemplateDisks, getImages(), ovfEntityDataFetched.getStorageDomainId());
}
saveImageStorageDomainMapList(copiedTemplateDisks);
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap 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.ImageStorageDomainMap in project ovirt-engine by oVirt.
the class ImagesHandler method saveImage.
/**
* The following method unify saving of image, it will be also saved with its storage
* mapping.
*/
public ImageStorageDomainMap saveImage(DiskImage diskImage) {
imageDao.save(diskImage.getImage());
ImageStorageDomainMap imageStorageDomainMap = new ImageStorageDomainMap(diskImage.getImageId(), diskImage.getStorageIds().get(0), diskImage.getQuotaId(), diskImage.getDiskProfileId());
imageStorageDomainMapDao.save(imageStorageDomainMap);
return imageStorageDomainMap;
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.
the class BaseImagesCommand method addDiskImageToDb.
protected void addDiskImageToDb(DiskImage image, CompensationContext compensationContext, boolean active) {
image.setActive(active);
imageDao.save(image.getImage());
DiskImageDynamic diskDynamic = updateDiskImageDynamicIntoDB(image);
ImageStorageDomainMap imageStorageDomainMap = new ImageStorageDomainMap(image.getImageId(), image.getStorageIds().get(0), image.getQuotaId(), image.getDiskProfileId());
imageStorageDomainMapDao.save(imageStorageDomainMap);
boolean isDiskAdded = saveDiskIfNotExists(image);
if (compensationContext != null) {
compensationContext.snapshotNewEntity(image.getImage());
compensationContext.snapshotNewEntity(diskDynamic);
compensationContext.snapshotNewEntity(imageStorageDomainMap);
if (isDiskAdded) {
compensationContext.snapshotNewEntity(image);
}
compensationContext.stateChanged();
}
}
Aggregations