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 27 28 |
# File 'lib/interferon/host_sources/optica.rb', line 16 def list_hosts optica_data['nodes'].map do |_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 end |
#optica_data ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/interferon/host_sources/optica.rb', line 30 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 |