class Fleet::Discovery

Attributes

discovery_url[RW]

Public Class Methods

hosts() click to toggle source
# File lib/fleet/discovery.rb, line 4
def hosts
  new(discovery_url).hosts
end
new(discovery_url = Fleetctl.options.discovery_url) click to toggle source
# File lib/fleet/discovery.rb, line 11
def initialize(discovery_url = Fleetctl.options.discovery_url)
  @discovery_url = discovery_url
end

Public Instance Methods

data() click to toggle source
# File lib/fleet/discovery.rb, line 15
def data
  @data ||= JSON.parse(Net::HTTP.get(URI.parse(@discovery_url)))
end
hosts() click to toggle source
# File lib/fleet/discovery.rb, line 19
def hosts
  begin
    data['node']['nodes'].map{|node| node['value'].split(':')[0..1].join(':').split('//').last}
  rescue => e
    Fleetctl.logger.error 'ERROR in Fleet::Discovery#hosts, returning empty set'
    Fleetctl.logger.error e.message
    Fleetctl.logger.error e.backtrace.join("\n")
    []
  end
end