Sha256: 89f46fc78ace29c0bad12fe0a5451c23dc761d9aa61a179fd43bdf7151f84079

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

#!/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}

  contracts the cloud by a single instance
EOS

  short_desc "contracts the cloud by a single instance"

  run do |command|    
    @loaded_clouds.each do |cld|
      
      node_to_terminate = cld.nodes.last
      # node_to_terminate.cloud = cld
      
      puts cld.nodes.size
      if cld.nodes.size - 1 < cld.minimum_instances
	puts "Contracting instances by 1 in cloud #{cld.name} will lower the number of instances below specified minimum (#{cld.minimum_instances})"
	next
      end
      msg = [
        "Contracting cloud #{cld.name} (#{cld.keypair}) by 1",
        "#{cld.nodes.size} running instances (#{cld.minimum_instances} - #{cld.maximum_instances})",
        " node: #{node_to_terminate.public_ip}"
      ]
      
      puts msg.join("\n")
      
      node_to_terminate.terminate!
      
      puts "#{node_to_terminate.public_ip} has been terminated"
    end    
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
poolparty-1.6.9 bin/cloud-contract
poolparty-1.6.8 bin/cloud-contract
poolparty-1.6.7 bin/cloud-contract
poolparty-1.6.6 bin/cloud-contract
poolparty-1.6.5 bin/cloud-contract
poolparty-1.6.4 bin/cloud-contract
poolparty-1.6.3 bin/cloud-contract
poolparty-1.6.2 bin/cloud-contract
poolparty-1.6.1 bin/cloud-contract
poolparty-1.6.0 bin/cloud-contract
poolparty-1.5.0 bin/cloud-contract
poolparty-1.4.8 bin/cloud-contract
poolparty-1.4.7 bin/cloud-contract