Class: Naginata::Loader
Class Method Summary
collapse
find_naginatafile
Methods included from DSL
env, fetch, nagios_server, set, set_if_empty
Class Method Details
.load_configuration ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/naginata/loader.rb', line 13
def load_configuration
instance_eval File.read(File.join(File.dirname(__FILE__), 'defaults.rb'))
naginatafile_path = ::Naginata::Configuration.env.fetch(:naginatafile) || find_naginatafile
if naginatafile_path.nil? or !File.file?(naginatafile_path)
raise NaginatafileNotFound, 'Could not locate Naginatafile'
else
instance_eval File.read naginatafile_path
end
end
|
.load_remote_objects(fetch_options = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/naginata/loader.rb', line 25
def load_remote_objects(fetch_options = {})
require 'naginata/cli/fetch'
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
|