Class: Fleet::Discovery
- Inherits:
-
Object
- Object
- Fleet::Discovery
- Defined in:
- lib/fleet/discovery.rb
Instance Attribute Summary collapse
-
#discovery_url ⇒ Object
Returns the value of attribute discovery_url.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #hosts ⇒ Object
-
#initialize(discovery_url = Fleetctl.options.discovery_url) ⇒ Discovery
constructor
A new instance of Discovery.
Constructor Details
Instance Attribute Details
#discovery_url ⇒ Object
Returns the value of attribute discovery_url.
9 10 11 |
# File 'lib/fleet/discovery.rb', line 9 def discovery_url @discovery_url end |
Class Method Details
.hosts ⇒ Object
4 5 6 |
# File 'lib/fleet/discovery.rb', line 4 def hosts new(discovery_url).hosts end |
Instance Method Details
#data ⇒ Object
15 16 17 |
# File 'lib/fleet/discovery.rb', line 15 def data @data ||= JSON.parse(Net::HTTP.get(URI.parse(@discovery_url))) end |
#hosts ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# 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. Fleetctl.logger.error e.backtrace.join("\n") [] end end |