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

Bug 1111128

Summary: If I have vm with domain(also when it empty), update vm via python SDK failed
Product: Red Hat Enterprise Virtualization Manager Reporter: Artyom <alukiano>
Component: ovirt-engine-sdkAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED DUPLICATE QA Contact: Shai Revivo <srevivo>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.4.0CC: acathrow, gklein, iheim, oramraz, Rhev-m-bugs, yeylon
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-20 08:55:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Artyom 2014-06-19 10:25:05 UTC
Description of problem:
I have vm with domain that in REST presentation looks:
<vms>
    <vm href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f" id="0404908a-7e9c-449e-ba49-0d1bac26e13f">
        <actions>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/commit_snapshot" rel="commit_snapshot"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/preview_snapshot" rel="preview_snapshot"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/cancelmigration" rel="cancelmigration"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/maintenance" rel="maintenance"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/undo_snapshot" rel="undo_snapshot"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/ticket" rel="ticket"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/migrate" rel="migrate"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/reboot" rel="reboot"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/move" rel="move"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/detach" rel="detach"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/export" rel="export"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/shutdown" rel="shutdown"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/start" rel="start"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/stop" rel="stop"/>
            <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/suspend" rel="suspend"/>
        </actions>
        <name>sla_test_1</name>
        <description>CPU Host VM</description>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/applications" rel="applications"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/disks" rel="disks"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/nics" rel="nics"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/cdroms" rel="cdroms"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/snapshots" rel="snapshots"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/tags" rel="tags"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/permissions" rel="permissions"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/statistics" rel="statistics"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/reporteddevices" rel="reporteddevices"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/watchdogs" rel="watchdogs"/>
        <type>desktop</type>
        <status>
            <state>down</state>
        </status>
        <memory>1073741824</memory>
        <cpu>
            <topology sockets="1" cores="1"/>
            <architecture>X86_64</architecture>
        </cpu>
        <cpu_shares>0</cpu_shares>
        <os type="other">
            <boot dev="hd"/>
        </os>
        <high_availability>
            <enabled>false</enabled>
            <priority>0</priority>
        </high_availability>
        <display>
            <type>spice</type>
            <monitors>1</monitors>
            <single_qxl_pci>false</single_qxl_pci>
            <allow_override>false</allow_override>
            <smartcard_enabled>false</smartcard_enabled>
        </display>
        <cluster href="/api/clusters/cb434140-f722-4d97-9cfb-dfe75dbd0afb" id="cb434140-f722-4d97-9cfb-dfe75dbd0afb"/>
        <template href="/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
        <stop_time>2014-06-18T19:28:57.838+03:00</stop_time>
        <creation_time>2014-06-18T19:28:57.834+03:00</creation_time>
        <origin>ovirt</origin>
        <stateless>false</stateless>
        <delete_protected>false</delete_protected>
        <sso>
            <methods>
                <method id="GUEST_AGENT"/>
            </methods>
        </sso>
        <domain>
            <name></name>
        </domain>
        <initialization>
            <domain></domain>
            <regenerate_ssh_keys>false</regenerate_ssh_keys>
            <nic_configurations/>
        </initialization>
        <placement_policy>
            <affinity>migratable</affinity>
        </placement_policy>
        <memory_policy>
            <guaranteed>1073741824</guaranteed>
        </memory_policy>
        <usb>
            <enabled>false</enabled>
        </usb>
        <migration_downtime>-1</migration_downtime>
    </vm>
</vms>

And now I try to update vm via, python SDK,
api_instance = API(url="https://10.35.162.35",
                   username="admin@internal",
                   password="123456",
                   ca_file="ca.crt",
                   debug=True)
print "Connected successfully!"

vm = api_instance.vms.get("test_sla")

vm_cpu = vm.get_cpu()
vm_cpu.set_mode('host_passthrough')
vm.get_placement_policy().set_affinity('user_migratable')
vm_placement_affinity = vm.get_placement_policy().get_affinity()

vm.update()
output in debug mode:
send: 'PUT /api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f HTTP/1.1\r\nHost: 10.35.162.35\r\nAccept-Encoding: identity\r\nContent-Length: 3841\r\nFilter: False\r\nPrefer: persistent-auth\r\ncookie: JSESSIONID=5WpAq79RxCYhIaehwhxMqF+C\r\nContent-type: application/xml\r\nAccept: application/xml\r\n\r\n
<vm href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f" id="0404908a-7e9c-449e-ba49-0d1bac26e13f">
    <actions>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/commit_snapshot" rel="commit_snapshot"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/preview_snapshot" rel="preview_snapshot"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/cancelmigration" rel="cancelmigration"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/maintenance" rel="maintenance"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/undo_snapshot" rel="undo_snapshot"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/ticket" rel="ticket"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/migrate" rel="migrate"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/reboot" rel="reboot"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/move" rel="move"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/detach" rel="detach"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/export" rel="export"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/shutdown" rel="shutdown"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/start" rel="start"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/stop" rel="stop"/>
        <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/suspend" rel="suspend"/>
    </actions>
    <name>sla_test_1</name>
    <description>CPU Host VM</description>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/applications" rel="applications"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/disks" rel="disks"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/nics" rel="nics"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/cdroms" rel="cdroms"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/snapshots" rel="snapshots"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/tags" rel="tags"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/permissions" rel="permissions"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/statistics" rel="statistics"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/reporteddevices" rel="reporteddevices"/>
    <link href="/api/vms/0404908a-7e9c-449e-ba49-0d1bac26e13f/watchdogs" rel="watchdogs"/>
    <type>desktop</type>
    <status>
        <state>down</state>
    </status>
    <memory>1073741824</memory>
    <cpu>
        <topology cores="1" sockets="1"/>
        <mode>host_passthrough</mode>
    </cpu>
    <cpu_shares>0</cpu_shares>
    <os type="other">
        <boot dev="hd"/>
    </os>
    <high_availability>
        <enabled>false</enabled>
        <priority>0</priority>
    </high_availability>
    <display>
        <type>spice</type>
        <monitors>1</monitors>
        <single_qxl_pci>false</single_qxl_pci>
        <allow_override>false</allow_override>
        <smartcard_enabled>false</smartcard_enabled>
    </display>
    <cluster href="/api/clusters/cb434140-f722-4d97-9cfb-dfe75dbd0afb" id="cb434140-f722-4d97-9cfb-dfe75dbd0afb"/>
    <template href="/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
    <creation_time>2014-06-18T19:28:57.834000+03:00</creation_time>
    <origin>ovirt</origin>
    <stateless>false</stateless>
    <delete_protected>false</delete_protected>
    <domain/>
    <initialization/>
    <placement_policy>
        <affinity>user_migratable</affinity>
    </placement_policy>
    <memory_policy>
        <guaranteed>1073741824</guaranteed>
    </memory_policy>
    <usb>
        <enabled>false</enabled>
    </usb>
</vm>
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Wed, 18 Jun 2014 16:29:47 GMT
header: Content-Type: application/xml
header: Content-Length: 202
header: Vary: Accept-Encoding
header: Connection: close
Traceback (most recent call last):
  File "/home/artyom/workspace/work/ART/art/tests/rhevm/unittests/local_test/python_sdk.py", line 18, in <module>
    vm.update()
  File "/usr/lib/python2.7/site-packages/ovirt_engine_sdk_python-3.3.0.8_1-py2.7.egg/ovirtsdk/infrastructure/brokers.py", line 13592, in update
    headers={"Correlation-Id":correlation_id}
  File "/usr/lib/python2.7/site-packages/ovirt_engine_sdk_python-3.3.0.8_1-py2.7.egg/ovirtsdk/infrastructure/proxy.py", line 72, in update
    return self.request('PUT', url, body, headers)
  File "/usr/lib/python2.7/site-packages/ovirt_engine_sdk_python-3.3.0.8_1-py2.7.egg/ovirtsdk/infrastructure/proxy.py", line 112, in request
    persistent_auth=self._persistent_auth)
  File "/usr/lib/python2.7/site-packages/ovirt_engine_sdk_python-3.3.0.8_1-py2.7.egg/ovirtsdk/infrastructure/proxy.py", line 134, in __doRequest
    persistent_auth=persistent_auth
  File "/usr/lib/python2.7/site-packages/ovirt_engine_sdk_python-3.3.0.8_1-py2.7.egg/ovirtsdk/web/connection.py", line 133, in doRequest
    raise RequestError, response
ovirtsdk.infrastructure.errors.RequestError: 
status: 400
reason: Bad Request
detail: If Domain supplied, Domain name expected to be supplied as well.

From some reason, it add <donain/> line that crush update.

Version-Release number of selected component (if applicable):
av9.6

How reproducible:
Always

Steps to Reproduce:
1. See above
2.
3.

Actual results:
Update vm via python sdk failed with exception

Expected results:
Update vm via python sdk success without any errors

Additional info:
If I have vm without lines: <domain>
            <name></name>
        </domain>
Update success, without any problems.
Also update via REST, works fine always, always when vm have domain lines.

Comment 1 Juan Hernández 2014-06-20 08:55:25 UTC
The root cause of this problem is that the version of generateDS.py that we currently use (2.9a) doesn't handle correctly empty elements. This will be fixed in 3.5 upgrading to version 2.12a.

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