Sha256: aa86e381f8ddf7c123f699eab068e903da011fb896d032542171e89961db9b3f

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "poolparty"
require "poolpartycl"

o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
  opts.on('-n name', '--name name', 'Update hosts for local pool named [name]')    { |p| optioner.cloudname p }
end

o.loaded_clouds.each do |cloud|
  with_cloud(cloud) do
    puts "Cloud: #{name}"
    
    new_hosts_listing = returning Array.new do |arr|
      
      puts list_of_running_instances
      
      list_of_running_instances.each do |ri|
        vputs ri.hosts_file_listing_for(self)
        arr << ri.hosts_file_listing_for(self)
      end
      other_clouds.each do |other|
        other.list_of_running_instances.each do |ri|
          vputs ri.hosts_file_listing_for(self)
          arr << ri.hosts_file_listing_for(self)
        end
      end
    end.join("\n")
    
    if testing
      puts new_hosts_listing
    else
      new_hosts_file = "#{Base.manifest_path}/classes/hosts.pp"
      
      arr = returning Array.new do |arr|
        new_hosts_listing.split(/\n/).each do |line|
          parts = line.split(/\t/).map {|a| a.chomp }
          ip,hostname,aliases = parts[0], parts[1], parts[2..-1]
          puts "ip: #{ip} for #{hostname}"
          arr << PoolParty::Resources::Host.new(:name => hostname, :ip => Resolv::DNS.new.getaddress(ip).to_s, :alias => aliases).to_string
        end
      end
      
      ::File.open(new_hosts_file, "w+") {|f| f << arr.join("\n") }
    end
    
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
auser-poolparty-0.2.67 bin/server-update-hosts
auser-poolparty-0.2.68 bin/server-update-hosts
auser-poolparty-0.2.69 bin/server-update-hosts
auser-poolparty-0.2.70 bin/server-update-hosts
auser-poolparty-0.2.71 bin/server-update-hosts
auser-poolparty-0.2.72 bin/server-update-hosts
auser-poolparty-0.2.74 bin/server-update-hosts
poolparty-0.2.69 bin/server-update-hosts