Search in sources :

Example 11 with DiskImageDynamic

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;
    });
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)

Example 12 with DiskImageDynamic

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);
}
Also used : DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)

Example 13 with DiskImageDynamic

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;
}
Also used : DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)

Example 14 with DiskImageDynamic

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()));
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) Test(org.junit.Test)

Example 15 with DiskImageDynamic

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);
    }
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)

Aggregations

DiskImageDynamic (org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)15 ImageStorageDomainMap (org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap)4 Guid (org.ovirt.engine.core.compat.Guid)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 Test (org.junit.Test)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1 VolumeFormat (org.ovirt.engine.core.common.businessentities.storage.VolumeFormat)1 Pair (org.ovirt.engine.core.common.utils.Pair)1 CopyImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters)1 GetImageInfoVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters)1