use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class ImagesHandler method addImage.
/**
* Add image and related entities to DB (Adds image, disk image dynamic and image storage domain map)
*
* @param image
* the image to add
* @param active
* if true the image will be active
* @param imageStorageDomainMap
* entry of mapping between the storage domain and the image
*/
public void addImage(DiskImage image, boolean active, ImageStorageDomainMap imageStorageDomainMap) {
image.setActive(active);
imageDao.save(image.getImage());
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(image.getImageId());
diskDynamic.setActualSize(image.getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
if (imageStorageDomainMap != null) {
imageStorageDomainMapDao.save(imageStorageDomainMap);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class DiskImageDynamicDaoTest method updateAllDiskImageDynamicWithDiskIdByVmId.
@Test
public void updateAllDiskImageDynamicWithDiskIdByVmId() throws Exception {
Guid imageId = FixturesTool.IMAGE_ID_2;
Guid imageGroupId = FixturesTool.IMAGE_GROUP_ID_2;
DiskImageDynamic existingEntity2 = dao.get(imageId);
assertFalse(existingEntity2.getReadRate().equals(120));
existingEntity2.setId(imageGroupId);
Integer readRate = 120;
existingEntity2.setReadRate(readRate);
// test that the record is updated when the active disk is attached to the vm
dao.updateAllDiskImageDynamicWithDiskIdByVmId(Collections.singleton(new Pair<>(FixturesTool.VM_RHEL5_POOL_57, existingEntity2)));
existingEntity2.setId(imageId);
assertEquals(existingEntity2, dao.get(imageId));
existingEntity2.setReadRate(150);
dao.updateAllDiskImageDynamicWithDiskIdByVmId(Collections.singleton(new Pair<>(FixturesTool.VM_RHEL5_POOL_57, existingEntity2)));
assertEquals(readRate, dao.get(imageId).getReadRate());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class AddCinderDiskCommand method addCinderDiskToDB.
protected void addCinderDiskToDB(final CinderDisk cinderDisk) {
TransactionSupport.executeInNewTransaction(() -> {
baseDiskDao.save(cinderDisk);
imageDao.save(cinderDisk.getImage());
imageStorageDomainMapDao.save(new ImageStorageDomainMap(cinderDisk.getImageId(), cinderDisk.getStorageIds().get(0), cinderDisk.getQuotaId(), cinderDisk.getDiskProfileId()));
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(cinderDisk.getImageId());
diskImageDynamicDao.save(diskDynamic);
if (getVm() != null) {
addDiskVmElementForDisk(getDiskVmElement());
addManagedDeviceForDisk(cinderDisk.getId());
}
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class BaseImagesCommand method updateDiskImageDynamicIntoDB.
protected DiskImageDynamic updateDiskImageDynamicIntoDB(DiskImage image) {
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(image.getImageId());
diskDynamic.setActualSize(image.getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
return diskDynamic;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class BaseImagesCommand method completeImageData.
/**
* Overrides the relevant fields of the destination disk image ('DestinationDiskImage') with some values of the IRS
* disk image.
* @param fromIRS
* the IRS disk image.
*/
protected void completeImageData(DiskImage fromIRS) {
getDestinationDiskImage().setCreationDate(fromIRS.getCreationDate());
getDestinationDiskImage().setLastModifiedDate(fromIRS.getLastModifiedDate());
getDestinationDiskImage().setLastModified(getDestinationDiskImage().getLastModifiedDate());
DiskImageDynamic destinationDiskDynamic = diskImageDynamicDao.get(getDestinationDiskImage().getImageId());
if (destinationDiskDynamic != null) {
destinationDiskDynamic.setActualSize(fromIRS.getActualSizeInBytes());
diskImageDynamicDao.update(destinationDiskDynamic);
}
}
Aggregations