Class: Interferon::HostSources::Optica
- Inherits:
-
Object
- Object
- Interferon::HostSources::Optica
- Includes:
- Logging
- Defined in:
- lib/interferon/host_sources/optica.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Optica
constructor
A new instance of Optica.
- #list_hosts ⇒ Object
- #optica_data ⇒ Object
Methods included from Logging
configure_logger_for, #log, #statsd
Constructor Details
#initialize(options) ⇒ Optica
Returns a new instance of Optica.
8 9 10 11 12 13 14 |
# File 'lib/interferon/host_sources/optica.rb', line 8 def initialize() raise ArgumentError, "missing host for optica source" \ unless ['host'] @host = ['host'] @port = ['port'] || 80 end |
Instance Method Details
#list_hosts ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/interferon/host_sources/optica.rb', line 16 def list_hosts return optica_data['nodes'].map{|ip, host| { :source => 'optica', :hostname => host['hostname'], :role => host['role'], :environment => host['environment'], :owners => host['ownership'] && host['ownership']['people'] || [], :owner_groups => host['ownership'] && host['ownership']['groups'] || [], }} end |
#optica_data ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/interferon/host_sources/optica.rb', line 28 def optica_data @optica_data ||= begin con = Net::HTTP.new(@host, @port) con.read_timeout = 60 con.open_timeout = 60 response = con.get('/') JSON::parse(response.body) end end |