Skip to content

Commit

Permalink
ensure that ec2 options are passed to ec2 gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
fairchild committed Apr 26, 2009
1 parent 3fc79b3 commit 7903deb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
rdoc/*
.com.apple.timemachine.supported
.DS_Store
*tmp*
Expand Down
1 change: 0 additions & 1 deletion bin/cloud-list
Expand Up @@ -10,7 +10,6 @@ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
end

o.loaded_clouds.each do |cld|

puts header("Listing cloud #{cld.name}")

puts subheader("Active instances")
Expand Down
1 change: 0 additions & 1 deletion lib/poolparty/net/remoter_base.rb
Expand Up @@ -85,7 +85,6 @@ def describe_instances(o={})
def self.launch_instance!(o={}, &block)
@cloud = o.delete(:cloud) if o[:cloud]
@keypair = o.delete(:keypair) if o[:keypair]

@inst = launch_new_instance!( o.merge(:keypair => @keypair.to_s) )
sleep(2)

Expand Down
40 changes: 22 additions & 18 deletions lib/poolparty/net/remoter_bases/ec2/ec2.rb
Expand Up @@ -43,23 +43,27 @@ def initialize(par, opts={}, &block)
super(par, &block)
end

def self.launch_new_instance!(o = options)
new(o).launch_new_instance!
# Requires a hash of options
def self.launch_new_instance!(o )
new(o).launch_new_instance!(o)
end

# TODO: Fix the key_name issue
def launch_new_instance!(o={})
# Start a new instance with the given options
def launch_new_instance!(o)
raise "You must pass a keypair to launch an instance, or else you wont be able to login. options = #{o.inspect}" if !@cloud.keypair
instance = ec2(o).run_instances(
:image_id => ami,
:user_data => options[:user_data],
:minCount => 1,
:maxCount => options[:num] || 1,
:key_name => ::File.basename(keypair.is_a?(String) ? keypair : keypair.full_filepath),
:availability_zone => availabilty_zone,
:instance_type => options[:size] || Default.size,
:group_id => security_group)

o.merge!( :image_id => ami,
:user_data => options[:user_data],
:min_count => 1,
:max_count => options[:num] || 1,
:key_name => ::File.basename(keypair.is_a?(String) ? keypair : keypair.full_filepath),
:availability_zone => availabilty_zone,
:instance_type => options[:size] || Default.size,
:group_id => security_group,
:addressing_type => "public",
:kernel_id => nil
)
instance = ec2(o).run_instances(o)
begin
h = EC2ResponseObject.get_hash_from_response(instance.instancesSet.item.first)
#h = instance.instancesSet.item.first
Expand Down Expand Up @@ -97,11 +101,16 @@ def describe_instances(o={})
end.compact.sort {|a,b| a[:index] <=> b[:index] }
end

# EC2 connections
def ec2(o={})
@ec2 ||= self.class.ec2(o)
end
def self.ec2(o={})
@ec2 ||= EC2::Base.new( :access_key_id => o[:access_key],
:secret_access_key => o[:secret_access_key]
)
end

# Get the ec2 description for the response in a hash format
def get_instances_description(o={})
key_hash = {:keypair => ::File.basename(keypair.is_a?(String) ? keypair : keypair.full_filepath)}
Expand Down Expand Up @@ -178,11 +187,6 @@ def create_snapshot
ec2.create_snapshot(:volume_id => ebs_volume_id)
end

# EC2 connections
def ec2(o={})
@ec2 ||= self.class.ec2(o)
end

# These are tasks that run before the configuration runs
def before_configuration_tasks
if set_master_ip_to && master.ip && master.ip.to_s != set_master_ip_to.to_s
Expand Down

0 comments on commit 7903deb

Please sign in to comment.