Created attachment 1322497 [details] server log Description of problem: Failed to create affinity host to VM group Version-Release number of selected component (if applicable): ovirt-engine-4.2.0-0.0.master.20170904111624.git842d79b.el7.centos.noarch How reproducible: Always Steps to Reproduce: 1. Try to create host to VM affinity group via REST API <affinity_group> <name>affinity_enforcement_01</name> <hosts_rule> <enforcing>true</enforcing> <positive>true</positive> </hosts_rule> <vms_rule> <enabled>false</enabled> </vms_rule> <hosts> <host id="091db1f9-7c7a-408d-9abe-3f549b4da5b9"/> </hosts> <vms> <vm id="06fefa09-a213-410c-ae12-149b0de90f42"/> </vms> </affinity_group> 2. 3. Actual results: Internal Server Error 2017-09-06 09:35:21,835+03 ERROR [io.undertow.request] (default task-36) UT005023: Exception handling request to /ovirt-engine/api/v4/clusters/753d7ede-61f6-4fc3-9d8d-263d01374745/affinitygroups: java.lang.RuntimeException: org.jboss.resteasy.spi.UnhandledException: org.ovirt.api.metamodel.server.ValidationException: Parameter 'group.enforcing' is mandatory but was not provided. at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:245) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final] at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final] at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final] at org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:180) [restapi-jaxrs.jar:] at org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:98) [restapi-jaxrs.jar:] at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final] Expected results: Affinity group creation succeeds Additional info: Via UI all works fine
The reason for this is that the 'enforcing' and 'positive' attributes where deprecated in version 4.1 of the engine, but we didn't update the specification of the API correctly, so they are still marked as mandatory. In addition now the API server is more strict, and enforces the restrictions declared in the specification of the API, so it rejects the request. This will need to be fixed in the specification of the API, with the suggested patch, then the engine will need to be updated to use the fixed version of the specification.
This bug report has Keywords: Regression or TestBlocker. Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.
[root@pm-rh40 ~]# curl -v -u "admin@internal:$pass" -H "Content-type: application/xml" --insecure -X POST https://$engine/ovirt-engine/api/clusters/$cluster_id/affinitygroups -d "<affinity_group><name>affinity_enforcement_01</name><hosts_rule><enforcing>true</enforcing><positive>true</positive></hosts_rule><vms_rule><enabled>false</enabled></vms_rule><hosts><host id="7c14d704-66b0-462b-8e6d-5619736e6ce6"/></hosts><vms><vm id="54fff86b-f4b2-4a6d-acf9-70d7f17977f0"/></vms></affinity_group>" ^ this results in 400 Request syntactically incorrect and in engine log is: Message: Open quote is expected for attribute "id" associated with an element type "host". Although I can clearly see that id attribute has all the necessary quotes
Sorry, I forgot to mention I'm using ovirt-engine-4.2.0-0.0.master.20170911195522.git5ddba50.el7.centos.noarch
In order to send that request using curl and the command line you need to use shell quoting carefully. Currently you are putting all the XML document between double quotes, and then there are double quotes inside the XML document itself. Try to use single quotes for the XML document: -d '<affinity_group>...</affinity_group>' Or else use the back slash to escape the double quotes inside the XML document: -d "<affinity_group>...id=\"..."
You are right, my quotes were wrong, this request works correctly.
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017. Since the problem described in this bug report should be resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE. If the solution does not work for you, please open a new bug report.