use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class TemplateListModel method postNameUniqueCheck.
public void postNameUniqueCheck() {
final UnitVmModel model = (UnitVmModel) getWindow();
if (model.getProgress() != null) {
return;
}
VmTemplate selectedItem;
if (model.getBehavior().isExistingTemplateBehavior()) {
selectedItem = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate();
} else {
selectedItem = ((ExistingBlankTemplateModelBehavior) model.getBehavior()).getVmTemplate();
}
final VmTemplate template = (VmTemplate) Cloner.clone(selectedItem);
final String iconForParameters = IconCache.getInstance().getIcon(selectedItem.getLargeIconId()).equals(model.getIcon().getEntity().getIcon()) ? null : IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon());
// Save changes.
buildTemplateOnSave(model, template);
template.setCreatedByUserId(selectedItem.getCreatedByUserId());
model.startProgress();
template.setVmInit(model.getVmInitModel().buildCloudInitParameters(model));
UpdateVmTemplateParameters parameters = new UpdateVmTemplateParameters(template);
parameters.setVmLargeIcon(iconForParameters);
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
setVmWatchdogToParams(model, parameters);
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
setVmRngDeviceToParams(model, parameters);
parameters.setBalloonEnabled(balloonEnabled(model));
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
if (model.getIsHeadlessModeEnabled().getEntity()) {
parameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
}
Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, parameters, result -> {
TemplateListModel localModel = (TemplateListModel) result.getState();
localModel.postUpdateVmTemplate(result.getReturnValue());
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class TemplateListModel method executeCommand.
@Override
public void executeCommand(UICommand command) {
super.executeCommand(command);
if (command == getEditCommand()) {
edit();
} else if (command == getRemoveCommand()) {
remove();
} else if (command == getExportCommand()) {
export();
} else if (command == getCreateVmFromTemplateCommand()) {
createVMFromTemplate();
} else if ("Cancel".equals(command.getName())) {
// $NON-NLS-1$
cancel();
} else if ("OnExport".equals(command.getName())) {
// $NON-NLS-1$
onExport();
} else if ("OnSave".equals(command.getName())) {
// $NON-NLS-1$
onSave();
} else if ("OnSaveVm".equals(command.getName())) {
// $NON-NLS-1$
onSaveVm();
} else if ("postNameUniqueCheck".equals(command.getName())) {
// $NON-NLS-1$
postNameUniqueCheck();
setConfirmWindow(null);
} else if ("OnRemove".equals(command.getName())) {
// $NON-NLS-1$
onRemove();
} else if ("OnExportNoTemplates".equals(command.getName())) {
// $NON-NLS-1$
doExport();
} else if ("CancelConfirmation".equals(command.getName())) {
// $NON-NLS-1$
cancelConfirmation();
} else if ("SaveOrUpdateVM".equals(command.getName())) {
// $NON-NLS-1$
UnitVmModel model = (UnitVmModel) getWindow();
if (!model.validate()) {
return;
}
saveOrUpdateVM(model);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class VmBaseListModel method displayHighPerformanceConfirmationPopup.
protected void displayHighPerformanceConfirmationPopup() {
final UnitVmModel model = (UnitVmModel) getWindow();
if (model == null || model.getProgress() != null) {
return;
}
VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
// Handle CPU Pinning topology
final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
// Handle NUMA
final boolean isVmVirtNumaSet = model.getNumaEnabled().getEntity() && model.getNumaNodeCount().getEntity() > 0;
final boolean isVmVirtNumaPinned = model.getVmNumaNodes() != null && !model.getVmNumaNodes().isEmpty() && model.getVmNumaNodes().stream().filter(x -> !x.getVdsNumaNodeList().isEmpty()).count() > 0;
confirmModel.addRecommendationForVirtNumaSetAndPinned(isVmVirtNumaSet, isVmVirtNumaPinned);
// Handle Huge Pages
KeyValueModel keyValue = model.getCustomPropertySheet();
// $NON-NLS-1$
final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
// Handle KSM (Kernel Same Page Merging)
confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
// If there are recommendations to display and it is not a Pool VM then display the popup
if (!confirmModel.getRecommendationsList().isEmpty() && !model.isVmAttachedToPool()) {
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformanceVmTitle());
confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_vm);
// $NON-NLS-1$
confirmModel.setHashName("configuration_changes_for_high_performance_vm");
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("SaveOrUpdateVM", VmBaseListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
confirmModel.getCommands().add(// $NON-NLS-1$
UICommand.createCancelUiCommand("CancelConfirmation", VmBaseListModel.this));
setConfirmWindow(null);
setConfirmWindow(confirmModel);
} else {
saveOrUpdateVM(model);
}
}
Aggregations