Search in sources :

Example 6 with DiskImageDynamic

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

Example 7 with DiskImageDynamic

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

Example 8 with DiskImageDynamic

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

Example 9 with DiskImageDynamic

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

Example 10 with DiskImageDynamic

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);
    }
}
Also used : 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