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();
}
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());
}
}
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);
}
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());
}
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);
}
Aggregations