Red Hat Bugzilla – Bug 1315861
API.events.list() won't filter by code
Last modified: 2016-03-09 04:16:36 EST
Description of problem:
I actually didn't know if file this as a bug or a RFE. Our management has asked us for some indicators including how much times has been started a VNC session on a single day.
To do so, I've tried to filter the events list with this query:
In : api.events.list(query='code=167')
An empty list is returned while there's about 400 events in the DB with code 167.
An example object:
'cluster': <ovirtsdk.xml.params.Cluster object at 0x9ec30d0>,
'description': 'User XXX is connected to VM YYY',
'host': <ovitsdk.xml.params.Host object at 0x9ebc3410>,
'template': <ovirtsdk.xml.params.Template object at 0x9ec3090>,
'time': datetime.datetime(2016, 3, 8, 10, 48, 37, 69000, tzinfo=<ovirtsdk.xml.params._FixedOffsetTZ object at 0x9ec33d0>),
'vm': <ovirtsdk.xml.params.VM object at 0x9ec3390>
If not a bug, could filtering based on event code be implemented?
Version-Release number of selected component (if applicable):
The text that you put in the "query" parameter is translated into the "search" parameter of the API, so that call to the "list" method is translated into something like this:
The syntax of this "search" parameter is the same used in the search bar of the GUI, and it uses the same names used by the database and there are some differences with the names used in the API. For example, what is "code" in the API is "type" in the database. This means that you can make your script work just replacing "code" with "type":
There is more information about the query syntax here:
Section "F.1.19. Searching for Events" describes events.