use of org.ovirt.engine.core.common.action.VmManagementParametersBase 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.core.common.action.VmManagementParametersBase in project ovirt-engine by oVirt.
the class VmListModel method updateExistingVm.
private void updateExistingVm(final boolean applyCpuChangesLater) {
final UnitVmModel model = (UnitVmModel) getWindow();
if (model.getProgress() != null) {
return;
}
// runEditVM: should be true if Cluster hasn't changed or if
// Cluster has changed and Editing it in the Backend has succeeded:
VM selectedItem = getSelectedItem();
Guid oldClusterID = selectedItem.getClusterId();
Guid newClusterID = model.getSelectedCluster().getId();
if (!oldClusterID.equals(newClusterID)) {
ChangeVMClusterParameters parameters = new ChangeVMClusterParameters(newClusterID, getcurrentVm().getId(), model.getCustomCompatibilityVersion().getSelectedItem());
model.startProgress();
Frontend.getInstance().runAction(ActionType.ChangeVMCluster, parameters, result -> {
final VmListModel<Void> vmListModel = (VmListModel<Void>) result.getState();
ActionReturnValue returnValueBase = result.getReturnValue();
if (returnValueBase != null && returnValueBase.getSucceeded()) {
VM vm = vmListModel.getcurrentVm();
VmManagementParametersBase updateVmParams = vmListModel.getUpdateVmParameters(applyCpuChangesLater);
Frontend.getInstance().runAction(ActionType.UpdateVm, updateVmParams, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, vm.getId()), vmListModel);
} else {
vmListModel.getWindow().stopProgress();
}
}, this);
} else {
model.startProgress();
VmManagementParametersBase updateVmParams = getUpdateVmParameters(applyCpuChangesLater);
Frontend.getInstance().runAction(ActionType.UpdateVm, updateVmParams, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, getcurrentVm().getId()), this);
}
}
use of org.ovirt.engine.core.common.action.VmManagementParametersBase in project ovirt-engine by oVirt.
the class UpdateVmPoolCommand method updatePoolVms.
private void updatePoolVms(List<VM> vmsInPool) {
// new latest value
boolean isUpdatedPoolLatest = getParameters().getVmStaticData().isUseLatestVersion();
vmTemplateHandler.lockVmTemplateInTransaction(getParameters().getVmStaticData().getVmtGuid(), getCompensationContext());
for (VM vm : vmsInPool) {
VmManagementParametersBase updateParams = new VmManagementParametersBase(vm);
updateParams.getVmStaticData().setUseLatestVersion(isUpdatedPoolLatest);
if (!isUpdatedPoolLatest) {
updateParams.getVmStaticData().setVmtGuid(getParameters().getVmStaticData().getVmtGuid());
}
ActionReturnValue result = runInternalActionWithTasksContext(ActionType.UpdateVm, updateParams, getLock());
getTaskIdList().addAll(result.getInternalVdsmTaskIdList());
setSucceeded(getSucceeded() && result.getSucceeded());
}
vmTemplateHandler.unlockVmTemplate(getParameters().getVmStaticData().getVmtGuid());
}
use of org.ovirt.engine.core.common.action.VmManagementParametersBase in project ovirt-engine by oVirt.
the class UpdateVmTemplateCommand method updateVmsOfInstanceType.
/**
* only in case of InstanceType update, update all vms that are bound to it
*/
private void updateVmsOfInstanceType() {
if (!isInstanceType()) {
return;
}
// get vms from db
List<VM> vmsToUpdate = vmDao.getVmsListByInstanceType(getVmTemplateId());
for (VM vm : vmsToUpdate) {
VmManagementParametersBase params = new VmManagementParametersBase(vm);
params.setApplyChangesLater(true);
runInternalAction(ActionType.UpdateVm, params);
}
}
use of org.ovirt.engine.core.common.action.VmManagementParametersBase in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method createUpdateVmParameters.
private VmManagementParametersBase createUpdateVmParameters() {
// clear non updateable fields got from config
getVm().setExportDate(null);
getVm().setOvfVersion(null);
VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
updateVmParams.setUpdateWatchdog(true);
updateVmParams.setSoundDeviceEnabled(false);
updateVmParams.setBalloonEnabled(false);
updateVmParams.setVirtioScsiEnabled(false);
updateVmParams.setClearPayload(true);
updateVmParams.setUpdateRngDevice(true);
for (GraphicsType graphicsType : GraphicsType.values()) {
updateVmParams.getGraphicsDevices().put(graphicsType, null);
}
for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
switch(device.getType()) {
case WATCHDOG:
updateVmParams.setWatchdog(new VmWatchdog(device));
break;
case SOUND:
updateVmParams.setSoundDeviceEnabled(true);
break;
case BALLOON:
updateVmParams.setBalloonEnabled(true);
break;
case CONTROLLER:
if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
updateVmParams.setVirtioScsiEnabled(true);
}
break;
case DISK:
if (VmPayload.isPayload(device.getSpecParams())) {
updateVmParams.setVmPayload(new VmPayload(device));
}
break;
case CONSOLE:
updateVmParams.setConsoleEnabled(true);
break;
case RNG:
updateVmParams.setRngDevice(new VmRngDevice(device));
break;
case GRAPHICS:
updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
break;
default:
}
}
// clear these fields as these are non updatable
getVm().getManagedVmDeviceMap().clear();
getVm().getUnmanagedDeviceList().clear();
return updateVmParams;
}
Aggregations