Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1456711

Summary: [RFE] Add properties to events
Product: [oVirt] ovirt-engine Reporter: Juan Hernández <juan.hernandez>
Component: RestAPIAssignee: Ori Liel <oliel>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.1CC: bugs, lsvaty, mperina, oourfali
Target Milestone: ovirt-4.2.0Keywords: FutureFeature
Target Release: 4.2.0Flags: rule-engine: ovirt-4.2?
pmatyas: testing_plan_complete-
rule-engine: planning_ack?
oourfali: devel_ack+
lsvaty: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 10:49:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1499716    

Description Juan Hernández 2017-05-30 08:16:48 UTC
Currently events contain a description that is built a template and a set of properties added by the backend to the audit log object. For example, when a NIC is added to a virtual machine the generated event looks like this:

  <event href="/ovirt-engine/api/events/99" id="99">
    <description>Interface nic2 (VirtIO) was added to VM myvm. (User: admin@internal-authz)</description>
    <code>932</code>
    ...
    <vm href="/ovirt-engine/api/vms/34bc8a23-8749-481c-a67e-dd855960cf79" id="34bc8a23-8749-481c-a67e-dd855960cf79"/>
    ...
  </event>

Some applications need to extract certain details from that message, for example the name of the virtual machine. For a selected set of objects that information can be extracted from the links that are part of the event. For example, in the above example the user could follow the <vm ../> link to get the VM name. But this isn't always possible, as there may not be a link containing the required information. In that cases applications tend to parse the text message. For example, that is what ManageIQ currently does to extract the VM name:

  https://github.com/ManageIQ/manageiq/blob/fine-1/app/models/manageiq/providers/redhat/infra_manager/event_parser.rb#L80-L88

That is very fragile.

To better support these applications the API should provide the properties in easier and more reliable way:

  <event href="/ovirt-engine/api/events/99" id="99">
    <description>Interface nic2 (VirtIO) was added to VM myvm. (User: admin@internal-authz)</description>
    <code>932</code>
    <properties>
      <property>
        <name>nic_name</name>
        <value>nic2</value>
      </property>
      <property>
        <name>nic_interface</name>
        <value>VirtIO</value>
      </property>
      <property>
        <name>vm_name</name>
        <value>myvm</value>
      </property>
      <property>
        <name>user_name</name>
        <value>admin@internal-authz</value>
      </property>

    </properties>
    ...
  </event>

The set of properties available for each event type should be kept backwards compatible, and the names and meanings should be documented in the specification of the API.

Comment 1 Oved Ourfali 2017-07-12 12:04:25 UTC
We discussed that offline.
We'll add that functionality to some extent in 4.2.
The idea is to add the names of references we currently have in the events structure (like VM name, cluster name, DC name etc, depends on the event itself).

Comment 2 Ori Liel 2017-09-06 12:14:43 UTC
Patch posted: 

  https://gerrit.ovirt.org/#/c/81513/

Comment 3 Petr Matyáš 2017-10-09 09:35:04 UTC
Verified on ovirt-engine-4.2.0-0.0.master.20171006152719.gitbc9a33d.el7.centos.noarch

Comment 4 Sandro Bonazzola 2017-12-20 10:49:04 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.