Class: CloudFormationTool::CLI::Recycle
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- CloudFormationTool::CLI::Recycle
- Includes:
- CloudFormationTool
- Defined in:
- lib/cloud_formation_tool/cli/recycle.rb
Constant Summary
Constants included from CloudFormationTool
Instance Method Summary collapse
Methods included from CloudFormationTool
#aws_config, #awsas, #awscdn, #awscf, #awscreds, #awsec2, #awsecs, #awss3, #cf_bucket_name, #find_profile, #profile, #region, #s3_bucket_name
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloud_formation_tool/cli/recycle.rb', line 10 def execute st = CloudFormation::Stack.new(stack_name) st.asgroups.select do |res| asg_name.nil? or (res.logical_resource_id == asg_name) end.collect do |res| Thread.new do grp = res.group torecycle = cursize = grp.instances.size puts "#{grp.name}: Recyclying #{cursize} instance" + (cursize > 1 ? "s" : "") while torecycle > 0 grp.set_desired_capacity(desired_capacity: (cursize + 1)) while grp.instances.size != (cursize + 1) sleep 5 grp.reload end grp.set_desired_capacity(desired_capacity: cursize) while grp.instances.size != cursize sleep 5 grp.reload end torecycle -= 1 puts "#{grp.name}: Left to recycle - #{torecycle}" end end end.each(&:join).length > 0 or error "No valid Autoscaling groups found named #{asg_name}" end |