Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webadmin: warn when cloning snapshot with memory #583

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public enum HelpTag {

clone_template_from_snapshot("clone_template_from_snapshot", HelpTagType.WEBADMIN, "VMs Tab > Snapshots Sub-Tab > Clone Template From Snapshot"), //$NON-NLS-1$ //$NON-NLS-2$

clone_snapshot_with_memory("clone_snapshot_with_memory", HelpTagType.WEBADMIN, "VMs Tab > Snapshots Sub-Tab > Clone VM/Template From Snapshot With Memory"), //$NON-NLS-1$ //$NON-NLS-2$

clusters("clusters", HelpTagType.UNKNOWN), //$NON-NLS-1$

configure("configure", HelpTagType.WEBADMIN, "Main > Configure"), //$NON-NLS-1$ //$NON-NLS-2$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
import org.ovirt.engine.ui.uicommonweb.help.HelpTag;
import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel;
import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModelChain;
import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModelChain.ConfirmationModelChainItem;
import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
import org.ovirt.engine.ui.uicommonweb.models.Model;
import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
Expand Down Expand Up @@ -590,6 +592,12 @@ private void cancel() {
setWindow(null);
}

private void confirmClone(Runnable callback) {
ConfirmationModelChain chain = new ConfirmationModelChain();
chain.addConfirmation(createConfirmClone());
chain.execute(this, callback);
}

private void cloneTemplate() {
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
Expand Down Expand Up @@ -885,9 +893,9 @@ public void executeCommand(UICommand command) {
} else if (command == getRemoveCommand()) {
remove();
} else if (command == getCloneVmCommand()) {
cloneVM();
confirmClone(this::cloneVM);
} else if (command == getCloneTemplateCommand()) {
cloneTemplate();
confirmClone(this::cloneTemplate);
} else if ("OnNewTemplate".equals(command.getName())) { //$NON-NLS-1$
onCloneTemplate();
} else if ("OnRemove".equals(command.getName())) { //$NON-NLS-1$
Expand Down Expand Up @@ -915,4 +923,24 @@ protected boolean isSingleSelectionOnly() {
// Single selection model
return true;
}

private ConfirmationModelChainItem createConfirmClone() {
return new ConfirmationModelChainItem() {

@Override
public boolean isRequired() {
return getSelectedItem() != null && getSelectedItem().containsMemory();
}

@Override
public ConfirmationModel getConfirmation() {
ConfirmationModel confirmModel = new ConfirmationModel();
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().cloneFromSnapshotWithMemoryConfirmationTitle());
confirmModel.setMessage(ConstantsManager.getInstance().getConstants().cloneFromSnapshotWithMemoryConfirmationText());
confirmModel.setHelpTag(HelpTag.clone_snapshot_with_memory);
confirmModel.setHashName("clone_snapshot_with_memory"); //$NON-NLS-1$
return confirmModel;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ public interface UIConstants extends Constants {

String cloneVmFromSnapshotTitle();

String cloneFromSnapshotWithMemoryConfirmationTitle();

String cloneFromSnapshotWithMemoryConfirmationText();

String youAreAboutChangeClusterCompatibilityVersionMsg();

String youAreAboutChangeClusterCompatibilityVersionNonResponsiveHostsMsg();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ cloneTitle=Clone
cloneVmFromSnapshotTitle=Clone VM from Snapshot
cloneVmLunsWontBeCloned=VM's LUN(s) will not be cloned.
cloneVmTitle=Clone Virtual Machine
cloneFromSnapshotWithMemoryConfirmationTitle=Snapshot contains memory
cloneFromSnapshotWithMemoryConfirmationText=The Snapshot contains memory that will not be preserved and the guest file system may end up in an inconsistent state.\nAre you sure you want to continue?
close=Close
cloudInitAttachmentTypeBase64=Base64
cloudInitAttachmentTypePlainText=Plain Text
Expand Down