use of org.ovirt.engine.core.common.action.ChangeVMClusterParameters 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.ChangeVMClusterParameters in project ovirt-engine by oVirt.
the class BackendVmResource method update.
@Override
public Vm update(Vm incoming) {
validateParameters(incoming);
if (incoming.isSetCluster() && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) {
Guid clusterId = lookupClusterId(incoming);
if (!clusterId.toString().equals(get().getCluster().getId())) {
performAction(ActionType.ChangeVMCluster, // TODO: change 'null' to 'incoming.getVmCompa...' when REST support is added
new ChangeVMClusterParameters(clusterId, guid, null));
}
}
if (!isFiltered()) {
if (incoming.isSetPlacementPolicy()) {
parent.validateAndUpdateHostsInPlacementPolicy(incoming.getPlacementPolicy());
}
} else {
incoming.setPlacementPolicy(null);
}
QueryType queryType = isNextRunRequested() ? QueryType.GetVmNextRunConfiguration : QueryType.GetVmByVmId;
Vm vm = performUpdate(incoming, new QueryIdResolver<>(queryType, IdQueryParameters.class), ActionType.UpdateVm, new UpdateParametersProvider());
if (vm != null) {
DisplayHelper.adjustDisplayData(this, vm, false);
removeRestrictedInfo(vm);
}
return vm;
}
use of org.ovirt.engine.core.common.action.ChangeVMClusterParameters in project ovirt-engine by oVirt.
the class MigrateVmCommand method updateVmAfterMigrationToDifferentCluster.
private void updateVmAfterMigrationToDifferentCluster() {
if (getParameters().getTargetClusterId() == null || getVm().getClusterId().equals(getParameters().getTargetClusterId())) {
return;
}
ChangeVMClusterParameters params = new ChangeVMClusterParameters(getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion());
setSucceeded(backend.runInternalAction(ActionType.ChangeVMCluster, params).getSucceeded());
}
Aggregations