Method: KnifeCloudstack::CsStackCreate#print_local_hosts

Defined in:
lib/chef/knife/cs_stack_create.rb


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/chef/knife/cs_stack_create.rb', line 302

def print_local_hosts
  hosts = []
  current_stack[:servers].each do |server|
    next unless server[:local_hosts]
    name = server[:name].split(' ').first
    ip = public_ip_for_host(name)
    server[:local_hosts].each { |host|
      hostname = host.sub(/\$\{environment\}/, get_environment)
      hosts << "#{ip}    #{hostname}"
    }
  end
  unless hosts.empty?
    puts "\nAdd this to your /etc/hosts file:"
    puts hosts.join("\n")
  end
end