Skip to content

Commit

Permalink
Added cloud reboot to cycle instances
Browse files Browse the repository at this point in the history
  • Loading branch information
auser committed Oct 13, 2009
1 parent a85649a commit 22006c8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
23 changes: 23 additions & 0 deletions bin/cloud-reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + "/../lib")
require "poolparty"

require 'git-style-binary/command'

GitStyleBinary.command do
banner <<-EOS
Usage: #{$0} #{all_options_string}
Cycle through nodes in the cloud and wait for the autoscaler to reboot
EOS

short_desc "Cycle the instances"

run do |command|

@loaded_clouds.each do |cld|
cld.reboot!
end

end
end
2 changes: 1 addition & 1 deletion lib/cloud_providers/ec2/helpers/elastic_auto_scaler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def teardown
# cloud.nodes.each {|n| n.terminate! }
delete_autoscaling_group!
delete_launch_configuration!
puts ""
end
end

Expand Down Expand Up @@ -75,7 +76,6 @@ def ensure_no_scaling_activities
sleep 1
end
end
puts ""
reset!
end
public
Expand Down
31 changes: 31 additions & 0 deletions lib/poolparty/cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,37 @@ def teardown
#TODO: keypair.delete # Do we want to delete the keypair? probably, but not certain
end

def reboot!
orig_nodes = nodes
num_nodes = nodes.size

if autoscalers.empty?
puts <<-EOE
No autoscalers defined
Launching new nodes and then shutting down original nodes
EOE
# Start new nodes
expand_by(num_nodes)
# Terminate the nodes
orig_nodes.each do |node|
node.terminate!
end
else
# Terminate the nodes
orig_nodes.each do |node|
node.terminate!
puts "----> Terminated node: #{node.instance_id}"
# Wait for the autoscaler to boot the next node
puts "----> Waiting for new node to boot via the autoscaler"
loop do
reset!
break if nodes.size == num_nodes
sleep 1
end
end
end
end

def compile!
build_tmp_dir unless chef_repo.nil?
end
Expand Down

0 comments on commit 22006c8

Please sign in to comment.