Bug 1118329

Summary: Can't change power management type using REST-API
Product: Red Hat Enterprise Virtualization Manager Reporter: sefi litmanovich <slitmano>
Component: ovirt-engineAssignee: Ori Liel <oliel>
Status: CLOSED WONTFIX QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.5.0CC: eedri, gklein, iheim, lpeer, oourfali, rbalakri, Rhev-m-bugs, yeylon
Target Milestone: ---Keywords: AutomationBlocker, AutomationTriaged
Target Release: 3.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-08 07:22:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sefi litmanovich 2014-07-10 13:00:39 UTC
Description of problem:

if a power management agent is configured with agent type A and I want to change it to type B using REST-API, until now I would issue this call:

PUT request content is --  url:/api/hosts/{host_id}
 
body:

<host>
    <power_management type="apc_snmp">
        <enabled>true</enabled>
    </power_management>
</host>


Steps to Reproduce:
1.add a host.
2.enable power management and provide address, username, password and type for it.
3.try to change the type of the agent using the above call.

Actual results:

Response code = 400

fails with message:

<fault>
<reason>Operation Failed</reason>
<detail>[Cannot edit Host. Power Management is enabled for Host but no Agent type selected.]</detail>
</fault>

Expected results:

the agent type changes according to the new type.


Additional info:

This bug was found in test run:

http://jenkins.qa.lab.tlv.redhat.com:8080/job/3.5-art_rpm_build_testing/36/engine=rest,test=reg_hosts/testReport/reg_hosts.reg_host_tests/017-TestUpdatePowerManagementType;update_power_management_type/TestUpdatePowerManagementType_update_power_management_type/

Comment 1 Oved Ourfali 2014-07-16 08:23:44 UTC
A rewrite of the REST API for the power management definition is on the way.
Will be available in 3.6.
Changing the target release properly.

Comment 2 Ori Liel 2015-04-08 07:22:03 UTC
The Power-Management refactoring for 3.6 was done, among other reasons, because the old entity structure was wrong. One bad thing about the old structure was that 'type' was associated directly with 'Power-Management'. Since two agents in the same Power-Management may have different types, this doesn't make sense. Updating 'type' of the Power-Management as describes in the bug description would result in updating the type of the first agent. Since this is wrong to begin with, I see no point maintaining backwards-compatibility to it.  

The new way to update agent type is: 
  
  PUT  ...api/hosts/xxx/fenceagnets/yyy     (xxx = host-id, yyy = fence-agent id)
  <agent>
    <type>apc_snmp</type>
  </agent>