Search in sources :

Example 26 with Snapshot

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

the class ImportValidator method validateStorageExistsForMemoryDisks.

public ValidationResult validateStorageExistsForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) {
    for (Snapshot snap : snapshots) {
        if (snap.containsMemory()) {
            DiskImage memoryDump = (DiskImage) getDiskDao().get(snap.getMemoryDiskId());
            StorageDomain dumpSd = getStorageDomainDao().getForStoragePool(memoryDump.getStorageIds().get(0), params.getStoragePoolId());
            ValidationResult dumpSdResult = new StorageDomainValidator(dumpSd).isDomainExistAndActive();
            if (!handleStorageValidationResult(dumpSdResult, memoryDump, snap, failedDisksToImport) && !allowPartial) {
                return dumpSdResult;
            }
            DiskImage memoryConf = (DiskImage) getDiskDao().get(snap.getMetadataDiskId());
            StorageDomain confSd = getStorageDomainDao().getForStoragePool(memoryConf.getStorageIds().get(0), params.getStoragePoolId());
            ValidationResult confSdResult = new StorageDomainValidator(confSd).isDomainExistAndActive();
            if (!handleStorageValidationResult(confSdResult, memoryConf, snap, failedDisksToImport) && !allowPartial) {
                return confSdResult;
            }
        }
    }
    return ValidationResult.VALID;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 27 with Snapshot

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

the class DiskImagesValidator method diskImagesSnapshotsAttachedToVm.

public ValidationResult diskImagesSnapshotsAttachedToVm(Guid vmId) {
    LinkedList<String> diskSnapshotInfo = new LinkedList<>();
    VM vm = getVmDao().get(vmId);
    for (DiskImage diskImage : diskImages) {
        List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), vmId);
        if (devices.isEmpty()) {
            // The specified disk image does not belong to the vm
            Snapshot snapshot = getSnapshotDao().get(diskImage.getSnapshotId());
            Disk disk = getDbFacade().getDiskDao().get(diskImage.getId());
            diskSnapshotInfo.add(String.format("%s ,%s", disk.getDiskAlias(), snapshot.getDescription()));
        }
    }
    if (!diskSnapshotInfo.isEmpty()) {
        EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_NOT_ATTACHED_TO_VM;
        return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(diskSnapshotInfo, "%n"))), String.format("$vmName %s", vm.getName()));
    }
    return ValidationResult.VALID;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) LinkedList(java.util.LinkedList) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 28 with Snapshot

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

the class GetAllVmSnapshotsByVmIdQueryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    vmId = Guid.newGuid();
    snapshot = new Snapshot(Guid.newGuid(), SnapshotStatus.OK, vmId, null, SnapshotType.REGULAR, "", new Date(), "");
    setUpDaoMocks();
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Date(java.util.Date) Before(org.junit.Before)

Example 29 with Snapshot

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

the class GetAllVmSnapshotsWithLeasesFromConfigurationByVmIdQueryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    vmId = Guid.newGuid();
    snapshot = new Snapshot(Guid.newGuid(), SnapshotStatus.OK, vmId, null, SnapshotType.REGULAR, "", new Date(), "");
    disk1 = new DiskImage();
    disk2 = new DiskImage();
    snapshotVmConfigurationHelper = spy(new SnapshotVmConfigurationHelper());
    when(getQuery().getSnapshotVmConfigurationHelper()).thenReturn(snapshotVmConfigurationHelper);
    setUpDaoMocks();
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Date(java.util.Date) Before(org.junit.Before)

Example 30 with Snapshot

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

the class RemoveSnapshotCommandTest method mockSnapshot.

private void mockSnapshot(SnapshotType snapshotType) {
    Snapshot snapshot = new Snapshot();
    snapshot.setId(cmd.getParameters().getSnapshotId());
    snapshot.setType(snapshotType);
    doReturn(snapshot).when(snapshotDao).get(snapshot.getId());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot)

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