Sha256: cd5015c09013f84420d2718bae276ca5a019ee6e996cb13c34d553911d1691cc

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 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}) do
    logger.info header("Maintaining cloud #{name}")
    if !minimum_number_of_instances_are_running?
      logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
      logger.warn "Launching new instance"
      expand_cloud_if_necessary( !testing )
    elsif !maximum_number_of_instances_are_not_running?
      logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
      logger.warn "Shutting down non-master instance"
      contract_cloud_if_necessary( !testing )
    else
      logger.info "Cloud is maintained"
    end    
  end  

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auser-poolparty-0.2.2 bin/cloud-maintain
auser-poolparty-0.2.3 bin/cloud-maintain