Browse files

We fixed the rather odd, broken adaptee problem; now working on actua…

…lly associating addresses.
  • Loading branch information...
1 parent 5f269ba commit 2f6c7c4f6886a0a0e75eeef18c4d5e63eaf218ab @schade schade committed Nov 29, 2012
View
2 lib/ironfan/dsl/ec2.rb
@@ -61,7 +61,7 @@ def to_display(style,values={})
values["AZ"] = default_availability_zone
return values if style == :default
- values["Stable IP"] = public_ip if public_ip
+ values["Public IP"] = public_ip if public_ip
values
end
View
7 lib/ironfan/provider/ec2.rb
@@ -15,13 +15,6 @@ def self.connection
@@connection ||= Fog::Compute.new(self.aws_credentials.merge({ :provider => 'AWS' }))
end
-# def self.eip
-# c ||= Fog::Compute.new(self.aws_credentials.merge({ :provider => 'AWS' }))
-# address = c.addresses.create
-# address.server = server
-# server.reload
-# end
-
def self.elb
@@elb ||= Fog::AWS::ELB.new(self.aws_credentials)
end
View
47 lib/ironfan/provider/ec2/elastic_ip.rb
@@ -3,37 +3,44 @@ class Provider
class Ec2
class ElasticIp < Ironfan::Provider::Resource
- delegate :public_ip, :allocation_id, :server_id, :network_interface_id,:domain, :initialize, :destroy, :server=, :server, :save, :associate, :disassociate,
+ delegate :addresses, :associate_address, :allocation_id,
+ :allocation_id=, :destroy, :domain, :domain=,
+ :describe_addresses, :disassociate_address, :domain, :id,
+ :network_interface_id, :network_interface_id=, :public_ip,
+ :public_ip=, :save, :server=, :server, :server_id, :server_id=,
:to => :adaptee
-
- def self.shared?() true; end
+
+ def self.shared?() true; end
def self.multiple?() false; end
def self.resource_type() :elastic_ip; end
def self.expected_ids(computer) [ computer.server.ec2.public_ip ]; end
- def name() public_ip; end
-
+ def name() adaptee.public_ip ; end
+
+ Ec2.connection.servers.each do |m|
+ pp m.id, m.state, m.public_ip_address if m.state != "terminated"
+ end
+
+ # FIXME: This is very broken, but somehow works around the breakage
+ def self.new(*args)
+ x = super
+ x.adaptee = args[0][:adaptee]
+ x
+ end
+
def self.load!(cluster=nil)
Ec2.connection.addresses.each do |eip|
- pp(eip.public_ip)
- remember new(:adaptee => eip)
- pp(eip.public_ip)
+ register eip
Chef::Log.debug("Loaded #{eip}")
end
- raise "hell"
end
- def address(ip)
-
- end
-
- def attach(ip, timeout)
-
- end
-
- def detach(ip, timeout)
-
- end
+ def self.attach()
+ Ec2.connection.addresses.each do |eip|
+ eip.associate_address(eip.id, adaptee.public_ip) unless eip.public_ip_address.nil?
+ end
+
+ end
end
end
end
View
4 lib/ironfan/provider/ec2/machine.rb
@@ -87,7 +87,6 @@ def to_display(style,values={})
values["Volumes"] = volumes.map(&:id).join(', ')
values["SSH Key"] = key_name
values
- pp(public_ip_address)
end
def ssh_key
@@ -161,7 +160,8 @@ def self.create!(computer)
machine = Machine.new(:adaptee => fog_server)
computer.machine = machine
# set elastic_ip here?
- # machine.ip = elastic_ip if elastic_ip
+ #pp computer.machine.public_ip_address
+ #computer.machine.public_ip_address = computer.server.ec2.public_ip unless computer.server.ec2.public_ip.nil?
remember machine, :id => computer.name
fog_server.wait_for { ready? }

0 comments on commit 2f6c7c4

Please sign in to comment.