Skip to content
Browse files

Merge pull request #1 from schade/feature/196_elastic_ips

Feature/196 elastic ips; non-final
  • Loading branch information...
2 parents 1710c8d + e6418e6 commit bfe0b9f6412e538260cf030bba525bd6ebb6cd2a @schade schade committed
View
3 lib/chef/knife/ironfan_knife_common.rb
@@ -1,4 +1,4 @@
-require 'chef/knife'
+ require 'chef/knife'
module Ironfan
module KnifeCommon
@@ -140,6 +140,7 @@ def bootstrapper(computer)
bootstrap.name_args = [ hostname ]
bootstrap.config[:computer] = computer
bootstrap.config[:server] = server
+ bootstrap.config[:elastic_ip] = server.associate_address(elastic_ip)
bootstrap.config[:run_list] = server.run_list
bootstrap.config[:ssh_user] = config[:ssh_user] || computer.ssh_user
bootstrap.config[:attribute] = config[:attribute]
View
7 lib/ironfan/dsl/ec2.rb
@@ -14,7 +14,7 @@ class Ec2 < Cloud
magic :bootstrap_distro, String, :default => ->{ image_info[:bootstrap_distro] }
magic :chef_client_script, String
magic :default_availability_zone, String, :default => ->{ availability_zones.first }
- magic :elastic_ip String
+ magic :elastic_ip, String
collection :elastic_load_balancers, Ironfan::Dsl::Ec2::ElasticLoadBalancer, :key_method => :name
magic :flavor, String, :default => 't1.micro'
collection :iam_server_certificates, Ironfan::Dsl::Ec2::IamServerCertificate, :key_method => :name
@@ -47,11 +47,6 @@ def image_id
result = read_attribute(:image_id) || image_info[:image_id]
end
- def elastic_ip(address)
- Ironfan.safely do
- Ironfan.fog_connection.associate_address(self.fog_server.id, address)
- end
-
def ssh_key_name(computer)
keypair ? keypair.to_s : computer.server.cluster_name
end
View
7 lib/ironfan/provider/ec2.rb
@@ -15,6 +15,13 @@ 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
19 lib/ironfan/provider/ec2/elastic_ip.rb
@@ -3,7 +3,26 @@ class Provider
class Ec2
class ElasticIp < Ironfan::Provider::Resource
+ delegate :allocate, :associate, :describe, :to => :adaptee
+ field :domain, String, :default => 'standard'
+
+ :associate
+
+ def address(ip)
+
+ end
+
+ def attach(ip, timeout)
+
+ end
+
+ def detach(ip, timeout)
+
+ end
end
end
end
end
+
+# 'publicIp', 'domain'
+# vpc use only = 'allocationId', 'associationId', 'instanceId', 'requestId'
View
5 lib/ironfan/provider/ec2/machine.rb
@@ -87,6 +87,7 @@ 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
@@ -159,6 +160,8 @@ def self.create!(computer)
fog_server = Ec2.connection.servers.create(launch_desc)
machine = Machine.new(:adaptee => fog_server)
computer.machine = machine
+ # set elastic_ip here?
+ # machine.ip = elastic_ip if elastic_ip
remember machine, :id => computer.name
fog_server.wait_for { ready? }
@@ -236,7 +239,7 @@ def self.launch_description(computer)
:user_data => JSON.pretty_generate(user_data_hsh),
:block_device_mapping => block_device_mapping(computer),
:availability_zone => cloud.default_availability_zone,
- :monitoring => cloud.monitoring,
+ :monitoring => cloud.monitoring
}
# VPC security_groups can only be addressed by id (not name)
View
1 lib/ironfan/requirements.rb
@@ -35,6 +35,7 @@
require 'ironfan/provider/ec2/keypair'
require 'ironfan/provider/ec2/placement_group'
require 'ironfan/provider/ec2/security_group'
+require 'ironfan/provider/ec2/elastic_ip'
require 'ironfan/provider/ec2/elastic_load_balancer'
require 'ironfan/provider/ec2/iam_server_certificate'

0 comments on commit bfe0b9f

Please sign in to comment.
Something went wrong with that request. Please try again.