Class: Ovirt::EventMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/ovirt/event_monitor.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EventMonitor

Returns a new instance of EventMonitor.



3
4
5
# File 'lib/ovirt/event_monitor.rb', line 3

def initialize(options={})
  @options = options
end

Instance Method Details

#eachObject



30
31
32
33
34
# File 'lib/ovirt/event_monitor.rb', line 30

def each
  each_batch do |events|
    events.each { |e| yield e }
  end
end

#each_batchObject



22
23
24
25
26
27
28
# File 'lib/ovirt/event_monitor.rb', line 22

def each_batch
  while @monitor_events do
    events = inventory.events(@since).sort_by { |e| e[:id].to_i }
    @since = events.last[:id].to_i unless events.empty?
    yield events
  end
end

#inventoryObject



7
8
9
# File 'lib/ovirt/event_monitor.rb', line 7

def inventory
  @inventory ||= Inventory.new(@options)
end

#startObject



11
12
13
14
15
16
# File 'lib/ovirt/event_monitor.rb', line 11

def start
  trap(:TERM) { $rhevm_log.info "EventMonitor#start: ignoring SIGTERM" }
  @since          = nil
  @inventory      = nil
  @monitor_events = true
end

#stopObject



18
19
20
# File 'lib/ovirt/event_monitor.rb', line 18

def stop
  @monitor_events = false
end