Search in sources :

Example 81 with Snapshot

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

the class MemoryUtils method getMemoryDiskIdsFromSnapshots.

public static Set<Guid> getMemoryDiskIdsFromSnapshots(List<Snapshot> snapshots) {
    Set<Guid> memoryDiskIds = new HashSet<>();
    for (Snapshot snapshot : snapshots) {
        if (snapshot.containsMemory()) {
            memoryDiskIds.add(snapshot.getMemoryDiskId());
            memoryDiskIds.add(snapshot.getMetadataDiskId());
        }
    }
    return memoryDiskIds;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 82 with Snapshot

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

the class ImportVmCommandTest method testCDANoCollapseNoSnapshots.

@Test
public void testCDANoCollapseNoSnapshots() {
    final VM v = createVmWithNoSnapshots();
    v.setName("testVm");
    cmd.getParameters().setVm(v);
    cmd.getParameters().setCopyCollapse(false);
    cmd.init();
    DiskImage activeDisk = cmd.getParameters().getVm().getImages().get(0);
    doNothing().when(cmd).saveImage(activeDisk);
    doNothing().when(cmd).saveDiskImageDynamic(activeDisk);
    doNothing().when(cmd).saveBaseDisk(activeDisk);
    doNothing().when(cmd).saveDiskVmElement(any(), any(), any());
    doReturn(new Snapshot()).when(cmd).addActiveSnapshot(any());
    cmd.addVmImagesAndSnapshots();
    assertEquals("Disk alias not generated", "testVm_Disk1", activeDisk.getDiskAlias());
}
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) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 83 with Snapshot

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

the class GetVmConfigurationBySnapshotQueryTest method createSnapshot.

private Snapshot createSnapshot(Guid existingSnapshotId) {
    Snapshot snapshot = new Snapshot();
    snapshot.setId(existingSnapshotId);
    snapshot.setVmId(existingVmId);
    snapshot.setVmConfiguration(EXISTING_VM_NAME);
    return snapshot;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot)

Example 84 with Snapshot

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

the class ExportVmCommand method copyAllMemoryImages.

private void copyAllMemoryImages(Guid containerID) {
    for (Snapshot snapshot : snapshotsWithMemory) {
        // copy the memory dump image
        DiskImage dumpImage = (DiskImage) diskDao.get(snapshot.getMemoryDiskId());
        ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage(containerID, dumpImage));
        if (!vdcRetValue.getSucceeded()) {
            throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
        }
        // TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
        getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
        // copy the memory configuration (of the VM) image
        // This volume is always of type 'sparse' and format 'cow' so no need to convert,
        // and there're no snapshots for it so no reason to use copy collapse
        DiskImage confImage = (DiskImage) diskDao.get(snapshot.getMetadataDiskId());
        vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParameters(containerID, confImage));
        if (!vdcRetValue.getSucceeded()) {
            throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
        }
        // TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
        getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 85 with Snapshot

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

the class ImportVmCommand method determineDomainsForMemoryImagesAndCreateDummies.

/**
 * For each snapshot that has memory volume this method find a suitable storage domain and adds a dummy
 * memory disks for future storage space validation
 *
 * @return true if we managed to assign storage domain for every memory volume, false otherwise
 */
private boolean determineDomainsForMemoryImagesAndCreateDummies(List<DiskImage> disksList) {
    for (Snapshot snapshot : getVm().getSnapshots()) {
        if (!snapshot.containsMemory() || memoryDiskDomainMap.containsKey(snapshot.getMemoryDiskId())) {
            continue;
        }
        StorageDomain storageDomain = findDomainForMemoryImagesAndCreateDummies(disksList);
        if (storageDomain == null) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_NO_SUITABLE_DOMAIN_FOUND);
        }
        memoryDiskDomainMap.put(snapshot.getMemoryDiskId(), storageDomain.getId());
        memoryDiskDomainMap.put(snapshot.getMetadataDiskId(), storageDomain.getId());
    }
    return true;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain)

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