Search in sources :

Example 41 with Snapshot

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

the class ImportVmCommandTest method createVmWithSnapshots.

protected VM createVmWithSnapshots() {
    final VM v = new VM();
    v.setId(Guid.newGuid());
    Snapshot baseSnapshot = new Snapshot();
    baseSnapshot.setVmId(v.getId());
    Snapshot activeSnapshot = new Snapshot();
    activeSnapshot.setVmId(v.getId());
    DiskImage baseImage = createDiskImage(Guid.newGuid(), Guid.newGuid(), baseSnapshot.getId(), false);
    DiskImage activeImage = createDiskImage(baseImage.getId(), baseImage.getImageId(), activeSnapshot.getId(), true);
    baseSnapshot.setDiskImages(Collections.singletonList(baseImage));
    activeSnapshot.setDiskImages(Collections.singletonList(activeImage));
    v.setDiskMap(Collections.singletonMap(activeImage.getId(), activeImage));
    v.setImages(new ArrayList<>(Arrays.asList(baseImage, activeImage)));
    v.setSnapshots(new ArrayList<>(Arrays.asList(baseSnapshot, activeSnapshot)));
    v.setClusterId(Guid.Empty);
    return v;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 42 with Snapshot

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

the class SnapshotDaoTest method updateStatus.

@Test
public void updateStatus() throws Exception {
    Snapshot snapshot = dao.get(getExistingEntityId());
    snapshot.setStatus(SnapshotStatus.LOCKED);
    dao.updateStatus(snapshot.getId(), snapshot.getStatus());
    assertEquals(snapshot, dao.get(snapshot.getId()));
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 43 with Snapshot

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

the class SnapshotDaoTest method getFilteredWithPermissions.

@Test
public void getFilteredWithPermissions() {
    Snapshot snapshot = dao.get(EXISTING_SNAPSHOT_ID, PRIVILEGED_USER_ID, true);
    assertNotNull(snapshot);
    assertEquals(existingEntity, snapshot);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 44 with Snapshot

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

the class SnapshotDaoTest method getFilteredWithPermissionsNoPermissions.

@Test
public void getFilteredWithPermissionsNoPermissions() {
    Snapshot snapshot = dao.get(EXISTING_SNAPSHOT_ID, UNPRIVILEGED_USER_ID, true);
    assertNull(snapshot);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 45 with Snapshot

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

the class SnapshotDaoTest method removeMemoryFromActiveSnapshot.

@Test
public void removeMemoryFromActiveSnapshot() throws Exception {
    Snapshot snapshot = dao.get(EXISTING_SNAPSHOT_ID2);
    assertEquals(EXISTING_MEMORY_DUMP_DISK_ID, snapshot.getMemoryDiskId());
    assertEquals(EXISTING_MEMORY_CONF_DISK_ID, snapshot.getMetadataDiskId());
    dao.removeMemoryFromActiveSnapshot(EXISTING_VM_ID2);
    snapshot = dao.get(EXISTING_SNAPSHOT_ID2);
    assertNull(snapshot.getMemoryDiskId());
    assertNull(snapshot.getMetadataDiskId());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Aggregations

Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)96 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)33 VM (org.ovirt.engine.core.common.businessentities.VM)32 Guid (org.ovirt.engine.core.compat.Guid)30 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)15 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)12 List (java.util.List)11 SnapshotStatus (org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus)9 Collections (java.util.Collections)8 Date (java.util.Date)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 SnapshotType (org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType)8 EngineException (org.ovirt.engine.core.common.errors.EngineException)8 ActionType (org.ovirt.engine.core.common.action.ActionType)7 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)6 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5