Class: NagiosConfig
- Inherits:
-
CloudstackNagios::Base
- Object
- Thor
- CloudstackNagios::Base
- NagiosConfig
- Defined in:
- lib/cloudstack-nagios/commands/nagios_config.rb
Constant Summary collapse
- TEMPLATE_DIR =
File.join(File.dirname(__FILE__), '..', 'templates')
Constants included from CloudstackNagios::Helper
CloudstackNagios::Helper::RETURN_CODES
Instance Attribute Summary
Attributes inherited from CloudstackNagios::Base
Instance Method Summary collapse
Methods inherited from CloudstackNagios::Base
Methods included from CloudstackNagios::Helper
#check_data, #cs_routers, #cs_system_vms, #exit_with_failure, #load_template, #storage_pools
Instance Method Details
#generate(*configs) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 24 def generate(*configs) configs = get_configs(configs) if configs.size == 0 say "Please specify a valid configuration.", :green say "Possible values are..." invoke "nagios_config:list", [] exit end routers = configs.include?("router_hosts") ? cs_routers : nil system_vms = configs.include?("system_vm_hosts") ? cs_system_vms : nil pools = configs.include?("storage_pools") ? storage_pools : nil zones = client.list_zones config_name = configs.size == 1 ? "#{configs[0]} configuration" : "all configurations" header = load_template(File.join(TEMPLATE_DIR, "header.cfg.erb")) output = header.result( config_name: config_name, date: date_string ) configs.each do |config| if configs.size == 1 && [:template] tmpl_file = [:template] else tmpl_file = File.join(TEMPLATE_DIR, "cloudstack_#{config}.cfg.erb") end template = load_template(tmpl_file) output += template.result( routers: routers, system_vms: system_vms, bin_path: bin_path, if_speed: [:if_speed], config_file: [:config], zones: zones, capacity_types: Capacity::CAPACITY_TYPES, storage_pools: pools, over_provisioning: [:over_provisioning], ssh_key: [:ssh_key], ssh_port: [:ssh_port] ) end = load_template(File.join(TEMPLATE_DIR, "footer.cfg.erb")) output += .result( config_name: config_name ) puts output end |
#list ⇒ Object
75 76 77 78 |
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 75 def list configs = get_configs puts ["all"] << configs end |