Description of problem: The python 2.7 api lacks some code in the HostNicReader class that cause a crash when you try to do a follow_link(nic.statistics) Version-Release number of selected component (if applicable): ovirt-engine-sdk-python 4.2.9 oVirt Engine Version: 4.1.9.1-1.el7.centos How reproducible: Always, I'm using this python 2.7 code: #!/usr/bin/env python # -*- coding: utf-8 -*- import logging import ovirtsdk4 as sdk import ovirtsdk4.types as types # Create the connection to the server: connection = sdk.Connection( url='https://******************/ovirt-engine/api', username='*************', password='***************', debug=True, log=logging.getLogger(), ) # Get the reference to the "hosts" service: hosts_service = connection.system_service().hosts_service() # Use the "list" method of the "hosts" service to list all the hosts of the system: hosts = hosts_service.list() for host in hosts: memory_used = 0 memory_total = 0 cpu_used = 0 print("%s: Status %s" % (host.name, host.status)) #print statistic information like ram and cpu statistics = connection.follow_link(host.statistics) for statistic in statistics: if(statistic.name == "memory.used"): memory_used = statistic.values[0].datum elif(statistic.name == "memory.total"): memory_total = statistic.values[0].datum elif(statistic.name == "cpu.current.idle"): cpu_used = 100 - statistic.values[0].datum if (memory_used is not None and memory_total is not None): print(" Ram:%.0f" % (float(memory_used)/float(memory_total)*100))+r'%' print(" CPU: %.0f" % cpu_used)+r'%' nics = connection.follow_link(host.nics) print(" Network interfaces:") for nic in nics: if nic.speed is not None: speed_mb = (int(nic.speed) /1000 /1000) #convert from bits to Mbits statistics = connection.follow_link(nic.statistics) tx_use = 0 rx_use = 0 for statistic in statistics: if(statistic.name == "data.current.tx"): tx_use = statistic.values[0].datum tx_use = tx_use/nic.speed*100 elif(statistic.name == "data.current.rx"): rx_use = statistic.values[0].datum rx_use = rx_use/nic.speed*100 print(" "+str(nic.name)+": Status: "+str(nic.status)+", Speed:"+str(nic.speed/1000/1000)+" Mb, Tx "+str(tx_use)+"%,Rx "+str(rx_use)+"%") elif (nic.status == types.NicStatus.DOWN): print(" %s: Status: %s" % (nic.name,nic.status)) connection.close() Steps to Reproduce: 1. get a host from host service using the python 2.7 api 2. list all nics and iterate 3. for each nic, try to get the statistics using follow_link(nic.statistics) Actual results: It crash when try to follow the link, due to the HostNicReader ignore the link tags and lack a _process_link method Expected results: It should return a statistics object with the nic statistics information Additional info: I've fixed it in my local instalation modifying the HostNicReader class in readers.py, first i have added around the line : elif tag == 'link': links.append((reader.get_attribute('rel'), reader.get_attribute('href'))) reader.next_element() also this class needs a _process_link method, I just copied it from HostReader class, and by now i only have implemented statistics links, but it lacks the other links due that i don't know how many types of links can have this class, around the line : @staticmethod def _process_link(link, obj): rel = link[0] href = link[1] if href and rel: if rel == "statistics": if obj.statistics is not None: obj.statistics.href = href else: obj.statistics = List(href) I have read in the github repo that this code is generated from the api model, could the api model be wrong or using a old version? I have instaled it from pypi
This is indeed a bug in API model. I've sent a fix. It will be part of another Python SDK release.
Martin, I see you moved this bug to modified. Can you please cross-check? Referenced patches in merged status are not related to this bugzilla component.
(In reply to Sandro Bonazzola from comment #2) > Martin, I see you moved this bug to modified. Can you please cross-check? > Referenced patches in merged status are not related to this bugzilla > component. SDKs are generated from ovirt-engine-api-model used by ovirt-engine, am I right Ondro?
Correct, it refers model patches, which were used to rebuild SDKs.
Ok, thanks, moving to QE accordingly
Verified on oVirt 4.3.0 Fourth Release Candidate
I have tested and its solved, thanks.
This bugzilla is included in oVirt 4.3.0 release, published on February 4th 2019. Since the problem described in this bug report should be resolved in oVirt 4.3.0 release, it has been closed with a resolution of CURRENT RELEASE. If the solution does not work for you, please open a new bug report.