I'm trying to use the RHEV 4.1 API to get the host status of my hypervisor using python. RHEV 3.6 is working with my script. But if i use the following.
host = api.hosts.get(host_name)
host_state = host.status //RHEV 3.6 this was host.state.status
print(host_state)
it gives the following
<ovirtsdk.xml.params.Status object at 0x3ce0f10>
dev-dbe101t <ovirtsdk.xml.params.Status object at 0x3ce0f10>
dev-be101t-data1 None master
dev-be101t-data2 None
I can get the hostname and data-center name correctly. even this Status object is not iterable. According to the rhvm 3.6 and rhev 4.1 api difference.
In version 4 of the API this Status type has been removed and replaced by enum types. (my above code is working for rhev 3.6 and it gives the correct status of the host)
How can i retrieve the host status ? i found that the host.status type is a class and then i printed out all related class methods using dir(theobject) and found following useful methods. state,get_state, but it is giving none. but my api status is up
according to the api guide.
status is type of HostStatus ENUM
HOSTSTATUS ENUM contains a NAME called "up"
not sure how to get the host.status from the api. API returns this
<host>
<status>up</status>
</host>