Gilad Chaplik has uploaded a new change for review. Change subject: restapi: Failed to update VM Cluster in SDK ......................................................................
restapi: Failed to update VM Cluster in SDK When updating VM's cluster in SDK, entire element is sent, including old CPU profile which will not match updated cluster. To prevent user from handling it, and to keep backwards compatibility, resetting the cpu profile when it matches the old one. Change-Id: Idd7dcf86d7257653463e91110909204b6576ca81 Bug-Url: https://bugzilla.redhat.com/1158458 Signed-off-by: Gilad Chaplik <[email protected]> --- M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java 1 file changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/35762/1 diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java index 0c53b1f..75384ce 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java @@ -10,6 +10,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.apache.commons.lang.ObjectUtils; import org.ovirt.engine.api.common.util.DetailHelper; import org.ovirt.engine.api.common.util.QueryHelper; import org.ovirt.engine.api.model.Action; @@ -128,9 +129,16 @@ validateParameters(incoming); if (incoming.isSetCluster() && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) { Guid clusterId = lookupClusterId(incoming); - if(!clusterId.toString().equals(get().getCluster().getId())){ + VM vm = get(); + if(!clusterId.toString().equals(vm.getCluster().getId())){ performAction(VdcActionType.ChangeVMCluster, new ChangeVMClusterParameters(clusterId, guid)); + // When performing update via sdk, entire element is sent including old profile, so resetting it + // to keep backwards compatibility. + if (incoming.getCpuProfile() != null && vm.getCpuProfile() != null + && ObjectUtils.equals(incoming.getCpuProfile().getId(), vm.getCpuProfile().getId())) { + incoming.getCpuProfile().setId(null); + } } } if (!isFiltered()) { -- To view, visit http://gerrit.ovirt.org/35762 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idd7dcf86d7257653463e91110909204b6576ca81 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
