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);
}
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);
}
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");
}
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());
}
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());
}
Aggregations