Search in sources :

Example 11 with Snapshot

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

the class DiskSnapshotsValidatorTest method diskSnapshotsCanBePreviewed.

@Test
public void diskSnapshotsCanBePreviewed() {
    Snapshot activeSnapshot = getActiveSnapshot();
    when(snapshotDao.get(any())).thenReturn(activeSnapshot);
    assertThat(validator.canDiskSnapshotsBePreviewed(activeSnapshot.getId()), isValid());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 12 with Snapshot

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

the class SnapshotModel method updateVmConfiguration.

public void updateVmConfiguration(final AsyncCallback<Void> onUpdateAsyncCallback) {
    Snapshot snapshot = getEntity();
    if (snapshot == null) {
        return;
    }
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
        Snapshot snapshot1 = getEntity();
        if (vm != null && snapshot1 != null) {
            setVm(vm);
            setDisks(vm.getDiskList());
            setNics(vm.getInterfaces());
            setApps(Arrays.asList(snapshot1.getAppList() != null ? snapshot1.getAppList().split(",") : // $NON-NLS-1$
            new String[] {}));
            Collections.sort(getDisks(), new DiskByDiskAliasComparator());
            Collections.sort(getNics(), new LexoNumericNameableComparator<>());
        }
        onUpdateAsyncCallback.onSuccess(null);
    }), snapshot.getId());
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Version(org.ovirt.engine.core.compat.Version) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 13 with Snapshot

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

the class SnapshotModel method showWarningForByVmSnapshotsValidation.

private boolean showWarningForByVmSnapshotsValidation(List<Snapshot> snapshots) {
    for (Snapshot snapshot : snapshots) {
        if (!validateNewSnapshotByStatus(snapshot.getStatus()) || !validateNewSnapshotByType(snapshot.getType())) {
            getDescription().setIsAvailable(false);
            getMemory().setIsAvailable(false);
            return true;
        }
    }
    return false;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot)

Example 14 with Snapshot

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

the class RunVmCommand method removeMemoryFromActiveSnapshot.

private void removeMemoryFromActiveSnapshot() {
    // getActiveSnapshot fetches eagerly from the DB, cache it so we can remove the memory volumes
    Snapshot activeSnapshot = getActiveSnapshot();
    if (!activeSnapshot.containsMemory()) {
        return;
    }
    snapshotDao.removeMemoryFromActiveSnapshot(getVmId());
    // If the memory volumes are not used by any other snapshot, we can remove them
    if (snapshotDao.getNumOfSnapshotsByDisks(activeSnapshot) == 0) {
        removeMemoryDisks(activeSnapshot);
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot)

Example 15 with Snapshot

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

the class ProcessDownVmCommand method applyNextRunConfiguration.

/**
 * Update VM configuration with NEXT_RUN configuration, if exists.
 */
private void applyNextRunConfiguration() {
    // Remove snpashot first, in case other update is in progress, it will block this one with exclusive lock
    // and any newer update should be preffered to this one.
    Snapshot runSnap = snapshotDao.get(getVmId(), SnapshotType.NEXT_RUN);
    if (runSnap != null && getVm().getStatus() != VMStatus.Suspended) {
        log.debug("Attempt to apply NEXT_RUN snapshot for VM '{}'", getVmId());
        EngineLock updateVmLock = createUpdateVmLock();
        if (lockManager.acquireLock(updateVmLock).getFirst()) {
            snapshotDao.remove(runSnap.getId());
            Date originalCreationDate = getVm().getVmCreationDate();
            snapshotsManager.updateVmFromConfiguration(getVm(), runSnap.getVmConfiguration());
            // override creation date because the value in the config is the creation date of the config, not the vm
            getVm().setVmCreationDate(originalCreationDate);
            ActionReturnValue result = runInternalAction(ActionType.UpdateVm, createUpdateVmParameters(), ExecutionHandler.createInternalJobContext(updateVmLock));
            if (result.getActionReturnValue() != null && result.getActionReturnValue().equals(ActionType.UpdateVmVersion)) {
                // Template-version changed
                templateVersionChanged = true;
            }
        } else {
            log.warn("Could not acquire lock for UpdateVmCommand to apply Next Run Config of VM '{}'", getVmId());
        }
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) Date(java.util.Date)

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