Search in sources :

Example 61 with Snapshot

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

the class DiskImagesValidator method diskImagesSnapshotsNotAttachedToOtherVms.

public ValidationResult diskImagesSnapshotsNotAttachedToOtherVms(boolean onlyPlugged) {
    LinkedList<String> pluggedDiskSnapshotInfo = new LinkedList<>();
    for (DiskImage diskImage : diskImages) {
        List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), null);
        for (VmDevice device : devices) {
            if (device.getSnapshotId() != null && (!onlyPlugged || device.isPlugged())) {
                VM vm = getVmDao().get(device.getVmId());
                Snapshot snapshot = getSnapshotDao().get(device.getSnapshotId());
                pluggedDiskSnapshotInfo.add(String.format("%s ,%s, %s", diskImage.getDiskAlias(), snapshot.getDescription(), vm.getName()));
            }
        }
    }
    if (!pluggedDiskSnapshotInfo.isEmpty()) {
        EngineMessage message = onlyPlugged ? EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_PLUGGED_TO_ANOTHER_VM : EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_ATTACHED_TO_ANOTHER_VM;
        return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(pluggedDiskSnapshotInfo, "%n"))));
    }
    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) LinkedList(java.util.LinkedList) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 62 with Snapshot

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

the class VmSnapshotListModel method remove.

private void remove() {
    if (getEntity() != null) {
        if (getWindow() != null) {
            return;
        }
        Snapshot snapshot = getSelectedItem();
        ConfirmationModel model = new ConfirmationModel();
        setWindow(model);
        model.setTitle(ConstantsManager.getInstance().getConstants().deleteSnapshotTitle());
        model.setHelpTag(HelpTag.delete_snapshot);
        // $NON-NLS-1$
        model.setHashName("delete_snapshot");
        model.setMessage(ConstantsManager.getInstance().getMessages().areYouSureYouWantToDeleteSanpshot(DateTimeFormat.getFormat(DATE_FORMAT).format(snapshot.getCreationDate()), snapshot.getDescription()));
        // $NON-NLS-1$
        UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
        model.getCommands().add(tempVar);
        // $NON-NLS-1$
        UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
        model.getCommands().add(tempVar2);
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 63 with Snapshot

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

the class VmSnapshotListModel method onRemove.

private void onRemove() {
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        cancel();
        return;
    }
    VM vm = getEntity();
    if (vm != null) {
        Frontend.getInstance().runAction(ActionType.RemoveSnapshot, new RemoveSnapshotParameters(snapshot.getId(), vm.getId()), null, null);
    }
    getCanSelectSnapshot().setEntity(false);
    cancel();
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 64 with Snapshot

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

the class VmSnapshotListModel method onCustomPreview.

private void onCustomPreview() {
    VM vm = getEntity();
    PreviewSnapshotModel previewSnapshotModel = (PreviewSnapshotModel) getWindow();
    Snapshot snapshot = previewSnapshotModel.getSnapshotModel().getEntity();
    boolean memory = Boolean.TRUE.equals(previewSnapshotModel.getSnapshotModel().getMemory().getEntity());
    List<DiskImage> disks = previewSnapshotModel.getSelectedDisks();
    boolean isSnapshotsContainsLeases = previewSnapshotModel.isSnapshotsContainsLeases();
    Guid selectedSnapshotLeaseDomainId = previewSnapshotModel.getSelectedLease();
    runTryBackToAllSnapshotsOfVm(previewSnapshotModel, vm, snapshot, memory, disks, !(isSnapshotsContainsLeases && selectedSnapshotLeaseDomainId == null), selectedSnapshotLeaseDomainId);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 65 with Snapshot

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

the class VmSnapshotListModel method preview.

private void preview() {
    VM vm = getEntity();
    if (vm == null) {
        return;
    }
    final Snapshot snapshot = getSelectedItem();
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(v -> {
        ArrayList<DiskImage> snapshotDisks = v.getDiskList();
        List<DiskImage> disksExcludedFromSnapshot = imagesSubtract(getVmDisks(), snapshotDisks);
        boolean showMemorySnapshotWarning = isMemorySnapshotSupported() && snapshot.containsMemory();
        boolean showPartialSnapshotWarning = !disksExcludedFromSnapshot.isEmpty();
        if (showMemorySnapshotWarning || showPartialSnapshotWarning) {
            SnapshotModel model = new SnapshotModel();
            model.setVmDisks(getVmDisks());
            model.setDisks(snapshotDisks);
            model.setShowMemorySnapshotWarning(showMemorySnapshotWarning);
            model.setShowPartialSnapshotWarning(showPartialSnapshotWarning);
            if (showMemorySnapshotWarning) {
                model.setOldClusterVersionOfSnapshotWithMemory(v);
            }
            setWindow(model);
            model.setTitle(showPartialSnapshotWarning ? ConstantsManager.getInstance().getConstants().previewPartialSnapshotTitle() : ConstantsManager.getInstance().getConstants().previewSnapshotTitle());
            model.setHelpTag(showPartialSnapshotWarning ? HelpTag.preview_partial_snapshot : HelpTag.preview_snapshot);
            // $NON-NLS-1$ //$NON-NLS-2$
            model.setHashName(showPartialSnapshotWarning ? "preview_partial_snapshot" : "preview_snapshot");
            // $NON-NLS-1$
            addCommands(model, "OnPreview");
        } else {
            runTryBackToAllSnapshotsOfVm(null, v, snapshot, false, null, true, null);
        }
    }), snapshot.getId());
}
Also used : CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) QueryType(org.ovirt.engine.core.common.queries.QueryType) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SnapshotActionEnum(org.ovirt.engine.core.common.businessentities.SnapshotActionEnum) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) ActionUtils(org.ovirt.engine.core.common.ActionUtils) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) TryBackToAllSnapshotsOfVmParameters(org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters) StringHelper(org.ovirt.engine.core.compat.StringHelper) 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) AddVmTemplateFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmTemplateFromSnapshotParameters) Comparator(java.util.Comparator) Collections(java.util.Collections) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

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