Class: Ovirt::EventMonitor
- Inherits:
-
Object
- Object
- Ovirt::EventMonitor
- Defined in:
- lib/ovirt/event_monitor.rb
Instance Method Summary collapse
- #each ⇒ Object
- #each_batch ⇒ Object
-
#initialize(options = {}) ⇒ EventMonitor
constructor
A new instance of EventMonitor.
- #inventory ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
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 = end |
Instance Method Details
#each ⇒ Object
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_batch ⇒ Object
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 |
#inventory ⇒ Object
7 8 9 |
# File 'lib/ovirt/event_monitor.rb', line 7 def inventory @inventory ||= Inventory.new(@options) end |
#start ⇒ Object
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 |
#stop ⇒ Object
18 19 20 |
# File 'lib/ovirt/event_monitor.rb', line 18 def stop @monitor_events = false end |