Sha256: 8c37d656d0b6c3f97ca9404e8e4d1f74e456e90fec840d5be06637e23296a087
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
module PoolParty module Ec2Wrapper module InstanceMethods def ec2 @ec2 ||= EC2::Base.new(:access_key_id => "access", :secret_access_key => "shhhh") end end end class Master def launch_new_instance! letter = ("a".."z").to_a[instances.size] # For unique instance_ids h = {:instance_id => "i-58ba56#{letter}", :ip => "ip-127-0-0-1.aws.amazonaws.com", :status => "pending", :keypair => "alist", :launching_time => Time.now } instances << h Thread.new {wait 0.01;h[:status] = "running"} # Simulate the startup time return h end # Shutdown the instance by instance_id def terminate_instance!(instance_id) instances.select {|a| a[:instance_id] == instance_id}[0][:status] = "terminating" end # Instance description def describe_instance(id) item = instances.select {|a| a[:instance_id] == id}[0] EC2ResponseObject.get_hash_from_response(item) end # Get instance by id def get_instance_by_id(id) get_instances_description.select {|a| a.instance_id == id}[0] rescue nil end # Get the s3 description for the response in a hash format def get_instances_description instances end def get_non_empty_instances_description EC2::Response.parse(:xml => open("#{File.dirname(__FILE__)}/../files/response.txt").read) end # Fake the ec2 connection def ec2 @ec2 ||= EC2::Base.new(:access_key_id => "not a key", :secret_access_key => "not a key") end # Some basic instances, not totally necessary def instances @instances ||= [] end end class RemoteInstance def ssh(l="") "true" end def scp(s,d,o={}) "true" end def run(s) "true" end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
auser-poolparty-0.1.2 | spec/helpers/ec2_mock.rb |
jtzemp-poolparty-0.1.2 | spec/helpers/ec2_mock.rb |