
On 12/01/2015 03:16 PM, Giulio Casella wrote:
Hi everybody, I'm trying to enable power management on a host using python, but I'm stuck.
Previously (ovirt 3.5) I directly wrote power management parameters into PowerManagement structure (and everything was working fine), but starting from 3.6 this is not possible.
This is what I do now:
agent = params.Agent() agent.set_options(params.Options()) agent.set_type("ilo3") agent.set_username("admin") agent.set_password("mysecret") agent.set_address("172.20.20.1")
agents=params.Agents() agents.add_agent(agent)
pm=params.PowerManagement() pm.set_agents(agents) pm.set_enabled(True)
myhost=api.hosts.get("myhost") myhost.set_power_management(pm) try: myhost.update() except Exception as e: print "Error: %s" % e
and I get:
Error: status: 400 reason: Bad Request detail: Cannot edit Host. Power Management is enabled for Host but no Agent type selected.
If I dont't enable PM (pm.set_enabled line above) I get no error, but no agent is added.
My software is: - ovirt-engine-3.6.0.3-1.el6 - ovirt-engine-sdk-python-3.6.0.3-1.el6 on a CentOS 6.6 distro.
Any ideas?
Thanks in advance, Giulio
In 3.6 fencing agents have been converted into a sub-collection of the host entity: https://.../ovirt-engine/api/hosts/{host:id}/fenceagents This means that the recommended way to add/remove/update fencing agents now in Python is now this: ---8<--- # Find the host: host = api.hosts.get(name="myhost"); # Enable power management: host.get_power_management().set_enabled(True) host.update() # Add the fencing agent: agent = params.Agent() agent.set_options(params.Options()) agent.set_type("ilo3") agent.set_username("admin") agent.set_password("mysecret") agent.set_address("172.20.20.1") agent.set_order(1); host.fenceagents.add(agent) --->8--- You can use this as a workaround. However the mechanism used in 3.5 should continue working in 3.6. If it doesn't it is a bug. The script that you shared is the one you used in 3.5? -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.