module ManageIQ
  module Providers
    module Ovirt
      module Legacy
        class EventMonitor
          def initialize(options = {})
            @ems = options[:ems]
          end

          def event_fetcher
            @event_fetcher ||= @ems.ovirt_services.event_fetcher
          end

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

          def stop
            @monitor_events = false
          end

          def each_batch
            while @monitor_events
              # grab only the most recent event if this is the first time through
              query_options = @since ? {:since => @since} : {:max => 1}
              events = event_fetcher.events(query_options).sort_by { |e| e.id.to_i }
              @since = events.last.id.to_i unless events.empty?

              yield events
            end
          end

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

module ManageIQ
  module Providers
    module Ovirt
      module Legacy
        class EventMonitor
          def initialize(options = {})
            @ems = options[:ems]
          end

          def event_fetcher
            @event_fetcher ||= @ems.ovirt_services.event_fetcher
          end

          def start
            @since          = nil
            @event_fetcher  = nil
            @monitor_events = true
          end

          def stop
            @monitor_events = false
          end

          def each_batch
            while @monitor_events
              # grab only the most recent event if this is the first time through
              query_options = @since ? {:since => @since} : {:max => 1}
              events = event_fetcher.events(query_options).sort_by { |e| e.id.to_i }
              @since = events.last.id.to_i unless events.empty?

              yield events
            end
          end

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

Remove seemingly unnecessary ignoring of SIGTERM
Remove seemingly unnecessary ignoring of SIGTERM

It was added originally back in 2011 in manageiq:
946657b11a0a65abbcdca9975206d71f7c2b7afc

This was actually copied from the vmware vim monitoring events
code from 2009: 22a911716b40428b6d822f0f1e95aabd022e59c9

```
def monitorEvents
  raise "monitorEvents: no block given" if !block_given?

 trap(:TERM) { $log.info "monitorEvents: ignoring SIGTERM" }
...
```

First of all, trap with logging doesn't work since ruby 2.0+:

```
irb(main):001:0> require 'logger'
=> true
irb(main):002:0> trap(:TERM) { Logger.new("stdout").info
"EventMonitor#start: ignoring SIGTERM" }
=> "DEFAULT"
irb(main):003:0> `kill #{Process.pid}`
log writing failed. can't be called from trap context
=> ""
```

See https://github.com/ManageIQ/manageiq/pull/2386

Second, we need to TERM processes in container land.
