#!/usr/bin/env ruby $:.unshift(File.dirname(__FILE__) + "/../lib") require "poolparty" # require "poolpartycl" require 'git-style-binary/command' GitStyleBinary.command do version "PoolParty #{$0} command" 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| puts header("Contracting cloud #{cld.name}") puts "#{cld.nodes(:status => "running").size} running instances (#{cld.minimum_instances} minimum instances)" puts testing ? "Not contracting (test mode)" : "Contracting the cloud if possible" if cld.minimum_instances < cld.nodes(:status => "running").size last_instance_id = cld.nodes(:status => "running").last[:instance_id] cld.remote_base.terminate_instance! cld.dsl_options.merge(:instance_id => last_instance_id) else puts "The cloud #{cld.name} is running minimum instances (#{cld.nodes(:status => "running").size})" end end end end