Sha256: 3a969a1df43bf539e41b6093d50762518921765d64a55a1f4b161a1a943d4c05

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "poolparty/lite"

list_type = ARGV.shift || "ip"

json_file = ARGV[0] || PoolParty::Default.properties_hash_file
raise "ERROR: no json_file given" if !json_file
schema = PoolParty::Schema.new( ::File.read(json_file) )

remoter_base = schema.options.remote_base

# TODO: WTF? Change this
instances = PoolParty::Remote::Ec2.describe_instances(schema.options)
inst_array = instances.map {|inst| inst.send list_type.to_sym }

print_array = 
case list_type
when "ip"
  inst_array.select {|a| a =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/}
when "internal_ip"
  inst_array.compact.map {|ip| ip.gsub(/ip-/, '').gsub(/\.ec2\.internal/, '').gsub(/-/, '.') }
else
  inst_array
end

print print_array.compact.join("\t")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auser-poolparty-1.1.5 bin/server-list-active