Class: CloudManager::Configuration::Configuration
- Inherits:
-
Object
- Object
- CloudManager::Configuration::Configuration
- Defined in:
- lib/cloud_manager/configuration/configuration.rb
Overview
The cloud-manager configuration holder.
This class is responsible for loading a configuration file, and instantiate the specific service configuration object for each defined service. The class also defines some functions, that the child configuration objects can use, to get information provided by other services.
Instance Attribute Summary collapse
-
#config_file ⇒ String
readonly
The file name of the configuration.
Instance Method Summary collapse
-
#dns_names_of(machine_alias) ⇒ Array<String>
Returns the DNS name list for the given machine.
-
#initialize(config_file, default_region = nil) ⇒ Configuration
constructor
Returns a new instance of Configuration.
-
#ips_of(machine_alias) ⇒ Array<String>
Returns the IP list for the given machine.
-
#manage ⇒ void
Start the management of the defined configuration.
Constructor Details
#initialize(config_file, default_region = nil) ⇒ Configuration
Returns a new instance of Configuration.
Every configured service part gets initialized.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cloud_manager/configuration/configuration.rb', line 27 def initialize(config_file, default_region = nil) @config_file = config_file @default_region = default_region @services = {} @config = YAML::load_file(@config_file) if @config.include?('services') @config['services'].each do |service_type, service_config| case service_type when 'ec2' service = CloudManager::Configuration::Service::EC2.new(service_config, @default_region, self) when 'ansible' service = CloudManager::Configuration::Service::Ansible.new(service_config, self) when 'test' service = CloudManager::Configuration::Service::Test.new(service_config, self) else raise "Unhandled service type: #{service_type}" end @services[service_type] = service end end end |
Instance Attribute Details
#config_file ⇒ String (readonly)
Returns the file name of the configuration.
17 18 19 |
# File 'lib/cloud_manager/configuration/configuration.rb', line 17 def config_file @config_file end |
Instance Method Details
#dns_names_of(machine_alias) ⇒ Array<String>
Returns the DNS name list for the given machine.
Every service that can provide DNS names will be asked.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cloud_manager/configuration/configuration.rb', line 95 def dns_names_of(machine_alias) dns_names = [] @services.each do |service_type, service| case service_type when 'ec2' dns_names.concat(service.dns_names_of(machine_alias)) else # this service type cannot provide machine dns names end end dns_names end |
#ips_of(machine_alias) ⇒ Array<String>
Returns the IP list for the given machine.
Every service that can provide IPs will be asked.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cloud_manager/configuration/configuration.rb', line 74 def ips_of(machine_alias) ips = [] @services.each do |service_type, service| case service_type when 'ec2' ips.concat(service.ips_of(machine_alias)) else # this service type cannot provide machine ip end end ips end |
#manage ⇒ void
might need to implement some service dependency handling
This method returns an undefined value.
Start the management of the defined configuration.
Each defined service gets managed in the order they are given in the configuration.
59 60 61 62 63 64 65 66 |
# File 'lib/cloud_manager/configuration/configuration.rb', line 59 def manage puts 'Starting management...' @services.each do |service_type, service| puts " - managing #{service_type}" service.manage end end |