Class: OvirtSDK4::EventsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#add(event, opts = {}) ⇒ Event
Adds an external event to the internal audit log.
-
#event_service(id) ⇒ EventService
Reference to the service that manages a specific event.
-
#list(opts = {}) ⇒ Array<Event>
Get list of events.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
-
#undelete(opts = {}) ⇒ Object
Executes the
undeletemethod.
Methods inherited from Service
Instance Method Details
#add(event, opts = {}) ⇒ Event
Adds an external event to the internal audit log.
This is intended for integration with external systems that detect or produce events relevant for the administrator of the system. For example, an external monitoring tool may be able to detect that a file system is full inside the guest operating system of a virtual machine. This event can be added to the internal audit log sending a request like this:
POST /ovirt-engine/api/events HTTP/1.1
<event>
<description>File system /home is full</description>
<severity>alert</severity>
<origin>mymonitor</origin>
<custom_id>1467879754</custom_id>
</event>
Events can also be linked to specific objects. For example, the above event could be linked to the specific
virtual machine where it happened, using the vm link:
POST /ovirt-engine/api/events HTTP/1.1
<event>
<description>File system /home is full</description>
<severity>alert</severity>
<origin>mymonitor</origin>
<custom_id>1467879754</custom_id>
<vm id="aae98225-5b73-490d-a252-899209af17e9"/>
</event>
|
Note
|
When using links, like the vm in the previous example, only the id attribute is accepted. The name
attribute, if provided, is simply ignored.
|
8897 8898 8899 |
# File 'lib/ovirtsdk4/services.rb', line 8897 def add(event, opts = {}) internal_add(event, Event, ADD, opts) end |
#event_service(id) ⇒ EventService
Reference to the service that manages a specific event.
9090 9091 9092 |
# File 'lib/ovirtsdk4/services.rb', line 9090 def event_service(id) EventService.new(self, id) end |
#list(opts = {}) ⇒ Array<Event>
Get list of events.
GET /ovirt-engine/api/events HTTP/1.1
To the above request we get following response:
<events>
<event href="/ovirt-engine/api/events/2" id="2">
<description>User admin@internal-authz logged out.</description>
<code>31</code>
<correlation_id>1e892ea9</correlation_id>
<custom_id>-1</custom_id>
<flood_rate>30</flood_rate>
<origin>oVirt</origin>
<severity>normal</severity>
<time>2016-09-14T12:14:34.541+02:00</time>
<user href="/ovirt-engine/api/users/57d91d48-00da-0137-0138-000000000244" id="57d91d48-00da-0137-0138-000000000244"/>
</event>
<event href="/ovirt-engine/api/events/1" id="1">
<description>User admin logged in.</description>
<code>30</code>
<correlation_id>1fbd81f4</correlation_id>
<custom_id>-1</custom_id>
<flood_rate>30</flood_rate>
<origin>oVirt</origin>
<severity>normal</severity>
<time>2016-09-14T11:54:35.229+02:00</time>
<user href="/ovirt-engine/api/users/57d91d48-00da-0137-0138-000000000244" id="57d91d48-00da-0137-0138-000000000244"/>
</event>
</events>
The following events occur:
-
id="1" - The API logs in the admin user account.
-
id="2" - The API logs out of the admin user account.
The order of the returned list of events is always garanteed. If the sortby clause is included in the
search parameter, then the events will be ordered according to that clause. If the sortby clause isn’t
included, then the events will be sorted by the numeric value of the id attribute, starting with the
highest value. This, combined with the max parameter, simplifies obtaining the most recent event:
GET /ovirt-engine/api/events?max=1 HTTP/1.1
9053 9054 9055 |
# File 'lib/ovirtsdk4/services.rb', line 9053 def list(opts = {}) internal_get(LIST, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 |
# File 'lib/ovirtsdk4/services.rb', line 9101 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return event_service(path) end return event_service(path[0..(index - 1)]).service(path[(index + 1)..-1]) end |
#undelete(opts = {}) ⇒ Object
Executes the undelete method.
9079 9080 9081 |
# File 'lib/ovirtsdk4/services.rb', line 9079 def undelete(opts = {}) internal_action(:undelete, nil, UNDELETE, opts) end |