Sha256: ffd53c365d71245402856c5e3b88cbc8b2fc48334481976c08adc22fe9d98f60

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "poolparty"
require "poolpartycl"
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
  opts.on('-f [remote|local]', '--from [remote|local]', 'Remote or local (default: local)')    { |o| optioner.location o }
  opts.on('-r', '--remote', 'Remote listing')    { optioner.location "remote" }
  opts.on('-l', '--local', 'Local listing')    { optioner.location "local" }
  opts.on('-n name', '--name name', 'Listing for cloud name')    { |c| optioner.cloudname c }
end
load_pool(o.spec || Binary.get_existing_spec_location)

@location = o.location ? o.location : "remote"

include Remote

@clouds = o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds

@clouds.each do |name, cloud|

  with_cloud(cloud, {:location => @location, :testing => o.testing, :verbose => o.verbose}) do
    vputs header("Maintaining cloud #{name}")
    if !minimum_number_of_instances_are_running?
      vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
      vputs "Launching new instance"
      expand_cloud_if_necessary( !testing )
    elsif !maximum_number_of_instances_are_not_running?
      vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
      vputs "Shutting down non-master instance"
      contract_cloud_if_necessary( !testing )
    end    
    vputs "Cloud is maintained"
    
    if should_expand_cloud?
      vputs "Expanding cloud based on load"
      expand_cloud_if_necessary
    elsif should_contract_cloud?
      vputs "Contracting cloud based on load"
      contract_cloud_if_necessary
    end
  end  

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auser-poolparty-0.2.39 bin/cloud-maintain