Bug 1315861 - API.events.list() won't filter by code
API.events.list() won't filter by code
Status: CLOSED NOTABUG
Product: ovirt-engine
Classification: oVirt
Component: Search-Backend (Show other bugs)
3.6.3.3
x86_64 Linux
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: Eli Mesika
Pavel Stehlik
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-08 14:34 EST by nicolas
Modified: 2016-03-09 04:16 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-09 04:16:36 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Infra
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?


Attachments (Terms of Use)

  None (edit)
Description nicolas 2016-03-08 14:34:41 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 [1]: api.events.list(query='code=167')
Out[1]: []

An empty list is returned while there's about 400 events in the DB with code 167.

An example object:

{
 '_Base__context': 38197328,
 'actions': None,
 'cluster': <ovirtsdk.xml.params.Cluster object at 0x9ec30d0>,
 'code': 167,
 'comment': None,
 'correlation_id': None,
 'creation_status': None,
 'custom_data': None,
 'custom_id': -1,
 'data_center': None,
 'description': 'User XXX is connected to VM YYY',
 'extensiontype_': None,
 'flood_rate': 30,
 'host': <ovitsdk.xml.params.Host object at 0x9ebc3410>,
 'href': '/api/events/43476',
 'id': '43476',
 'link': [],
 'name': None,
 'origin': 'oVirt',
 'severity': 'normal',
 'storage_domain': None,
 '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>),
 'user': None,
 '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):

3.6.3.0
Comment 1 Juan Hernández 2016-03-09 04:14:40 EST
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:

  GET /ovirt-engine/api/events?search=code%3D167

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":

  api.events.list(query='type=167')

There is more information about the query syntax here:

  https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.5/html-single/Administration_Guide/index.html#Performing_Searches_in_Red_Hat_Enterprise_Virtualization

Section "F.1.19. Searching for Events" describes events.

Note You need to log in before you can comment on or make changes to this bug.