forked from auser/poolparty
/
server-ensure-provisioning
executable file
·33 lines (28 loc) · 1.18 KB
/
server-ensure-provisioning
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "poolparty"
require "poolparty/lite"
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
opts.on('-n cloudname', '--name name', 'Start cloud by this name') { |c| optioner.cloudname c }
opts.on('-i num', '--num i', 'Instance number') { |i| optioner.inst_num i.to_i }
end
schema = ::PoolParty.load_cloud_from_json
o.loaded_clouds.each do |cld|
cld.update_from_schema(schema)
# If an IP or DNS name is given, bootstrap that node, otherwise, bootstrap all running nodes.
nodes = !o.unflagged_args.empty? ? o.unflagged_args : cld.remote_instances_list.collect {|inst| inst.ip if inst.running? }.compact
if nodes.empty?
puts "No nodes to bootstrap"
else
if o.inst_num?
::PoolParty::Provision::BootStrapper.new( nodes[o.inst_num], :cloud => cld )
::PoolParty::Provision::DrConfigure.new( nodes[o.inst_num], :cloud => cld )
else
nodes.each do |address|
puts "bootstrapping: #{address}"
::PoolParty::Provision::BootStrapper.new( address, :cloud => cld )
::PoolParty::Provision::DrConfigure.new( address, :cloud => cld )
end
end
end
end