Browse files

:auto_elastic_ip functionality to separate it from known :elastic_ip …

…addresses; fixing docstrings for new features.
  • Loading branch information...
1 parent f455235 commit 2e807d9e9db03e3612dbe2dfcb70f86c95dd654c @schade schade committed Jan 9, 2013
Showing with 6 additions and 28 deletions.
  1. +6 −28 lib/ironfan/provider/ec2/elastic_ip.rb
View
34 lib/ironfan/provider/ec2/elastic_ip.rb
@@ -58,8 +58,7 @@ def self.save!(computer)
return unless computer.created?
# instead of just returning if the elastic_ip is blank we first test if the symbol exists and whether an actual
# address exists in the collection; All three require the presence of elastic_ip in the facet definition. We
-<<<<<<< Updated upstream
- # also, in the absence of an elastic_ip value, can use allocation_id to attach a VPC Elastic IP.
+ # also, for connecting to a VPC, can use allocation_id for the given :elastic_ip to attach an Elastic IP.
return unless computer.server.ec2.include?(:elastic_ip)
if ( computer.server.ec2.elastic_ip.nil? and cloud.vpc.nil? )
# First, :elastic_ip is set, no address is currently allocated for this connection's owner
@@ -74,38 +73,17 @@ def self.save!(computer)
elastic_ip = computer.server.addresses.first.public_ip
Chef::Log.debug( "using first available Elastic IP address" )
end
- elsif ( !computer.server.ec2.elastic_ip.nil? and cloud.vpc.nil? )
- # Third, :elastic_ip is set, has an address available to use and has a set value available in facet definition.
+ elsif ( !computer.server.ec2.elastic_ip.nil? or cloud.vpc.nil? )
+ # Third, :elastic_ip is set, has an address available to use, has a set value in facet definition and is not VPC.
elastic_ip = computer.server.ec2.elastic_ip
Chef::Log.debug( "using requested Elastic IP address" )
- else ( computer.server.ec2.elastic_ip.nil? and !cloud.vpc.nil? )
+ elsif ( computer.server.ec2.elastic_ip.nil? and !cloud.vpc.nil? )
# Fourth, is exactly like Third but on a VPC domain. (this is functionaility for attaching VPC Elastic IPS)
allocation_id = computer.server.ec2.allocation_id
Chef::Log.debug( "using Elastic IP address matched to given Allocation ID" )
-=======
- # also, in the case of VPC Elastic IPs, can discover and use allocation_id to attach a VPC Elastic IP.
- if ( computer.server.ec2.auto_elastic_ip == 'first' and cloud.vpc.nil? )
- if computer.server.addresses.nil?
- Ec2.connection.allocate_address
- load!
- elastic_ip = computer.server.addresses.first.public_ip
- Chef::Log.debug( "allocating new Elastic IP address" )
- else
- # Second, :elastic_ip is set, has an address available to use, has no set value in facet definition and is not VPC.
- elastic_ip = computer.server.addresses.first.public_ip
- Chef::Log.debug( "using first available Elastic IP address" )
->>>>>>> Stashed changes
+ else
+ ui.fatal("You have set both :elastic_ip and :auto_elastic_ip in your facet definition; which are mutually exclusive.")
end
- elsif ( !computer.server.ec2.elastic_ip.nil? or cloud.vpc.nil? )
- # Third, :elastic_ip is set, has an address available to use, has a set value in facet definition and is not VPC.
- elastic_ip = computer.server.ec2.elastic_ip
- Chef::Log.debug( "using requested Elastic IP address" )
- elsif ( computer.server.ec2.elastic_ip.nil? and !cloud.vpc.nil? )
- # Fourth, is exactly like Third but on a VPC domain. (this is functionaility for attaching VPC Elastic IPS)
- allocation_id = computer.server.ec2.allocation_id
- Chef::Log.debug( "using Elastic IP address matched to given Allocation ID" )
- else
- ui.fatal("You have set both :elastic_ip and :auto_elastic_ip in your facet definition; which are mutually exclusive.")
end
Ironfan.step(computer.name, "associating Elastic IP #{elastic_ip}", :blue)
Ironfan.unless_dry_run do

0 comments on commit 2e807d9

Please sign in to comment.