Sha256: 8d74d05cc7f31326247e4e5e17081dd81ca60ca1071fe6c18ec1485f1de53a05
Contents?: true
Size: 1.63 KB
Versions: 9
Compression:
Stored size: 1.63 KB
Contents
require 'trollop' module SimplePerf module CLI class Chaos include Shared def execute opts = Trollop::options do version SimplePerf::VERSION banner <<-EOS Randomly terminates an instance in the specified stack Usage: simple_perf chaos -e ENVIRONMENT -n STACK_NAME EOS opt :help, "Display Help" opt :environment, "Set the target environment", :type => :string opt :name, "Stack name to manage", :type => :string end Trollop::die :environment, "is required but not specified" unless opts[:environment] Trollop::die :name, "is required but not specified" unless opts[:name] config = Config.new.environment opts[:environment] command = 'simple_deploy instances' + ' -e ' + opts[:environment] + ' -n ' + opts[:name] output = `#{command}` output.gsub!(/\r\n?/, "\n") list = output.split("\n") target = list.sample puts "Target locked: " + target AWS.config( :access_key_id => config['access_key'], :secret_access_key => config['secret_key']) ec2 = AWS::EC2.new(:region => config['region']) ec2.instances.each do |i| if i.vpc_id if(i.private_ip_address == target) puts "Terminating instance with private IP: " + target i.terminate end elsif if(i.ip_address == target) puts "Terminating instance with public IP: " + target i.terminate end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems