Method: KnifeCloudstack::CsStackCreate#print_local_hosts

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


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/chef/knife/cs_stack_create.rb', line 281

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