Search in sources :

Example 31 with VM

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

the class VmSnapshotListModel method postNameUniqueCheck.

private void postNameUniqueCheck(VM vm) {
    UnitVmModel model = (UnitVmModel) getWindow();
    VM newVm = buildVmOnNewTemplate(model, vm);
    AddVmTemplateFromSnapshotParameters parameters = new AddVmTemplateFromSnapshotParameters(newVm.getStaticData(), model.getName().getEntity(), model.getDescription().getEntity(), getSelectedItem().getId());
    BuilderExecutor.build(model, parameters, new UnitToAddVmTemplateParametersBuilder());
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.AddVmTemplateFromSnapshot, parameters, result -> {
        VmSnapshotListModel vmSnapshotListModel = (VmSnapshotListModel) result.getState();
        vmSnapshotListModel.getWindow().stopProgress();
        ActionReturnValue returnValueBase = result.getReturnValue();
        if (returnValueBase != null && returnValueBase.getSucceeded()) {
            vmSnapshotListModel.cancel();
        }
    }, this);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) VM(org.ovirt.engine.core.common.businessentities.VM) AddVmTemplateFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmTemplateFromSnapshotParameters)

Example 32 with VM

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

the class VmSnapshotListModel method onPreview.

private void onPreview() {
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        cancel();
        return;
    }
    VM vm = getEntity();
    SnapshotModel snapshotModel = (SnapshotModel) getWindow();
    boolean memory = false;
    List<DiskImage> disks = null;
    if (snapshotModel.isShowPartialSnapshotWarning()) {
        switch(snapshotModel.getPartialPreviewSnapshotOptions().getSelectedItem()) {
            case preserveActiveDisks:
                // get snapshot disks
                disks = snapshotModel.getDisks();
                // add active disks missed from snapshot
                disks.addAll(imagesSubtract(getVmDisks(), disks));
                break;
            case excludeActiveDisks:
                // nothing to do - default behaviour
                break;
            case openCustomPreviewDialog:
                setWindow(null);
                getCustomPreviewCommand().execute();
                return;
        }
    }
    if (snapshotModel.isShowMemorySnapshotWarning()) {
        memory = snapshotModel.getMemory().getEntity();
    }
    runTryBackToAllSnapshotsOfVm(snapshotModel, vm, snapshot, memory, disks, true, null);
}
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 33 with VM

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

the class VmSnapshotListModel method customPreview.

private void customPreview() {
    VM vm = getEntity();
    if (vm == null) {
        return;
    }
    PreviewSnapshotModel model = new PreviewSnapshotModel(vm, getSelectedItem().getId());
    model.setVmId(vm.getId());
    model.initialize();
    // Update according to the selected snapshot
    Snapshot selectedSnapshot = getSelectedItem();
    if (selectedSnapshot != null) {
        model.setSnapshotModel(getSnapshotsMap().get(selectedSnapshot.getId()));
    }
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().customPreviewSnapshotTitle());
    model.setHelpTag(HelpTag.custom_preview_snapshot);
    // $NON-NLS-1$
    model.setHashName("custom_preview_snapshot");
    // $NON-NLS-1$
    addCommands(model, "OnCustomPreview");
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 34 with VM

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

the class VmSnapshotListModel method cloneTemplate.

private void cloneTemplate() {
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        return;
    }
    if (getWindow() != null) {
        return;
    }
    final UnitVmModel model = new UnitVmModel(createNewTemplateBehavior(), this);
    setWindow(model);
    model.startProgress();
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
        NewTemplateVmModelBehavior behavior = (NewTemplateVmModelBehavior) model.getBehavior();
        behavior.setVm(vm);
        model.setTitle(ConstantsManager.getInstance().getConstants().newTemplateTitle());
        model.setHelpTag(HelpTag.clone_template_from_snapshot);
        // $NON-NLS-1$
        model.setHashName("clone_template_from_snapshot");
        model.setIsNew(true);
        model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
        model.initialize();
        model.getVmType().setSelectedItem(vm.getVmType());
        model.getIsHighlyAvailable().setEntity(vm.getStaticData().isAutoStartup());
        model.getCommands().add(// $NON-NLS-1$
        new UICommand("OnNewTemplate", VmSnapshotListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        // $NON-NLS-1$
        model.getCommands().add(UICommand.createCancelUiCommand("Cancel", VmSnapshotListModel.this));
        model.stopProgress();
    }), 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) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 35 with VM

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

the class VmSnapshotListModel method updateVmActiveDisks.

private void updateVmActiveDisks() {
    VM vm = getEntity();
    if (vm == null) {
        return;
    }
    AsyncDataProvider.getInstance().getVmDiskList(new AsyncQuery<>(disks -> {
        setVmDisks(disks.stream().filter(d -> d.getDiskStorageType() != DiskStorageType.LUN).map(d -> (DiskImage) d).collect(Collectors.toList()));
    }), vm.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) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

VM (org.ovirt.engine.core.common.businessentities.VM)591 Test (org.junit.Test)178 Guid (org.ovirt.engine.core.compat.Guid)150 ArrayList (java.util.ArrayList)130 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)82 HashMap (java.util.HashMap)69 List (java.util.List)65 VDS (org.ovirt.engine.core.common.businessentities.VDS)63 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)56 Map (java.util.Map)53 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)53 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)41 QueryType (org.ovirt.engine.core.common.queries.QueryType)36 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)33 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)32 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)32 Collectors (java.util.stream.Collectors)31 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)31