On 12/06/2016 10:19 AM, Emil Flink wrote:
Hi,
Can someone please provide an example request to edit the power
management options of a host?
Ie. the options contained in
host['power_management']['agents']['agent'][0]['options']['option']
and
host['power_management']['options']['option']
Currently I have:
"option": [
{
"name": "power_wait",
"value": "4"
},
{
"name": "lanplus",
"value": ""
}
]
I need to change the value of "lanplus" from nothing to 1 or "on".
I have tried replacing the entire host['power_management']['options']
set and the host['power_management']['agents'] set with PUT requests to
the API endpoint for the host, with no change or errors - I just get a
200 OK response with the details of the host as if I had just done a GET
request.
Br.
Emil
Apparently you are using version 3.6 or older of the engine, because in
newer versions (4.0 and newer) the 'power_management/agents' and
'power_management/options' aren't populated. Anyhow, that information is
read only. To write it you need to use the
hosts/{host:id}/fenceagents/{agent:id} endpoint. For example, to change
the value of 'lanplus' to 1 you can use an script like this (using curl):
---8<---
#!/bin/sh -ex
url="https://rhevm36.example.com/ovirt-engine/api"
user="admin@internal"
password="redhat123"
curl \
--verbose \
--cacert /etc/pki/ovirt-engine/ca.pem \
--request PUT \
--user "${user}:${password}" \
--header "Version: 3" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '
{
"options" : {
"option" : [ {
"name" : "power_wait",
"value" : "4"
}, {
"name" : "lanplus",
"value" : "1"
} ]
}
}
' \
"${url}/hosts/136e39d6-7047-4ad0-87c8-d3028189ae8a/fenceagents/a16ff2fe-066c-4837-8b96-bd393bd7d3d7"
--->8---
Note that this is using version 3 of the API, which is deprecated since
version 4.0 of the engine, and will be removed in version 4.2. Consider
migrating to version 4 of the API once you upgrade your environment to
version 4.0 or newer of the engine.