Search in sources :

Example 6 with ImageStorageDomainMap

use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.

the class CopyImageGroupCommand method endSuccessfully.

@Override
protected void endSuccessfully() {
    if (shouldUpdateStorageDisk()) {
        List<DiskImage> snapshots = diskImageDao.getAllSnapshotsForImageGroup(getParameters().getDestImageGroupId());
        setSnapshotForShareableDisk(snapshots);
        for (DiskImage snapshot : snapshots) {
            imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(snapshot.getImageId(), snapshot.getStorageIds().get(0)));
            imageStorageDomainMapDao.save(new ImageStorageDomainMap(snapshot.getImageId(), getParameters().getStorageDomainId(), getParameters().getQuotaId(), getParameters().getDiskProfileId()));
            setQcowCompatForSnapshot(snapshot, null);
        }
    }
    super.endSuccessfully();
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) ImageStorageDomainMapId(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 7 with ImageStorageDomainMap

use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.

the class ImageStorageDomainMapDaoTest method testGetAllByImageId.

@Test
public void testGetAllByImageId() {
    List<ImageStorageDomainMap> result = dao.getAllByImageId(EXISTING_IMAGE_ID);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (ImageStorageDomainMap mapping : result) {
        assertEquals(EXISTING_IMAGE_ID, mapping.getImageId());
    }
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) Test(org.junit.Test)

Example 8 with ImageStorageDomainMap

use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.

the class ImageStorageDomainMapDaoTest method testSave.

@Test
public void testSave() {
    ImageStorageDomainMap entry = new ImageStorageDomainMap(EXISTING_IMAGE_ID_WITH_NO_MAP_ENTRY, FixturesTool.STORAGE_DOMAIN_SCALE_SD5, FixturesTool.DEFAULT_QUOTA_GENERAL, FixturesTool.DISK_PROFILE_1);
    dao.save(entry);
    List<ImageStorageDomainMap> entries = dao.getAllByImageId(EXISTING_IMAGE_ID_WITH_NO_MAP_ENTRY);
    assertNotNull(entries);
    assertEquals(1, entries.size());
    ImageStorageDomainMap entryFromDb = entries.get(0);
    assertEquals(entry, entryFromDb);
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) Test(org.junit.Test)

Example 9 with ImageStorageDomainMap

use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.

the class ImageStorageDomainMapDaoTest method testChangeDiskProfileForDisk.

@Test
public void testChangeDiskProfileForDisk() {
    // fetch image
    ImageStorageDomainMap imageStorageDomainMap = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0);
    // test that the current disk profile doesn't equal with the new disk profile
    assertThat("Same source and dest disk profile id, cannot perform test", imageStorageDomainMap.getDiskProfileId(), not(equalTo(FixturesTool.DISK_PROFILE_2)));
    // change to newDiskProfileId
    dao.updateDiskProfileByImageGroupIdAndStorageDomainId(FixturesTool.IMAGE_GROUP_ID, FixturesTool.STORAGE_DOMAIN_SCALE_SD5, FixturesTool.DISK_PROFILE_2);
    // fetch the image again
    imageStorageDomainMap = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0);
    // check that the new disk profile is the inserted one
    assertEquals("disk profile wasn't changed", FixturesTool.DISK_PROFILE_2, imageStorageDomainMap.getDiskProfileId());
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) Test(org.junit.Test)

Example 10 with ImageStorageDomainMap

use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap in project ovirt-engine by oVirt.

the class ImageStorageDomainMapDaoTest method testChangeQuotaForDisk.

@Test
public void testChangeQuotaForDisk() {
    // fetch image
    ImageStorageDomainMap imageStorageDomainMap = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0);
    Guid quotaId = imageStorageDomainMap.getQuotaId();
    // test that the current quota doesn't equal with the new quota
    if (quotaId.equals(FixturesTool.DEFAULT_QUOTA_GENERAL)) {
        fail("Same source and dest quota id, cannot perform test");
    }
    // change quota to the new quota 91
    dao.updateQuotaForImageAndSnapshots(FixturesTool.IMAGE_GROUP_ID, FixturesTool.STORAGE_DOMAIN_SCALE_SD5, FixturesTool.DEFAULT_QUOTA_GENERAL);
    // fetch the image again
    imageStorageDomainMap = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0);
    quotaId = imageStorageDomainMap.getQuotaId();
    // check that the new quota is the inserted one
    assertEquals("quota wasn't changed", FixturesTool.DEFAULT_QUOTA_GENERAL, quotaId);
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Aggregations

ImageStorageDomainMap (org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap)17 Test (org.junit.Test)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 DiskImageDynamic (org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)4 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)3 ImageStorageDomainMapId (org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId)3 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 OvfEntityData (org.ovirt.engine.core.common.businessentities.OvfEntityData)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)1 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1