Bug 1275733

Summary: [REST API] Host list don't appear under placement_policy after update VM to pinned
Product: [oVirt] ovirt-engine Reporter: Israel Pinto <ipinto>
Component: RestAPIAssignee: Andrej Krejcir <akrejcir>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.6.0CC: bugs, ipinto, juan.hernandez, pmatyas, rgolan
Target Milestone: ovirt-3.6.1Flags: dfediuck: ovirt-3.6.z?
rule-engine: planning_ack?
rule-engine: devel_ack+
rule-engine: testing_ack+
Target Release: 3.6.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-18 11:11:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: SLA RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
engine_log none

Description Israel Pinto 2015-10-27 15:20:33 UTC
Description of problem:
Host list don't appear under placement_policy after update VM to pinned

Version-Release number of selected component (if applicable):
rhevm-3.6.0-0.18.el6.noarch
VDSM: vdsm-4.17.10-5.el7ev
libvirt: libvirt-1.2.17-5.el7

How reproducible:
All the time

Steps to Reproduce:
Send request to pin VM with host in hosts list:
<vm id="d3f958c9-96de-4665-8d50-bbc855eb184d">
<placement_policy>
<affinity>pinned</affinity>
<hosts>
  <host>
   <name>host_1</name>      
  </host>
</hosts>
</placement_policy>
</vm>

The VM affinity update to 'pinned' from 'migratable'.
But the host list did not appear in VM, only in GUI.

Comment 1 Israel Pinto 2015-10-27 15:21:08 UTC
Created attachment 1086880 [details]
engine_log

Comment 2 Juan Hernández 2015-10-27 16:39:57 UTC
Currently if a VM is pinned to just one host then the RESTAPI will use the single "host" element:

  GET /vms/{vm:id}
  <vm>
    <placement_policy>
      <host id="..." href="..."/>
      <affinity>pinned</affinity>
    </plaement_policy>
  </vm>

Only if it is pinned to more than hone host the multiple "hosts" element will be used:

  GET /vms/{vm:id}
  <vm>
    <placement_policy>
      <hosts>
        <host id="..." href="..."/>
        <host id="..." href="..."/>
      </hosts>
      <affinity>pinned</affinity>
    </plaement_policy>
  </vm>

Is that what you are getting?

I think that it it is better to always populate the multiple "hosts" element, even if it only has one element.

Comment 3 Israel Pinto 2015-10-27 18:35:57 UTC
(In reply to Juan Hernández from comment #2)
> Currently if a VM is pinned to just one host then the RESTAPI will use the
> single "host" element:
> 
>   GET /vms/{vm:id}
>   <vm>
>     <placement_policy>
>       <host id="..." href="..."/>
>       <affinity>pinned</affinity>
>     </plaement_policy>
>   </vm>
> 
> Only if it is pinned to more than hone host the multiple "hosts" element
> will be used:
> 
>   GET /vms/{vm:id}
>   <vm>
>     <placement_policy>
>       <hosts>
>         <host id="..." href="..."/>
>         <host id="..." href="..."/>
>       </hosts>
>       <affinity>pinned</affinity>
>     </plaement_policy>
>   </vm>
> 
> Is that what you are getting?
> 
> I think that it it is better to always populate the multiple "hosts"
> element, even if it only has one element.

I did see host/hosts elemtemt at all.

Comment 4 Red Hat Bugzilla Rules Engine 2015-10-28 09:25:47 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 5 Juan Hernández 2015-10-28 16:51:45 UTC
I can't reproduce that. Please check with the following script and report the results:

---8<---
#!/bin/sh -ex

url="https://engine.example.com/ovirt-engine/api"
user="admin@internal"
password="******"

curl \
--verbose \
--cacert /etc/pki/ovirt-engine/ca.pem \
--request PUT \
--user "${user}:${password}" \
--header "Accept: application/xml" \
--header "Content-Type: application/xml" \
--data '
<vm>
  <placement_policy>
    <affinity>pinned</affinity>
    <hosts>
      <host>
       <name>host_1</name>      
      </host>
    </hosts>
  </placement_policy>
</vm>
' \
"${url}/vms/{vm:id}"
--->8---

Comment 6 Roy Golan 2015-10-29 07:10:55 UTC
(In reply to Juan Hernández from comment #5)
> I can't reproduce that. Please check with the following script and report
> the results:

> <vm>
>   <placement_policy>
>     <affinity>pinned</affinity>
>     <hosts>
>       <host>
>        <name>host_1</name>      
>       </host>
>     </hosts>
>   </placement_policy>
> </vm>
> ' \
> "${url}/vms/{vm:id}"
> --->8---



what version your using?

Comment 7 Juan Hernández 2015-10-29 08:44:34 UTC
I tested this with the latest 3.6 build:

  # rpm -q rhevm
  rhevm-3.6.0.2-0.1.el6.noarch

Comment 8 Petr Matyáš 2016-01-21 11:07:59 UTC
Verified on 3.6.2-10