Search in sources :

Example 36 with Snapshot

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

the class HotUnplugMemoryCommand method getNextRunConfiguration.

private VmStatic getNextRunConfiguration() {
    final Snapshot snapshot = snapshotDao.get(getVmId(), Snapshot.SnapshotType.NEXT_RUN);
    if (snapshot == null) {
        return null;
    }
    final VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
    return vm.getStaticData();
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 37 with Snapshot

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

the class IsBalloonEnabledQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Snapshot snapshot = snapshotDao.get(getParameters().getId(), Snapshot.SnapshotType.NEXT_RUN, getUserID(), getParameters().isFiltered());
    if (snapshot != null) {
        VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
        getQueryReturnValue().setReturnValue(VmDeviceCommonUtils.isVmDeviceExists(vm.getManagedVmDeviceMap(), VmDeviceType.MEMBALLOON));
    } else {
        getQueryReturnValue().setReturnValue(vmDeviceDao.isMemBalloonEnabled(getParameters().getId()));
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 38 with Snapshot

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

the class SnapshotsValidator method isLeaseDomainIdBelongsToSnapshot.

/**
 * Checks if that the destination lease domain ID belongs to one of the VM's snapshots.
 */
public ValidationResult isLeaseDomainIdBelongsToSnapshot(Guid vmId, Guid dstLeaseDomainId) {
    List<Snapshot> allVmSnapshots = snapshotDao.getAllWithConfiguration(vmId);
    boolean leaseStorageDomainValid = allVmSnapshots.stream().filter(snapshot -> snapshot.getVmConfiguration() != null).anyMatch(snapshot -> dstLeaseDomainId.equals(OvfUtils.fetchLeaseDomainId(snapshot.getVmConfiguration())));
    return leaseStorageDomainValid ? ValidationResult.VALID : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_LEASE_DOMAIN_ID_IS_NOT_VALID);
}
Also used : SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) Guid(org.ovirt.engine.core.compat.Guid) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) SnapshotDao(org.ovirt.engine.core.dao.SnapshotDao) Set(java.util.Set) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OvfUtils(org.ovirt.engine.core.utils.OvfUtils) Inject(javax.inject.Inject) List(java.util.List) Stream(java.util.stream.Stream) DiskImageDao(org.ovirt.engine.core.dao.DiskImageDao) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 39 with Snapshot

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

the class ImportVmCommandTest method createVmWithNoSnapshots.

protected VM createVmWithNoSnapshots() {
    final VM v = new VM();
    v.setId(Guid.newGuid());
    Snapshot activeSnapshot = new Snapshot();
    activeSnapshot.setVmId(v.getId());
    DiskImage activeImage = createDiskImage(Guid.newGuid(), Guid.newGuid(), activeSnapshot.getId(), true);
    activeSnapshot.setDiskImages(Collections.singletonList(activeImage));
    v.setImages(new ArrayList<>(Collections.singletonList(activeImage)));
    v.setSnapshots(new ArrayList<>(Collections.singletonList(activeSnapshot)));
    v.setDiskMap(Collections.singletonMap(activeImage.getId(), activeImage));
    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 40 with Snapshot

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

the class ImportVmCommandTest method testAliasGenerationByAddVmImagesAndSnapshotsWithCollapse.

/* Tests for alias generation in addVmImagesAndSnapshots() */
@Test
public void testAliasGenerationByAddVmImagesAndSnapshotsWithCollapse() {
    cmd.getParameters().setCopyCollapse(true);
    cmd.init();
    DiskImage collapsedDisk = cmd.getParameters().getVm().getImages().get(1);
    doNothing().when(cmd).saveImage(collapsedDisk);
    doNothing().when(cmd).saveBaseDisk(collapsedDisk);
    doNothing().when(cmd).saveDiskImageDynamic(collapsedDisk);
    doNothing().when(cmd).saveDiskVmElement(any(), any(), any());
    doReturn(new Snapshot()).when(cmd).addActiveSnapshot(any());
    cmd.addVmImagesAndSnapshots();
    assertEquals("Disk alias not generated", "testVm_Disk1", collapsedDisk.getDiskAlias());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

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