use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class CloneSingleCinderDiskCommand method addCinderDiskTemplateToDB.
protected void addCinderDiskTemplateToDB(final CinderDisk cinderDisk) {
TransactionSupport.executeInNewTransaction(() -> {
baseDiskDao.save(cinderDisk);
imageDao.save(cinderDisk.getImage());
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(cinderDisk.getImageId());
diskImageDynamicDao.save(diskDynamic);
ImageStorageDomainMap image_storage_domain_map = new ImageStorageDomainMap(cinderDisk.getImageId(), cinderDisk.getStorageIds().get(0), cinderDisk.getQuotaId(), cinderDisk.getDiskProfileId());
imageStorageDomainMapDao.save(image_storage_domain_map);
getCompensationContext().snapshotNewEntity(image_storage_domain_map);
getCompensationContext().snapshotNewEntity(diskDynamic);
getCompensationContext().snapshotNewEntity(cinderDisk.getImage());
getCompensationContext().snapshotNewEntity(cinderDisk);
getCompensationContext().stateChanged();
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class CreateAllOvaDisksCommand method saveDiskImageDynamic.
/**
* Generates and saves a {@link DiskImageDynamic} for the given <code>disk</code>
*
* @param disk
* The imported disk
*/
protected void saveDiskImageDynamic(DiskImage disk) {
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(disk.getImageId());
diskDynamic.setActualSize(disk.getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class DiskImageDynamicDaoTest method createDiskImageDynamic.
public DiskImageDynamic createDiskImageDynamic(Guid id) {
DiskImageDynamic dynamic = new DiskImageDynamic();
dynamic.setReadRate(5);
dynamic.setWriteRate(6);
dynamic.setReadLatency(0d);
dynamic.setFlushLatency(0.0202020d);
dynamic.setWriteLatency(null);
dynamic.setId(id);
return dynamic;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class DiskImageDynamicDaoTest method testUpdateAll.
@Test
public void testUpdateAll() throws Exception {
DiskImageDynamic existingEntity2 = dao.get(new Guid("42058975-3d5e-484a-80c1-01c31207f579"));
existingEntity.setActualSize(100);
existingEntity2.setReadRate(120);
existingEntity.setReadLatency(100d);
existingEntity2.setReadLatency(0.00001d);
dao.updateAll(Arrays.asList(existingEntity, existingEntity2));
assertEquals(existingEntity, dao.get(existingEntity.getId()));
assertEquals(existingEntity2, dao.get(existingEntity2.getId()));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class ImportVmTemplateCommand method addVmTemplateToDb.
protected void addVmTemplateToDb() {
getVmTemplate().setClusterId(getParameters().getClusterId());
// if "run on host" field points to a non existent vds (in the current cluster) -> remove field and continue
if (!vmHandler.validateDedicatedVdsExistOnSameCluster(getVmTemplate()).isValid()) {
getVmTemplate().setDedicatedVmForVdsList(Collections.emptyList());
}
getVmTemplate().setStatus(VmTemplateStatus.Locked);
getVmTemplate().setQuotaId(getParameters().getQuotaId());
vmHandler.autoSelectResumeBehavior(getVmTemplate(), getCluster());
vmTemplateDao.save(getVmTemplate());
getCompensationContext().snapshotNewEntity(getVmTemplate());
int count = 1;
for (DiskImage image : getImages()) {
image.setActive(true);
ImageStorageDomainMap map = imagesHandler.saveImage(image);
getCompensationContext().snapshotNewEntity(image.getImage());
getCompensationContext().snapshotNewEntity(map);
if (!baseDiskDao.exists(image.getId())) {
image.setDiskAlias(ImagesHandler.getSuggestedDiskAlias(image, getVmTemplateName(), count));
count++;
baseDiskDao.save(image);
getCompensationContext().snapshotNewEntity(image);
}
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(image.getImageId());
diskDynamic.setActualSize(image.getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
DiskVmElement dve = DiskVmElement.copyOf(image.getDiskVmElementForVm(sourceTemplateId), image.getId(), getVmTemplateId());
diskVmElementDao.save(dve);
getCompensationContext().snapshotNewEntity(diskDynamic);
}
}
Aggregations