use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder 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.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder in project ovirt-engine by oVirt.
the class VmListModel method getUpdateVmParameters.
public VmManagementParametersBase getUpdateVmParameters(boolean applyCpuChangesLater) {
UnitVmModel model = (UnitVmModel) getWindow();
VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getcurrentVm());
setVmWatchdogToParams(model, updateVmParams);
updateVmParams.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
updateVmParams.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
updateVmParams.setBalloonEnabled(balloonEnabled(model));
updateVmParams.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
updateVmParams.setApplyChangesLater(applyCpuChangesLater);
updateVmParams.setUpdateNuma(model.isNumaChanged());
updateVmParams.setAffinityLabels(model.getLabelList().getSelectedItems());
if (model.getIsHeadlessModeEnabled().getEntity()) {
updateVmParams.getVmStaticData().setDefaultDisplayType(DisplayType.none);
}
BuilderExecutor.build(new Pair<>((UnitVmModel) getWindow(), getSelectedItem()), updateVmParams, new VmIconUnitAndVmToParameterBuilder());
setRngDeviceToParams(model, updateVmParams);
BuilderExecutor.build(model, updateVmParams, new UnitToGraphicsDeviceParamsBuilder());
return updateVmParams;
}
use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onCloneVM.
private void onCloneVM() {
UnitVmModel model = (UnitVmModel) getWindow();
CloneVmFromSnapshotModelBehavior behavior = (CloneVmFromSnapshotModelBehavior) model.getBehavior();
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
cancel();
return;
}
if (!model.validate()) {
return;
}
VM vm = behavior.getVm();
// Save changes.
buildVmOnClone(model, vm);
vm.setUseHostCpuFlags(model.getHostCpu().getEntity());
vm.setDiskMap(behavior.getVm().getDiskMap());
HashMap<Guid, DiskImage> imageToDestinationDomainMap = model.getDisksAllocationModel().getImageToDestinationDomainMap();
AddVmFromSnapshotParameters parameters = new AddVmFromSnapshotParameters(vm.getStaticData(), snapshot.getId());
parameters.setDiskInfoDestinationMap(imageToDestinationDomainMap);
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
parameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
parameters.setVmId(new Guid(model.getVmId().getEntity()));
}
model.startProgress();
Frontend.getInstance().runAction(ActionType.AddVmFromSnapshot, parameters, result -> {
VmSnapshotListModel vmSnapshotListModel = (VmSnapshotListModel) result.getState();
vmSnapshotListModel.getWindow().stopProgress();
ActionReturnValue returnValueBase = result.getReturnValue();
if (returnValueBase != null && returnValueBase.getSucceeded()) {
vmSnapshotListModel.cancel();
vmSnapshotListModel.updateActionAvailability();
}
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder in project ovirt-engine by oVirt.
the class VmBaseListModel method saveNewVm.
private void saveNewVm(final UnitVmModel model) {
if (model.getProgress() != null) {
return;
}
model.startProgress();
VM vm = getcurrentVm();
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
vm.setId(new Guid(model.getVmId().getEntity()));
}
vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
AddVmParameters parameters = new AddVmParameters(vm);
parameters.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
parameters.setBalloonEnabled(balloonEnabled(model));
parameters.setCopyTemplatePermissions(model.getCopyPermissions().getEntity());
parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
parameters.setVmLargeIcon(IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon()));
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
setVmWatchdogToParams(model, parameters);
setRngDeviceToParams(model, parameters);
if (model.getIsHeadlessModeEnabled().getEntity()) {
parameters.getVmStaticData().setDefaultDisplayType(DisplayType.none);
}
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
parameters.setVmId(new Guid(model.getVmId().getEntity()));
}
Frontend.getInstance().runAction(model.getProvisioning().getEntity() ? ActionType.AddVmFromTemplate : ActionType.AddVm, parameters, createUnitVmModelNetworkAsyncCallback(vm, model), this);
}
use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder in project ovirt-engine by oVirt.
the class PoolListModel method savePoolPostValidation.
public void savePoolPostValidation() {
final PoolModel model = (PoolModel) getWindow();
VmPool pool = getCurrentPool();
setConfirmWindow(null);
// Save changes.
pool.setName(model.getName().getEntity());
pool.setVmPoolDescription(model.getDescription().getEntity());
pool.setClusterId(model.getSelectedCluster().getId());
pool.setComment(model.getComment().getEntity());
pool.setStateful(model.getPoolStateful().getEntity());
pool.setPrestartedVms(model.getPrestartedVms().getEntity());
pool.setMaxAssignedVmsPerUser(model.getMaxAssignedVmsPerUser().getEntity());
pool.setAutoStorageSelect(model.getDisksAllocationModel().getDiskAllocationTargetEnabled().getEntity());
EntityModel<VmPoolType> poolTypeSelectedItem = model.getPoolType().getSelectedItem();
pool.setVmPoolType(poolTypeSelectedItem.getEntity());
if (model.getSpiceProxyEnabled().getEntity()) {
pool.setSpiceProxy(model.getSpiceProxy().getEntity());
}
VM vm = buildVmOnSave(model);
vm.setVmInit(model.getVmInitModel().buildCloudInitParameters(model));
vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
vm.setStateless(false);
vm.setInstanceTypeId(model.getInstanceTypes().getSelectedItem().getId());
AddVmPoolParameters param = new AddVmPoolParameters(pool, vm, model.getNumOfDesktops().getEntity());
param.setStorageDomainId(Guid.Empty);
param.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
param.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
param.setRngDevice(model.getIsRngEnabled().getEntity() ? model.generateRngDevice() : null);
param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
param.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
if (model.getIsHeadlessModeEnabled().getEntity()) {
param.getVmStaticData().setDefaultDisplayType(DisplayType.none);
}
BuilderExecutor.build(model, param, new UnitToGraphicsDeviceParamsBuilder());
param.getVmStaticData().setUseHostCpuFlags(model.getHostCpu().getEntity());
param.getVmStaticData().setCpuPinning(model.getCpuPinning().getEntity());
if (model.getQuota().getSelectedItem() != null) {
vm.setQuotaId(model.getQuota().getSelectedItem().getId());
}
model.startProgress();
if (model.getIsNew()) {
if (model.getIcon().getEntity().isCustom()) {
param.setVmLargeIcon(model.getIcon().getEntity().getIcon());
}
Frontend.getInstance().runAction(ActionType.AddVmPool, param, result -> {
cancel();
stopProgress();
}, this);
} else {
Frontend.getInstance().runAction(ActionType.UpdateVmPool, param, result -> {
cancel();
stopProgress();
}, this);
}
}
Aggregations