Bug 1464819

Summary: [API] Setting Custom Compatibility Version for a VM via REST api to a none/empty value is not working
Product: Red Hat Enterprise Virtualization Manager Reporter: Germano Veit Michel <gveitmic>
Component: ovirt-engineAssignee: Sharon Gratch <sgratch>
Status: CLOSED ERRATA QA Contact: Israel Pinto <ipinto>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.2CC: bgraveno, bugs, lsurette, michal.skrivanek, mtessun, pstehlik, rbalakri, Rhev-m-bugs, sgratch, srevivo, tjelinek, ykaul
Target Milestone: ovirt-4.1.5Keywords: ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, setting the Custom Compatibility Version of a virtual machine to null with a REST API produced the following error: 2017-06-26 11:02:05,100+10 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-21) [] Operation Failed: [Cannot edit VM. Custom Compatibility Version is not supported: .] This update allows you to set the Custom Compatibility Version of a virtual machine to null with the following REST API request: POST /ovirt-engine/api/vms/<vm-id> ... <vm> <custom_compatibility_version/> </vm>
Story Points: ---
Clone Of: 1412725 Environment:
Last Closed: 2017-08-22 17:42:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1412725    
Bug Blocks:    

Description Germano Veit Michel 2017-06-26 00:55:36 UTC
+++ This bug was initially created as a clone of Bug #1412725 +++

Description of problem:
Trying to set the Custom Compatibility Version of a VM to an empty value via REST api (in order to take the Custom Compatibility Version value of the Cluster) is not supported, 

This should be done by running the following:
POST /ovirt-engine/api/vms/<vmid>
<vm>
    <custom_compatibility_version/>
</vm>

but it fails with an error: 
<detail>
For correct usage, see: http://butterfly.usersys.redhat.com:8080/ovirt-engine/api/v4/model#services/vm-graphics-consoles/methods/add
</detail>
<reason>Request syntactically incorrect.</reason>

Version-Release number of selected component (if applicable):
4.1 master

How reproducible:
100%

Steps to Reproduce:
1.Try to create a vm or edit a vm and set custom_compatibility_version attribute to an empty value:
<vm>
    <custom_comaptibility_version/>
</vm>

Actual results:
It failed with error:
<detail>
For correct usage, see: http://butterfly.usersys.redhat.com:8080/ovirt-engine/api/v4/model#services/vm-graphics-consoles/methods/add
</detail>
<reason>Request syntactically incorrect.</reason>

Expected results:
It should succeeded.

Comment 1 Germano Veit Michel 2017-06-26 01:16:27 UTC
In rhevm-4.1.2.2-0.1.el7.noarch:

vm_service.update(
    vm=types.Vm(
        custom_compatibility_version=types.Version()
    )
)

Results in:

DEBUG:root:PUT /ovirt-engine/api/vms/f03206ec-475b-4a66-9309-d85e454aa8d5 HTTP/1.1
DEBUG:root:Content-Length: 45
DEBUG:root:<vm>
DEBUG:root:  <custom_compatibility_version/>
DEBUG:root:</vm>
DEBUG:root:upload completely sent off: 45 out of 45 bytes
DEBUG:root:HTTP/1.1 400 Bad Request

2017-06-26 11:02:05,100+10 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-21) [] Operation Failed: [Cannot edit VM. Custom Compatibility Version is not supported: .]

And "custom_compatibility_version=None" results in:

DEBUG:root:<vm/>
DEBUG:root:upload completely sent off: 6 out of 6 bytes
DEBUG:root:HTTP/1.1 200 OK

Which obviously is accepted but doesn't work.

Also see:
BZ #1367411
https://gerrit.ovirt.org/#/c/69984/

Comment 3 Sharon Gratch 2017-07-31 09:48:36 UTC
*** Bug 1412725 has been marked as a duplicate of this bug. ***

Comment 5 Israel Pinto 2017-08-08 07:53:53 UTC
Verify with:
engine: 4.1.5.1-0.1.el7 

Steps:
1. Create VM
2. Set custom_compatibility_version from UI to 4.1
3. Update custom_compatibility_version to empty value from REST 
With:
<vm>
    <custom_compatibility_version/>
</vm>

Results: PASS
custom_compatibility_version updated to empty value.

Comment 7 errata-xmlrpc 2017-08-22 17:42:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:2509