Bug 1333354 - [REST API V3] Adding a vm with custom_properties fails via api version 3
Summary: [REST API V3] Adding a vm with custom_properties fails via api version 3
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: 4.0.0
Hardware: Unspecified
OS: Unspecified
medium
urgent
Target Milestone: ovirt-4.0.0-beta
: 4.0.0
Assignee: Juan Hernández
QA Contact: Lukas Svaty
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-05 11:08 UTC by sefi litmanovich
Modified: 2016-07-05 07:50 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-05 07:50:28 UTC
oVirt Team: Infra
rule-engine: ovirt-4.0.0+
rule-engine: blocker+
rule-engine: planning_ack+
juan.hernandez: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)
engine log (253.60 KB, application/x-gzip)
2016-05-05 11:08 UTC, sefi litmanovich
no flags Details


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 57100 0 master MERGED restapi: Add V3 adapters for custom properties 2016-05-06 11:45:35 UTC

Description sefi litmanovich 2016-05-05 11:08:38 UTC
Created attachment 1154164 [details]
engine log

Description of problem:

Attempting to add a vm which include a custom_properties attribute fails via api version 3.
 e.g.

https://{engine_url}/ovirt-engine/api/vms/

POST
headers:
Content-type: application/xml
Accept: application/xml
Version: 3

<vm>
    <name>add_vm_test</name>
    <type>desktop</type>
    <os type="rhel_6x64"/>
    <cluster href="/ovirt-engine/api/clusters/{cluster_id}" id="{cluster_id}">
    </cluster>
    <display>
        <type>spice</type>
    </display>
    <custom_properties>
        <custom_property name="sndbuf" value="111"/>
    </custom_properties>
    <template id="00000000-0000-0000-0000-000000000000"/>
</vm>

Actual results:
500 Internal Server Error

Expected results:
response 201
Vm is created successfully with the correct custom property

Version-Release number of selected component (if applicable):
ovirt-engine-4.0.0-0.0.master.20160504171422.git8c24183.el7.centos.noarch

How reproducible:
always

Additional info:
See attached log from entry:
2016-05-05 13:53:44,386 ERROR [org.ovirt.engine.api.restapi.resource.validation.IOExceptionMapper] (default task-5) []
 IO exception while processing "POST" request for path "/vms"

Comment 1 Lukas Svaty 2016-06-15 10:31:29 UTC
Operation is successful, however custom property was not added to VM and is missing-> FailedQA, tested in ovirt-engine-restapi-4.0.0.4-0.1.el7ev.noarch

curl -k -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" -u admin@internal:{admin_pwd} --cacert ca.crt -d "<vm><name>add_vm_test3</name><type>desktop</type><os type=\"rhel_6x64\"/><cluster href=\"/ovirt-engine/api/clusters/{cluster_id}\" id=\"{cluster_id}\"></cluster><display><type>spice</type></display><custom_properties>custom_property name=\"sndbuf\" value=\"111\"/></custom_properties><template id=\"{blank_template}\"/></vm>" https://test-engine.com:443/ovirt-engine/api/vms

engine log:
2016-06-15 10:29:56,083 INFO  [org.ovirt.engine.core.sso.utils.AuthenticationUtils] (default task-13) [] User admin@internal successfully logged in with scopes: ovirt-app-api ovirt-ext=token-info:authz-search ovirt-ext=token-info:public-authz-search ovirt-ext=token-info:validate
2016-06-15 10:29:56,119 INFO  [org.ovirt.engine.core.bll.aaa.CreateUserSessionCommand] (default task-16) [19a8a636] Running command: CreateUserSessionCommand internal: false.
2016-06-15 10:29:56,238 INFO  [org.ovirt.engine.core.bll.AddVmFromScratchCommand] (default task-16) [ea862b2] Lock Acquired to object 'EngineLock:{exclusiveLocks='[add_vm_testx=<VM_NAME, ACTION_TYPE_FAILED_OBJECT_LOCKED>]', sharedLocks='null'}'
2016-06-15 10:29:56,324 INFO  [org.ovirt.engine.core.bll.AddVmFromScratchCommand] (default task-16) [] Running command: AddVmFromScratchCommand internal: false. Entities affected :  ID: 00000002-0002-0002-0002-000000000299 Type: ClusterAction group CREATE_VM with role type USER
2016-06-15 10:29:56,363 INFO  [org.ovirt.engine.core.vdsbroker.monitoring.VmsStatisticsFetcher] (DefaultQuartzScheduler6) [d8a08e1] Fetched 0 VMs from VDS '189561d6-2c03-4cc4-be5d-15d9652a2113'
2016-06-15 10:29:56,495 INFO  [org.ovirt.engine.core.bll.AddGraphicsDeviceCommand] (default task-16) [69739fb8] Running command: AddGraphicsDeviceCommand internal: true. Entities affected :  ID: f919ce13-d17b-4691-b6a2-426ca7c6f4f1 Type: VMAction group EDIT_VM_PROPERTIES with role type USER
2016-06-15 10:29:56,524 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-16) [69739fb8] Correlation ID: ea862b2, Job ID: 13607998-d0f4-4efd-a77e-42820d41a4a5, Call Stack: null, Custom Event ID: -1, Message: VM add_vm_testx was created by admin@internal-authz.
2016-06-15 10:29:56,550 INFO  [org.ovirt.engine.core.bll.AddVmFromScratchCommand] (default task-16) [69739fb8] Lock freed to object 'EngineLock:{exclusiveLocks='[add_vm_testx=<VM_NAME, ACTION_TYPE_FAILED_OBJECT_LOCKED>]', sharedLocks='null'}'
2016-06-15 10:29:56,592 INFO  [org.ovirt.engine.core.bll.aaa.LogoutSessionCommand] (default task-16) [ffe839f] Running command: LogoutSessionCommand internal: false.
2016-06-15 10:29:56,599 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-16) [ffe839f] Correlation ID: ffe839f, Call Stack: null, Custom Event ID: -1, Message: User admin@internal-authz logged out.

Comment 2 Red Hat Bugzilla Rules Engine 2016-06-15 10:31:37 UTC
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.

Comment 3 Lukas Svaty 2016-06-15 10:34:04 UTC
just note: mentioned behaviour is the same with -H "Version: 3"

Comment 4 Juan Hernández 2016-06-15 11:04:15 UTC
I think that it has an error in the body, it is missing a "<" before the "custom_property" tag:

      <custom_properties>custom_property

Add the version header, and fix the "custom_property" tag, then it should work correctly, I just verified it in my environment.

Comment 5 Lukas Svaty 2016-06-15 11:16:34 UTC
Thank you for noticing, seems to be working with correct xml, also only working for "Version: 3" without this header it has the previous  issue of not assigning the custom property, bug?

However this issue is fixed and verified.

Comment 6 Juan Hernández 2016-06-15 11:21:17 UTC
Without the version header you will be using version 4 of the API, and in version 4 of the API XML attributes aren't used (except "id" and "href"), so the custom properties element should look like this:

  <custom_properties>
    <custom_property>
      <name>sndbuf</name>
      <value>111</value>
    </custom_property>
  </custom_properties>

Same for the "os" element, should be like this when using version 4 of the API:

  <os>
    <type>rhel_6x64</type>
  </os>

Try that, please, if doesn't work, then there is a bug.

Comment 7 Lukas Svaty 2016-06-15 11:39:34 UTC
just checked with new API it seems to be working correctly with changes you mentioned

Comment 8 Sandro Bonazzola 2016-07-05 07:50:28 UTC
oVirt 4.0.0 has been released, closing current release.


Note You need to log in before you can comment on or make changes to this bug.