Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1361079

Summary: POST templates documentation/bad request message is wrong (disks instead of disk attachments)
Product: [oVirt] ovirt-engine Reporter: Carlos Mestre González <cmestreg>
Component: RestAPIAssignee: Ori Liel <oliel>
Status: CLOSED DUPLICATE QA Contact: Pavel Stehlik <pstehlik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.0.2CC: bugs, cmestreg, gklein, oliel
Target Milestone: ---Flags: rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-28 11:46:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Carlos Mestre González 2016-07-28 10:15:05 UTC
Description of problem:
The POST to /api/templates and the rsdl return a wrong description for creating a template for disk section uses old disks instead of diskattachemnts (v4):

[...]
<usage_message>
    <message>Request syntactically incorrect. See the description below for the correct usage:</message>
    <detailedLink href="/ovirt-engine/api/v4/templates" rel="add">
        <description>add a new template to the system</description>
        <request>
[...]

                    <parameter required="false" type="xs:string">
                        <name>template.custom_cpu_model</name>
                    </parameter>
                    <parameter required="false" type="collection">
                        <name>template.vm.disks.disk</name>
                        <parameters_set>
                            <parameter required="false" type="xs:string">
<name>disk.id</name>
                            </parameter>
                            <parameter required="false" type="xs:string">
<name>disk.alias</name>
                            </parameter>
                            <parameter required="false" type="xs:string">
<name>disk.description</name>
                            </parameter>
                            <parameter required="false" type="collection">
<name>storage_domains.storage_domain</name>
<parameters_set>
    <parameter required="false" type="xs:string">
        <name>storage_domain.id</name>
    </parameter>
</parameters_set>
                            </parameter>
                        </parameters_set>
                    </parameter>
[...]

This should be the new way of creating a templates with vm.disk_attachments_disk_attachment ... and the properties like interface, disk,...

Version-Release number of selected component (if applicable):
rhevm-4.0.2-0.1.rc.el7ev.noarch

Comment 1 Ori Liel 2016-07-28 10:40:14 UTC
Starting to work on this, please include the exact request (including headers if exist)

Comment 2 Carlos Mestre González 2016-07-28 11:25:08 UTC
Just send a wrong v4 request and you'll see the Request syntactically incorrect response with the vm.disks.disk instaead of the correct one vm.disk_attachments.disk_attachment:

curl \
-k \
-X POST \
-H "Accept: application/xml" \
-H "Content-Type: application/xml" \
-d '
<template>
    <name>test_template_20</name>
    <cluster id="4d7decad-241e-4608-95dc-f033609523f1"/>
    <vm id="bdb658f9-27d3-4c93-ba5c-cb125507fc08">
    <disks>
            <disk id="f9eb812a-ace4-4103-87fe-626ce2c8fa49">
                <storage_domains id="5d819ebe-314d-4787-9269-85317114bf64"/>
           </disk>
    </disks>
   </vm>
</template>
' \
-u username@domain:password \
https://engine/ovirt-engine/api/v4/templates


proper request is:

curl \
-k \
-X POST \
-H "Accept: application/xml" \
-H "Content-Type: application/xml" \
-H "Version: 4" \
-d '
<template>
    <name>test_template_20</name>
    <cluster id="4d7decad-241e-4608-95dc-f033609523f1"/>
    <vm id="bdb658f9-27d3-4c93-ba5c-cb125507fc08">
    <disk_attachments>
        <disk_attachment>
            <disk id="f9eb812a-ace4-4103-87fe-626ce2c8fa49">
                <storage_domains id="5d819ebe-314d-4787-9269-85317114bf64"/>
           </disk>
        </disk_attachment>
    </disk_attachments>
   </vm>
</template>
' \
-u username@domain:password \
https://engine/ovirt-engine/api/v4/templates


again, problem is the documentation (rsdl), it should be documented as such.

Comment 3 Ori Liel 2016-07-28 11:46:59 UTC
This should have been fixed as part of a major change in 4.0.2.1. 
In this change, the return message for bad requests was made to contain a link to a relevant section in an html page which describes the API.

*** This bug has been marked as a duplicate of bug 1337240 ***