Module: Lakitu::Generator
- Defined in:
- lib/lakitu/generator.rb
Constant Summary collapse
- CLAUSE_TEMPLATE =
<<-EOF Host <%= host %><% if keyfile %> IdentityFile <%= keyfile %> <% end %> HostName <%= public_ip || private_ip %> EOF
Class Method Summary collapse
Class Method Details
.generate ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lakitu/generator.rb', line 11 def self.generate ([ Lakitu::MANAGED_SSH_CONFIG_TOKEN, Lakitu::FileOperator::local_ssh_config ] + instances.map do |instance| instance[:host] = format_for(instance[:provider], instance[:profile]) % instance instance[:host].gsub!(/[ \W-]+/, '-') key_path = Lakitu::FileOperator.key_path instance[:key] instance[:keyfile] = key_path if key_path ERB.new(CLAUSE_TEMPLATE).result(OpenStruct.new(instance).instance_eval { binding }) end).join("\n") end |
.instances ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/lakitu/generator.rb', line 21 def self.instances result = Lakitu::Provider.providers.map do |provider_class| Lakitu.logger.debug "Getting instances for #{provider_class.name}" get_instances(provider_class.new) end.flatten Lakitu.logger.info "Found #{result.length} instances" result end |