Class: Naginata::Loader

Inherits:
Object
  • Object
show all
Extended by:
DSL
Defined in:
lib/naginata/loader.rb

Class Method Summary collapse

Methods included from DSL

env, fetch, nagios_server, set, set_if_empty

Class Method Details

.load_configurationObject



10
11
12
13
14
# File 'lib/naginata/loader.rb', line 10

def load_configuration
  instance_eval File.read(File.join(File.dirname(__FILE__), 'defaults.rb'))
  naginatafile_path = find_naginatafile
  instance_eval File.read naginatafile_path
end

.load_remote_objects(fetch_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/naginata/loader.rb', line 16

def load_remote_objects(fetch_options = {})
  require 'naginata/cli/fetch'
  # Refresh cached status.dat
  CLI::Fetch.new(fetch_options).run

  nagios_servers = Configuration.env.filter(Configuration.env.nagios_servers)
  nagios_servers.each do |nagios_server|
    status = ::Naginata::Status.find(nagios_server.hostname)
    status.service_items.group_by{ |section| section.host_name }.each do |host, sections|
      services = sections.map { |s| s.service_description }
      Configuration.env.host(host, services: services, on: nagios_server.hostname)
    end
  end

end