use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters in project ovirt-engine by oVirt.
the class InstanceTypeListModel method onEditInstanceType.
private void onEditInstanceType() {
UnitVmModel model = (UnitVmModel) getWindow();
if (!model.validateInstanceTypePart()) {
return;
}
VmTemplate instanceType = (VmTemplate) Cloner.clone(selectedItem);
instanceType.setTemplateType(VmEntityType.INSTANCE_TYPE);
buildVmStatic(instanceType);
instanceType.setDescription(model.getDescription().getEntity());
UpdateVmTemplateParameters updateInstanceTypeParameters = new UpdateVmTemplateParameters(instanceType);
updateInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
updateInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
updateInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
updateInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
if (model.getIsHeadlessModeEnabled().getEntity()) {
updateInstanceTypeParameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
}
setVmWatchdogToParams(model, updateInstanceTypeParameters);
setRngDeviceToParams(model, updateInstanceTypeParameters);
BuilderExecutor.build(model, updateInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
getWindow().startProgress();
Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, updateInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager, instanceType.getId()), this);
}
use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters in project ovirt-engine by oVirt.
the class UpdateClusterCommand method updateTemplates.
private boolean updateTemplates() {
for (VmTemplate template : templatesLockedForUpdate) {
// the object was loaded in before command execution started and thus the value may be outdated
template.setClusterCompatibilityVersion(getCluster().getCompatibilityVersion());
UpdateVmTemplateParameters parameters = new UpdateVmTemplateParameters(template);
// Locking by UpdateVmTemplate is disabled since templates are already locked in #getExclusiveLocks method.
parameters.setLockProperties(LockProperties.create(LockProperties.Scope.None));
parameters.setClusterLevelChangeFromVersion(oldCluster.getCompatibilityVersion());
updateRngDeviceIfNecessary(template.getId(), template.getCustomCompatibilityVersion(), parameters);
updateResumeBehavior(template);
final ActionReturnValue result = runInternalAction(ActionType.UpdateVmTemplate, parameters, cloneContextAndDetachFromParent());
if (!result.getSucceeded()) {
List<String> params = new ArrayList<>();
params.add("$action Update");
params.add("$type Template");
params.add(parseErrorMessage(result.getValidationMessages()));
List<String> messages = Backend.getInstance().getErrorsTranslator().translateErrorText(params);
failedUpgradeEntities.put(template.getName(), getFailedMessage(messages));
}
}
return true;
}
use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters 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);
}
Aggregations