Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (43 sloc) 2.354 kb
1 2 3 4 5 6 7 8 9 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "poolparty"
require "poolpartycl"

# name = ARGV.select {|arg| arg if Binary.available_binaries_for("cloud").include?(arg) }.first
name = ARGV.shift if Binary.available_binaries_for("cloud").include?(ARGV.first)
# If the options include -h and they don't include a valid command, then we can just pass the
# original options back, but if they do contain a binary, we don't want -h getting through to
# these options, so we'll strip it if it's included
DUP_ARG = ARGV.dup
new_args = DUP_ARG.map {|arg| DUP_ARG.delete(arg) unless help_array.include?(arg) || Binary.available_binaries_for("cloud").include?(arg) }
new_args = new_args.reject {|arg| Binary.available_binaries_for("cloud").include?(arg) }.empty? ? ARGV : (name ? (help_array.each {|arg| DUP_ARG.delete(arg)}; DUP_ARG) : DUP_ARG)

# Let's make sure if no command is passed in that we show the help message
new_args.push("-h") unless name

# Binary.list_binaries_for("cloud")
extra_help_string = <<-EOE

Cloud commands
cloud start starts a single instance in your cloud.
cloud bootstrap bootstraps an instance or multiple instances
cloud configure configures an instance or multiple instances
cloud provision combines bootstrap and configures an instance or multiple instances
cloud expand expands the cloud by a single instance
cloud contract contracts the cloud by a single instance
cloud describe show the configuration of the current clouds.rb configuration file
cloud list show a list of the current instances on the cloud
cloud show shows output about the clouds.rb
cloud ssh ssh into an instance of the cloud
cloud terminate terminate the cloud
EOE

o = PoolParty::Optioner.new(new_args, {
  :extra_help => extra_help_string,
  :abstract => true}) do |opts, optioner|
  opts.on('-n cloudname', '--name name', 'Address this cloud') { |c| optioner.cloudname c }
end

program_name = "#{File.basename($0)}-#{name}"
program_location = File.join(Binary.binary_directory, program_name)

command_line = "#{program_location}"

# Run it from the command-line first
if Binary.available_binaries_for("cloud").include?(name)
  system command_line, *new_args
else
  puts "Unknown poolparty binary: #{name}"
end
Something went wrong with that request. Please try again.