class MCollective::Discovery::Mc - mcollective version 2.12.5

# class MCollective::Discovery::Mc

### Public Class Methods

discover(filter, timeout, limit, client) click to toggle source

       # File lib/mcollective/discovery/mc.rb
     4 def self.discover(filter, timeout, limit, client)
     5   begin
     6     hosts = []
     7     Timeout.timeout(timeout) do
     8       reqid = client.sendreq("ping", "discovery", filter)
     9       Log.debug("Waiting #{timeout} seconds for discovery replies to request #{reqid}")
    10
    11       loop do
    12         reply = client.receive(reqid)
    13         Log.debug("Got discovery reply from #{reply.payload[:senderid]}")
    14         hosts << reply.payload[:senderid]
    15
    16         return hosts if limit > 0 && hosts.size == limit
    17       end
    18     end
    19   rescue Timeout::Error => e
    20   rescue Exception => e
    21     raise
    22   ensure
    23     client.unsubscribe("discovery", :reply)
    24   end
    25
    26   hosts
    27 end