Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

196_elastic_ips #219

Merged
merged 20 commits into from

2 participants

@schade

As requested at #196 (comment), Ironfan will now associate an Elastic IP given via the facet definition for acol-vpn in clusters/acol.rb currently found on the testmonkey repo (example here #219 (comment)).

Also, per the same request, knife cluster ssh <facet-name> will use the Elastic IP if it has been set on the machine.

NOTE:
Current to_display methods in Ironfan cause the Elastic IP to not always show properly in your CLI console if a public_ip_address was previously assigned to the instance, but only until the next sync run; that particular item is beyond the scope of the original request.

Jerry Jackson and others added some commits
Jerry Jackson pushing minor changes from before start of feature code session e4c13fa
Jerry Jackson Adding code to activate Elastic IPs to lib/ironfan/dsl/ec2.rb 8255f6f
Jerry Jackson Merge branch 'master' of https://github.com/infochimps-labs/ironfan a15daae
Jerry Jackson Merge branch 'master' of https://github.com/infochimps-labs/ironfan 1710c8d
Jerry Jackson added some more bits to recognize elastic ips; Ironfan still ignoring…
… my pleas to asscoiate at this point in time.
414e149
Jerry Jackson pushed still non-working state to repo for coop testing 714f53c
Jerry Jackson recent changes added to the mix; todo: fix missing method 951b9dc
Jerry Jackson Elastic IP now attaches at launch time; still working on knife cluste…
…r ssh functionality.
e6418e6
@schade schade Merge pull request #1 from schade/feature/196_elastic_ips
Feature/196 elastic ips; non-final
bfe0b9f
Jerry Jackson added changes to various ec2 files for setting up basic elastic ip fu…
…nctionality
f4e8485
Jerry Jackson Merge branch 'master' of https://github.com/infochimps-labs/ironfan i…
…nto feature/196_elastic_ips
5f269ba
Jerry Jackson We fixed the rather odd, broken adaptee problem; now working on actua…
…lly associating addresses.
2f6c7c4
Jerry Jackson Merge branch 'master' of https://github.com/infochimps-labs/ironfan i…
…nto feature/196_elastic_ips
ce3dd0a
Jerry Jackson pushing changes that put us back in a state which completes the run w…
…ithout errors; still isn't attaching the elastic ip but is going through the motions.
76448df
Jerry Jackson push yesterday's changes to personal repo so that work can be done on…
… remaining issues.
8603763
Jerry Jackson Elastic IPs now properly attach at save/sync and are used when availa…
…ble by 'knife cluster ssh' as requested.
00aad33
Jerry Jackson Elastic IPs now properly attach at save/sync and are used when availa…
…ble by 'knife cluster ssh' as requested. Removed a last remaining 'raise hell' using during testing from machine.rb
94287ef
@schade schade Merge pull request #2 from schade/feature/196_elastic_ips
Feature/196 elastic ips
13e68a6
Jerry Jackson Continuing removal of miscellaneous bits used for testing during bug …
…wrangling sessions.
cefc539
Jerry Jackson Merge branch 'develop' of https://github.com/schade/ironfan into develop 468b81f
@temujin9

Looks good, though I see some minor tweaks. I'll make them, just pointing out for next time:

  • Don't duplicate information if it can be inferred (domain is equivalent vpc.nil? ? 'standard' : 'vpc')
  • Your FIXME shim on new is now unnecessary (underlying bug squashed during later dev?)
  • Cleaned up the legacy debugging code, to throw debugging statements in more general cases
@temujin9 temujin9 merged commit 21dd0d5 into infochimps-labs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 7, 2012
Commits on Nov 9, 2012
Commits on Nov 14, 2012
Commits on Nov 15, 2012
  1. added some more bits to recognize elastic ips; Ironfan still ignoring…

    Jerry Jackson authored
    … my pleas to asscoiate at this point in time.
  2. pushed still non-working state to repo for coop testing

    Jerry Jackson authored
Commits on Nov 19, 2012
  1. recent changes added to the mix; todo: fix missing method

    Jerry Jackson authored
Commits on Nov 20, 2012
  1. Elastic IP now attaches at launch time; still working on knife cluste…

    Jerry Jackson authored
    …r ssh functionality.
  2. @schade

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

    schade authored
    Feature/196 elastic ips; non-final
Commits on Nov 27, 2012
  1. added changes to various ec2 files for setting up basic elastic ip fu…

    Jerry Jackson authored
    …nctionality
Commits on Nov 28, 2012
  1. Merge branch 'master' of https://github.com/infochimps-labs/ironfan i…

    Jerry Jackson authored
    …nto feature/196_elastic_ips
Commits on Nov 29, 2012
  1. We fixed the rather odd, broken adaptee problem; now working on actua…

    Jerry Jackson authored
    …lly associating addresses.
Commits on Dec 4, 2012
  1. Merge branch 'master' of https://github.com/infochimps-labs/ironfan i…

    Jerry Jackson authored
    …nto feature/196_elastic_ips
Commits on Dec 6, 2012
  1. pushing changes that put us back in a state which completes the run w…

    Jerry Jackson authored
    …ithout errors; still isn't attaching the elastic ip but is going through the motions.
Commits on Dec 8, 2012
  1. push yesterday's changes to personal repo so that work can be done on…

    Jerry Jackson authored
    … remaining issues.
Commits on Dec 10, 2012
  1. Elastic IPs now properly attach at save/sync and are used when availa…

    Jerry Jackson authored
    …ble by 'knife cluster ssh' as requested.
  2. Elastic IPs now properly attach at save/sync and are used when availa…

    Jerry Jackson authored
    …ble by 'knife cluster ssh' as requested. Removed a last remaining 'raise hell' using during testing from machine.rb
  3. @schade

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

    schade authored
    Feature/196 elastic ips
  4. Continuing removal of miscellaneous bits used for testing during bug …

    Jerry Jackson authored
    …wrangling sessions.
This page is out of date. Refresh to see the latest.
View
5 config/knife.bash
@@ -129,6 +129,11 @@ _knife() {
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
+ *knife_cluster_launch|*knife_cluster_show|*knife_cluster_edit)
+ _chef_completion_cache -c ${words[0]}_cluster "${words[0]} cluster list|awk '{ print $1 }'"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
*knife_environment_show|*knife_environment_edit|*knife_environment_delete)
_chef_completion_cache -c ${words[0]}_environments "${words[0]} environment list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
View
5 lib/chef/knife/cluster_launch.rb
@@ -87,7 +87,6 @@ def run
section("Launching computers", :green)
display(target)
launched = target.launch
-
# As each server finishes, configure it
Ironfan.parallel(launched) do |computer|
if (computer.is_a?(Exception)) then ui.warn "Error launching #{computer.inspect}; skipping after-launch tasks."; next; end
@@ -107,7 +106,7 @@ def perform_after_launch_tasks(computer)
Ironfan.step(computer.name, 'waiting for ready', :white)
# Wait for machine creation on amazon side
computer.machine.wait_for{ ready? }
-
+
# Try SSH
unless config[:dry_run]
Ironfan.step(computer.name, 'trying ssh', :white)
@@ -116,7 +115,7 @@ def perform_after_launch_tasks(computer)
Ironfan.step(computer.name, 'final provisioning', :white)
computer.save
-
+
# Run Bootstrap
if config[:bootstrap]
Chef::Log.warn "UNTESTED --bootstrap"
View
2  lib/chef/knife/ironfan_knife_common.rb
@@ -1,4 +1,4 @@
-require 'chef/knife'
+ require 'chef/knife'
module Ironfan
module KnifeCommon
View
5 lib/ironfan/dsl/ec2.rb
@@ -14,6 +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 :domain, String, :default => 'standard'
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
@@ -25,7 +26,7 @@ class Ec2 < Cloud
magic :permanent, :boolean, :default => false
magic :placement_group, String
magic :provider, Whatever, :default => Ironfan::Provider::Ec2
- magic :public_ip, String
+ magic :elastic_ip, String
magic :region, String, :default => ->{ default_region }
collection :security_groups, Ironfan::Dsl::Ec2::SecurityGroup, :key_method => :name
magic :ssh_user, String, :default => ->{ image_info[:ssh_user] }
@@ -61,7 +62,7 @@ def to_display(style,values={})
values["AZ"] = default_availability_zone
return values if style == :default
- values["Elastic IP"] = public_ip if public_ip
+ values["Public IP"] = elastic_ip if elastic_ip
values
end
View
2  lib/ironfan/provider/ec2.rb
@@ -5,7 +5,7 @@ class Ec2 < Ironfan::IaasProvider
self.handle = :ec2
def self.resources
- [ Machine, EbsVolume, Keypair, SecurityGroup, IamServerCertificate, ElasticLoadBalancer ]
+ [ Machine, ElasticIp, EbsVolume, Keypair, SecurityGroup, IamServerCertificate, ElasticLoadBalancer ]
end
#
View
73 lib/ironfan/provider/ec2/elastic_ip.rb
@@ -3,6 +3,79 @@ class Provider
class Ec2
class ElasticIp < Ironfan::Provider::Resource
+ 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=, :public_ip_address, :save, :server=, :server, :server_id,
+ :server_id=,
+ :to => :adaptee
+
+ 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.elastic_ip ]
+ end
+
+ def name() adaptee.public_ip ; 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
+
+ #
+ # Discovery
+ #
+
+ def self.load!(cluster=nil, machine)
+ Ec2.connection.addresses.each do |eip|
+ register eip
+ Chef::Log.debug("Loaded #{eip}")
+ # The rest of this definition shows relevant information when -VV is passed to knife and aids in troubleshooting any refusal to attach Elastic IPs
+ machine.facets.each do |f|
+ unless f.servers[0].clouds[:ec2].elastic_ip.nil? or eip.domain == "vpc"
+ if eip.domain == "standard" and eip.public_ip == f.servers[0].clouds[:ec2].elastic_ip
+ Chef::Log.debug( "AWS domain: #{eip.domain}" )
+ Chef::Log.debug( "available ip match: #{eip.public_ip}" )
+ Chef::Log.debug( "----------------------" )
+ end
+ end
+ unless eip.public_ip.nil?
+ if eip.domain == "standard"
+ if eip.public_ip == f.servers[0].clouds[:ec2].elastic_ip
+ unless f.servers[0].clouds[:ec2].elastic_ip.nil?
+ Chef::Log.debug( "ip given by cluster definition: #{f.servers[0].clouds[:ec2].elastic_ip}" )
+ else
+ Chef::Log.debug( "No matching Elastic IP available to your account." )
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ #
+ # Manipulation
+ #
+
+ def self.save!(computer)
+ return unless computer.machine?
+ elastic_ip = computer.server.cloud(:ec2).elastic_ip
+ return unless computer.created?
+ Ironfan.step(computer.name, "associating Elastic IP #{elastic_ip}", :blue)
+ Ironfan.unless_dry_run do
+ Ironfan.safely do
+ Ec2.connection.associate_address( computer.machine.id, elastic_ip )
+ end
+ end
+ end
+
end
end
end
View
9 lib/ironfan/provider/ec2/machine.rb
@@ -71,8 +71,8 @@ def stop
def to_display(style,values={})
# style == :minimal
values["State"] = state.to_sym
- values["MachineID"] = id
- values["Public IP"] = public_ip_address
+ values["MachineID"] = id
+ values["Public IP"] = public_ip_address
values["Private IP"] = private_ip_address
values["Created On"] = created_at.to_date
return values if style == :minimal
@@ -163,7 +163,7 @@ def self.create!(computer)
fog_server.wait_for { ready? }
end
-
+
# tag the computer correctly
tags = {
'cluster' => computer.server.cluster_name,
@@ -224,7 +224,6 @@ def self.launch_description(computer)
:client_key => computer.private_key
}
-
# Fog does not actually create tags when it creates a server;
# they and permanence are applied during sync
description = {
@@ -236,7 +235,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'
Something went wrong with that request. Please try again.