From 46aa39154ce0cd2fa2239b5181cd066c55255a1a Mon Sep 17 00:00:00 2001 From: "Philip (flip) Kromer" Date: Fri, 27 Apr 2012 18:45:42 -0700 Subject: [PATCH] Support for cluster compute nodes, and injection of an HVM-virtualization AMI that mostly works. Have initial work to allow placement group specification, but unfortunately Fog is not passign things through correctly, will have to dive in and figure that out. sigh. --- lib/chef/knife/cluster_kick.rb | 15 +- lib/ironfan/chef_layer.rb | 3 +- lib/ironfan/cloud.rb | 244 ++++++++++++++++++--------------- lib/ironfan/discovery.rb | 13 ++ lib/ironfan/fog_layer.rb | 32 ++++- 5 files changed, 189 insertions(+), 118 deletions(-) diff --git a/lib/chef/knife/cluster_kick.rb b/lib/chef/knife/cluster_kick.rb index 3b8ed16b..20b28206 100644 --- a/lib/chef/knife/cluster_kick.rb +++ b/lib/chef/knife/cluster_kick.rb @@ -42,6 +42,14 @@ class ClusterKick < Chef::Knife::ClusterSsh :description => "Where to find the pid file. Typically /var/run/chef/client.pid (init.d) or /etc/sv/chef-client/supervise/pid (runit)", :default => "/etc/sv/chef-client/supervise/pid" + def run + @name_args = [ @name_args.join('-') ] + config[:display_target] = true + script = Erubis::Eruby.new(KICKSTART_SCRIPT).result(:config => config) + @name_args[1] = script + super + end + unless defined?(KICKSTART_SCRIPT) KICKSTART_SCRIPT = < config) - @name_args[1] = script - super - end - end end end diff --git a/lib/ironfan/chef_layer.rb b/lib/ironfan/chef_layer.rb index 5f8ad5ca..9ee09763 100644 --- a/lib/ironfan/chef_layer.rb +++ b/lib/ironfan/chef_layer.rb @@ -30,8 +30,9 @@ module DryRunnable # Run given block unless in dry_run mode (Ironfan.chef_config[:dry_run] # is true) def unless_dry_run - if Ironfan.chef_config[:dry_run] + if Ironfan.dry_run? ui.info(" ... but not really (#{ui.color("dry run", :bold, :yellow)} for server #{name})") + return nil else yield end diff --git a/lib/ironfan/cloud.rb b/lib/ironfan/cloud.rb index 01c49d71..aaa29e23 100644 --- a/lib/ironfan/cloud.rb +++ b/lib/ironfan/cloud.rb @@ -123,7 +123,8 @@ class Ec2 < Base :region, :availability_zones, :backing, :spot_price, :spot_price_fraction, :user_data, :security_groups, - :monitoring + :monitoring, + :placement_group ) def initialize(*args) @@ -192,6 +193,11 @@ def region(val=nil) end end + def placement_group(val=nil) + set(:placement_group, val) + @settings[:placement_group] || owner.cluster_name + end + def default_availability_zone availability_zones.first if availability_zones end @@ -206,14 +212,27 @@ def mount_ephemerals(attrs={}) # Utility methods + require 'pry' + def image_info - Chef::Config[:ec2_image_info][ [region, bits, backing, image_name] ] or ( ui.warn "Make sure to define the machine's region, bits, backing and image_name. (Have #{[region, bits, backing, image_name].inspect})" ; {} ) + ec2_image_info[ [region, bits, backing, image_name] ] or ( ui.warn "Make sure to define the machine's region, bits, backing and image_name. (Have #{[region, bits, backing, image_name, virtualization].inspect})" ; {} ) + end + + def ec2_image_info + return @image_info_mapping if @image_info_mapping + @image_info_mapping = Chef::Config[:ec2_image_info] + # @image_info_mapping.each{|key, val| key[4] ||= 'pv' } + @image_info_mapping + end + + def virtualization + flavor_info[:virtualization] || 'pv' end def list_images ui.info("Available images:") - Chef::Config[:ec2_image_info].each do |flavor_name, flavor| - ui.info(" #{flavor_name}\t#{flavor.inspect}") + ec2_image_info.each do |flavor_name, flavor| + ui.info(" %-55s\t%s" % [flavor_name, flavor.inspect]) end end @@ -236,31 +255,35 @@ def list_flavors end end - # code $/hr $/mo $/day CPU/$ Mem/$ mem cpu cores cpcore storage bits IO type name - # t1.micro $0.02 14 0.48 10.00 33.50 0.67 0.2 1 0.2 0 64 Low Micro Micro - # m1.small $0.085 61 2.04 11.76 20.00 1.7 1 1 1 160 32 Moderate Standard Small - # c1.medium $0.17 123 4.08 29.41 10.00 1.7 5 2 2.5 350 32 Moderate High-CPU Medium - # m1.large $0.34 246 8.16 11.76 22.06 7.5 4 2 2 850 64 High Standard Large - # m2.xlarge $0.50 363 12.00 13.00 35.40 17.7 6.5 2 3.25 420 64 Moderate High-Memory Extra Large - # c1.xlarge $0.68 493 16.32 29.41 10.29 7 20 8 2.5 1690 64 High High-CPU Extra Large - # m1.xlarge $0.68 493 16.32 11.76 22.06 15 8 4 2 1690 64 High Standard Extra Large - # m2.2xlarge $1.00 726 24.00 13.00 34.20 34.2 13 4 3.25 850 64 High High-Memory Double Extra Large - # m2.4xlarge $2.00 1452 48.00 13.00 34.20 68.4 26 8 3.25 1690 64 High High-Memory Quadruple Extra Large - # cc1.4xlarge $1.60 1161 38.40 20.94 14.38 23 33.5 2 16.75 1690 64 Very High 10GB Compute Quadruple Extra Large - # cg1.4xlarge $2.10 1524 50.40 15.95 10.48 22 33.5 2 16.75 1690 64 Very High 10GB Cluster GPU Quadruple Extra Large + # code $/mo $/day $/hr CPU/$ Mem/$ mem cpu cores cpcore storage bits IO type name + # t1.micro 15 0.48 .02 13 13 0.61 0.25 0.25 1 0 32 Low Micro Micro + # m1.small 58 1.92 .08 13 21 1.7 1 1 1 160 32 Moderate Standard Small + # m1.medium 116 3.84 .165 13 13 3.75 2 2 1 410 32 Moderate Standard Medium + # c1.medium 120 3.96 .17 30 10 1.7 5 2 2.5 350 32 Moderate High-CPU Medium + # m1.large 232 7.68 .32 13 23 7.5 4 2 2 850 64 High Standard Large + # m2.xlarge 327 10.80 .45 14 38 17.1 6.5 2 3.25 420 64 Moderate High-Memory Extra Large + # m1.xlarge 465 15.36 .64 13 23 15 8 4 2 1690 64 High Standard Extra Large + # c1.xlarge 479 15.84 .66 30 11 7 20 8 2.5 1690 64 High High-CPU Extra Large + # m2.2xlarge 653 21.60 .90 14 38 34.2 13 4 3.25 850 64 High High-Memory Double Extra Large + # m2.4xlarge 1307 43.20 1.80 14 38 68.4 26 8 3.25 1690 64 High High-Memory Quadruple Extra Large + # cc1.4xlarge 944 31.20 1.30 26 18 23 33.5 8 4.19 1690 64 10GB Compute Quadruple Extra Large + # cc2.8xlarge 1742 57.60 2.40 37 25 60.5 88 16 5.50 3370 64 Very High 10GB Compute Eight Extra Large + # cg1.4xlarge 1525 50.40 2.10 16 10 22 33.5 8 4.19 1690 64 Very High 10GB Cluster GPU Quadruple Extra Large FLAVOR_INFO = { 't1.micro' => { :price => 0.02, :bits => '64-bit', :ram => 686, :cores => 1, :core_size => 0.25, :inst_disks => 0, :inst_disk_size => 0, :ephemeral_volumes => 0 }, - 'm1.small' => { :price => 0.085, :bits => '64-bit', :ram => 1740, :cores => 1, :core_size => 1, :inst_disks => 1, :inst_disk_size => 160, :ephemeral_volumes => 1 }, + 'm1.small' => { :price => 0.08, :bits => '64-bit', :ram => 1740, :cores => 1, :core_size => 1, :inst_disks => 1, :inst_disk_size => 160, :ephemeral_volumes => 1 }, + 'm1.medium' => { :price => 0.165, :bits => '32-bit', :ram => 3840, :cores => 2, :core_size => 1, :inst_disks => 1, :inst_disk_size => 410, :ephemeral_volumes => 1 }, 'c1.medium' => { :price => 0.17, :bits => '32-bit', :ram => 1740, :cores => 2, :core_size => 2.5, :inst_disks => 1, :inst_disk_size => 350, :ephemeral_volumes => 1 }, - 'm1.large' => { :price => 0.34, :bits => '64-bit', :ram => 7680, :cores => 2, :core_size => 2, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 }, - 'm2.xlarge' => { :price => 0.50, :bits => '64-bit', :ram => 18124, :cores => 2, :core_size => 3.25, :inst_disks => 1, :inst_disk_size => 420, :ephemeral_volumes => 1 }, - 'c1.xlarge' => { :price => 0.68, :bits => '64-bit', :ram => 7168, :cores => 8, :core_size => 2.5, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, - 'm1.xlarge' => { :price => 0.68, :bits => '64-bit', :ram => 15360, :cores => 4, :core_size => 2, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, - 'm2.2xlarge' => { :price => 1.00, :bits => '64-bit', :ram => 35020, :cores => 4, :core_size => 3.25, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 }, - 'm2.4xlarge' => { :price => 2.00, :bits => '64-bit', :ram => 70041, :cores => 8, :core_size => 3.25, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, - 'cc1.4xlarge' => { :price => 1.60, :bits => '64-bit', :ram => 23552, :cores => 2, :core_size =>16.75, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2 }, - 'cg1.4xlarge' => { :price => 2.10, :bits => '64-bit', :ram => 22528, :cores => 2, :core_size =>16.75, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2 }, + 'm1.large' => { :price => 0.32, :bits => '64-bit', :ram => 7680, :cores => 2, :core_size => 2, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 }, + 'm2.xlarge' => { :price => 0.45, :bits => '64-bit', :ram => 18124, :cores => 2, :core_size => 3.25, :inst_disks => 1, :inst_disk_size => 420, :ephemeral_volumes => 1 }, + 'c1.xlarge' => { :price => 0.64, :bits => '64-bit', :ram => 7168, :cores => 8, :core_size => 2.5, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, + 'm1.xlarge' => { :price => 0.66, :bits => '64-bit', :ram => 15360, :cores => 4, :core_size => 2, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, + 'm2.2xlarge' => { :price => 0.90, :bits => '64-bit', :ram => 35020, :cores => 4, :core_size => 3.25, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 }, + 'm2.4xlarge' => { :price => 1.80, :bits => '64-bit', :ram => 70041, :cores => 8, :core_size => 3.25, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 }, + 'cc1.4xlarge' => { :price => 1.30, :bits => '64-bit', :ram => 23552, :cores => 8, :core_size => 4.19, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' }, + 'cc1.8xlarge' => { :price => 2.40, :bits => '64-bit', :ram => 61952, :cores =>16, :core_size => 5.50, :inst_disks => 8, :inst_disk_size => 3370, :ephemeral_volumes => 4, :placement_groupable => true, :virtualization => 'hvm' }, + 'cg1.4xlarge' => { :price => 2.10, :bits => '64-bit', :ram => 22528, :cores => 8, :core_size => 4.19, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' }, } # @@ -279,118 +302,125 @@ def list_flavors # # Lucid (Ubuntu 9.10) # - %w[us-east-1 64-bit instance karmic ] => { :image_id => 'ami-55739e3c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-east-1 32-bit instance karmic ] => { :image_id => 'ami-bb709dd2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-west-1 64-bit instance karmic ] => { :image_id => 'ami-cb2e7f8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-west-1 32-bit instance karmic ] => { :image_id => 'ami-c32e7f86', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 64-bit instance karmic ] => { :image_id => 'ami-05c2e971', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 32-bit instance karmic ] => { :image_id => 'ami-2fc2e95b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 64-bit instance karmic ] => { :image_id => 'ami-55739e3c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 32-bit instance karmic ] => { :image_id => 'ami-bb709dd2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 64-bit instance karmic ] => { :image_id => 'ami-cb2e7f8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 32-bit instance karmic ] => { :image_id => 'ami-c32e7f86', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 64-bit instance karmic ] => { :image_id => 'ami-05c2e971', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 32-bit instance karmic ] => { :image_id => 'ami-2fc2e95b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # # Lucid (Ubuntu 10.04.3) # - %w[ap-southeast-1 64-bit ebs lucid ] => { :image_id => 'ami-77f28d25', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ap-southeast-1 32-bit ebs lucid ] => { :image_id => 'ami-4df28d1f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ap-southeast-1 64-bit instance lucid ] => { :image_id => 'ami-57f28d05', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ap-southeast-1 32-bit instance lucid ] => { :image_id => 'ami-a5f38cf7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 64-bit ebs lucid ] => { :image_id => 'ami-ab4d67df', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 32-bit ebs lucid ] => { :image_id => 'ami-a94d67dd', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 64-bit instance lucid ] => { :image_id => 'ami-a54d67d1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[eu-west-1 32-bit instance lucid ] => { :image_id => 'ami-cf4d67bb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ap-southeast-1 64-bit ebs lucid ] => { :image_id => 'ami-77f28d25', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ap-southeast-1 32-bit ebs lucid ] => { :image_id => 'ami-4df28d1f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ap-southeast-1 64-bit instance lucid ] => { :image_id => 'ami-57f28d05', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ap-southeast-1 32-bit instance lucid ] => { :image_id => 'ami-a5f38cf7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 64-bit ebs lucid ] => { :image_id => 'ami-ab4d67df', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 32-bit ebs lucid ] => { :image_id => 'ami-a94d67dd', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 64-bit instance lucid ] => { :image_id => 'ami-a54d67d1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[eu-west-1 32-bit instance lucid ] => { :image_id => 'ami-cf4d67bb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[us-east-1 64-bit ebs lucid ] => { :image_id => 'ami-4b4ba522', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-east-1 32-bit ebs lucid ] => { :image_id => 'ami-714ba518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-east-1 64-bit instance lucid ] => { :image_id => 'ami-fd4aa494', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-east-1 32-bit instance lucid ] => { :image_id => 'ami-2d4aa444', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 64-bit ebs lucid ] => { :image_id => 'ami-4b4ba522', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 32-bit ebs lucid ] => { :image_id => 'ami-714ba518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 64-bit instance lucid ] => { :image_id => 'ami-fd4aa494', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-east-1 32-bit instance lucid ] => { :image_id => 'ami-2d4aa444', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[us-west-1 64-bit ebs lucid ] => { :image_id => 'ami-d197c694', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-west-1 32-bit ebs lucid ] => { :image_id => 'ami-cb97c68e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-west-1 64-bit instance lucid ] => { :image_id => 'ami-c997c68c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[us-west-1 32-bit instance lucid ] => { :image_id => 'ami-c597c680', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 64-bit ebs lucid ] => { :image_id => 'ami-d197c694', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 32-bit ebs lucid ] => { :image_id => 'ami-cb97c68e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 64-bit instance lucid ] => { :image_id => 'ami-c997c68c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[us-west-1 32-bit instance lucid ] => { :image_id => 'ami-c597c680', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # # Maverick (Ubuntu 10.10) # - %w[ ap-southeast-1 64-bit ebs maverick ] => { :image_id => 'ami-32423c60', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 64-bit instance maverick ] => { :image_id => 'ami-12423c40', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 32-bit ebs maverick ] => { :image_id => 'ami-0c423c5e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 32-bit instance maverick ] => { :image_id => 'ami-7c423c2e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit ebs maverick ] => { :image_id => 'ami-32423c60', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit instance maverick ] => { :image_id => 'ami-12423c40', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 32-bit ebs maverick ] => { :image_id => 'ami-0c423c5e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 32-bit instance maverick ] => { :image_id => 'ami-7c423c2e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ eu-west-1 64-bit ebs maverick ] => { :image_id => 'ami-e59ca991', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 64-bit instance maverick ] => { :image_id => 'ami-1b9ca96f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 32-bit ebs maverick ] => { :image_id => 'ami-fb9ca98f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 32-bit instance maverick ] => { :image_id => 'ami-339ca947', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit ebs maverick ] => { :image_id => 'ami-e59ca991', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit instance maverick ] => { :image_id => 'ami-1b9ca96f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit ebs maverick ] => { :image_id => 'ami-fb9ca98f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit instance maverick ] => { :image_id => 'ami-339ca947', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ us-east-1 64-bit ebs maverick ] => { :image_id => 'ami-cef405a7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 64-bit instance maverick ] => { :image_id => 'ami-08f40561', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 32-bit ebs maverick ] => { :image_id => 'ami-ccf405a5', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 32-bit instance maverick ] => { :image_id => 'ami-a6f504cf', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit ebs maverick ] => { :image_id => 'ami-cef405a7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit instance maverick ] => { :image_id => 'ami-08f40561', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 32-bit ebs maverick ] => { :image_id => 'ami-ccf405a5', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 32-bit instance maverick ] => { :image_id => 'ami-a6f504cf', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ us-west-1 64-bit ebs maverick ] => { :image_id => 'ami-af7e2eea', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 64-bit instance maverick ] => { :image_id => 'ami-a17e2ee4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 32-bit ebs maverick ] => { :image_id => 'ami-ad7e2ee8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 32-bit instance maverick ] => { :image_id => 'ami-957e2ed0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit ebs maverick ] => { :image_id => 'ami-af7e2eea', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit instance maverick ] => { :image_id => 'ami-a17e2ee4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 32-bit ebs maverick ] => { :image_id => 'ami-ad7e2ee8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 32-bit instance maverick ] => { :image_id => 'ami-957e2ed0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # # Natty (Ubuntu 11.04) # - %w[ ap-northeast-1 32-bit ebs natty ] => { :image_id => 'ami-00b10501', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 32-bit instance natty ] => { :image_id => 'ami-f0b004f1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 64-bit ebs natty ] => { :image_id => 'ami-02b10503', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 64-bit instance natty ] => { :image_id => 'ami-fab004fb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 32-bit ebs natty ] => { :image_id => 'ami-00b10501', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 32-bit instance natty ] => { :image_id => 'ami-f0b004f1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 64-bit ebs natty ] => { :image_id => 'ami-02b10503', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 64-bit instance natty ] => { :image_id => 'ami-fab004fb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # + %w[ ap-southeast-1 32-bit ebs natty ] => { :image_id => 'ami-06255f54', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 32-bit instance natty ] => { :image_id => 'ami-72255f20', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit ebs natty ] => { :image_id => 'ami-04255f56', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit instance natty ] => { :image_id => 'ami-7a255f28', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ ap-southeast-1 32-bit ebs natty ] => { :image_id => 'ami-06255f54', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 32-bit instance natty ] => { :image_id => 'ami-72255f20', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 64-bit ebs natty ] => { :image_id => 'ami-04255f56', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 64-bit instance natty ] => { :image_id => 'ami-7a255f28', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit ebs natty ] => { :image_id => 'ami-a4f7c5d0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit instance natty ] => { :image_id => 'ami-fef7c58a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit ebs natty ] => { :image_id => 'ami-a6f7c5d2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit instance natty ] => { :image_id => 'ami-c0f7c5b4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # + %w[ us-east-1 32-bit ebs natty ] => { :image_id => 'ami-e358958a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 32-bit instance natty ] => { :image_id => 'ami-c15994a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit ebs natty ] => { :image_id => 'ami-fd589594', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit instance natty ] => { :image_id => 'ami-71589518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # + %w[ us-west-1 32-bit ebs natty ] => { :image_id => 'ami-43580406', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 32-bit instance natty ] => { :image_id => 'ami-e95f03ac', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit ebs natty ] => { :image_id => 'ami-4d580408', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit instance natty ] => { :image_id => 'ami-a15f03e4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # - %w[ eu-west-1 32-bit ebs natty ] => { :image_id => 'ami-a4f7c5d0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 32-bit instance natty ] => { :image_id => 'ami-fef7c58a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 64-bit ebs natty ] => { :image_id => 'ami-a6f7c5d2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 64-bit instance natty ] => { :image_id => 'ami-c0f7c5b4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # Cluster Compute # - %w[ us-east-1 32-bit ebs natty ] => { :image_id => 'ami-e358958a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 32-bit instance natty ] => { :image_id => 'ami-c15994a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 64-bit ebs natty ] => { :image_id => 'ami-fd589594', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 64-bit instance natty ] => { :image_id => 'ami-71589518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + # IMAGE ami-6d2ce204 205199409180/Globus Provision 0.4.AMI (Ubuntu 11.04 HVM) 205199409180 available public x86_64 machine ebs hvm xen # - %w[ us-west-1 32-bit ebs natty ] => { :image_id => 'ami-43580406', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 32-bit instance natty ] => { :image_id => 'ami-e95f03ac', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 64-bit ebs natty ] => { :image_id => 'ami-4d580408', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 64-bit instance natty ] => { :image_id => 'ami-a15f03e4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit ebs natty-cc ] => { :image_id => 'ami-6d2ce204', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # # Oneiric (Ubuntu 11.10) # - %w[ ap-northeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-84902785', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 32-bit instance oneiric ] => { :image_id => 'ami-5e90275f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-88902789', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-northeast-1 64-bit instance oneiric ] => { :image_id => 'ami-7c90277d', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-84902785', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 32-bit instance oneiric ] => { :image_id => 'ami-5e90275f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-88902789', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-northeast-1 64-bit instance oneiric ] => { :image_id => 'ami-7c90277d', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ ap-southeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-0a327758', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 32-bit instance oneiric ] => { :image_id => 'ami-00327752', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-0832775a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ ap-southeast-1 64-bit instance oneiric ] => { :image_id => 'ami-04327756', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-0a327758', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 32-bit instance oneiric ] => { :image_id => 'ami-00327752', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-0832775a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ ap-southeast-1 64-bit instance oneiric ] => { :image_id => 'ami-04327756', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ eu-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-11f0cc65', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 32-bit instance oneiric ] => { :image_id => 'ami-4ff0cc3b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-1df0cc69', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ eu-west-1 64-bit instance oneiric ] => { :image_id => 'ami-23f0cc57', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-11f0cc65', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 32-bit instance oneiric ] => { :image_id => 'ami-4ff0cc3b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-1df0cc69', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ eu-west-1 64-bit instance oneiric ] => { :image_id => 'ami-23f0cc57', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ us-east-1 32-bit ebs oneiric ] => { :image_id => 'ami-a562a9cc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 32-bit instance oneiric ] => { :image_id => 'ami-3962a950', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 64-bit ebs oneiric ] => { :image_id => 'ami-bf62a9d6', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-east-1 64-bit instance oneiric ] => { :image_id => 'ami-c162a9a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 32-bit ebs oneiric ] => { :image_id => 'ami-a562a9cc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 32-bit instance oneiric ] => { :image_id => 'ami-3962a950', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit ebs oneiric ] => { :image_id => 'ami-bf62a9d6', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-east-1 64-bit instance oneiric ] => { :image_id => 'ami-c162a9a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ us-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-c9a1fe8c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 32-bit instance oneiric ] => { :image_id => 'ami-21a1fe64', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-cba1fe8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-1 64-bit instance oneiric ] => { :image_id => 'ami-3fa1fe7a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-c9a1fe8c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 32-bit instance oneiric ] => { :image_id => 'ami-21a1fe64', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-cba1fe8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-1 64-bit instance oneiric ] => { :image_id => 'ami-3fa1fe7a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, # - %w[ us-west-2 32-bit ebs oneiric ] => { :image_id => 'ami-ea9a17da', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-2 32-bit instance oneiric ] => { :image_id => 'ami-f49a17c4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-2 64-bit ebs oneiric ] => { :image_id => 'ami-ec9a17dc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, - %w[ us-west-2 64-bit instance oneiric ] => { :image_id => 'ami-fe9a17ce', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-2 32-bit ebs oneiric ] => { :image_id => 'ami-ea9a17da', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-2 32-bit instance oneiric ] => { :image_id => 'ami-f49a17c4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-2 64-bit ebs oneiric ] => { :image_id => 'ami-ec9a17dc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, + %w[ us-west-2 64-bit instance oneiric ] => { :image_id => 'ami-fe9a17ce', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", }, }) end diff --git a/lib/ironfan/discovery.rb b/lib/ironfan/discovery.rb index 4dd2a2e6..1ae89797 100644 --- a/lib/ironfan/discovery.rb +++ b/lib/ironfan/discovery.rb @@ -170,6 +170,19 @@ def self.fog_keypairs @fog_keypairs = {}.tap{|hsh| Ironfan.fog_connection.key_pairs.each{|kp| hsh[kp.name] = kp } } end + def self.dry_run? + Ironfan.chef_config[:dry_run] + end + + def self.placement_groups + return @placement_groups if @placement_groups + Chef::Log.debug("Using fog to catalog all placement_groups") + resp = self.fog_connection.describe_placement_groups unless dry_run? + return {} unless resp.respond_to?(:body) && resp.body.present? + arr = resp.body['placementGroupSet'] + @placement_groups = arr.inject({}){|acc, pg| acc[pg['groupName']] = pg ; acc } + end + def safely *args, &block Ironfan.safely(*args, &block) end diff --git a/lib/ironfan/fog_layer.rb b/lib/ironfan/fog_layer.rb index e6267b8f..c0089790 100644 --- a/lib/ironfan/fog_layer.rb +++ b/lib/ironfan/fog_layer.rb @@ -24,7 +24,7 @@ def fog_launch_description if client_key.body then cloud.user_data.merge({ :client_key => client_key.body }) else cloud.user_data.merge({ :validation_key => cloud.validation_key }) ; end # - { + description = { :image_id => cloud.image_id, :flavor_id => cloud.flavor, :groups => cloud.security_groups.keys, @@ -40,12 +40,18 @@ def fog_launch_description :monitoring => cloud.monitoring, # permanence is applied during sync } + if needs_placement_group? + ui.warn "1.3.1 and earlier versions of Fog don't correctly support placement groups, so your nodes will land willy-nilly. We're working on a fix" + description[:placement] = { 'groupName' => cloud.placement_group.to_s } + end + description end # # Takes key-value pairs and idempotently sets those tags on the cloud machine # def fog_create_tags(fog_obj, desc, tags) + tags['Name'] ||= tags['name'] if tags.has_key?('name') tags_to_create = tags.reject{|key, val| fog_obj.tags[key] == val.to_s } return if tags_to_create.empty? step(" tagging #{desc} with #{tags_to_create.inspect}", :green) @@ -106,6 +112,23 @@ def attach_volumes end end + def ensure_placement_group + return unless needs_placement_group? + pg_name = cloud.placement_group.to_s + desc = "placement group #{pg_name} for #{self.fullname} (vs #{Ironfan.placement_groups.inspect}" + return if Ironfan.placement_groups.include?(pg_name) + safely do + step(" creating #{desc}", :blue) + unless_dry_run{ Ironfan.fog_connection.create_placement_group(pg_name, 'cluster') } + Ironfan.placement_groups[pg_name] = { 'groupName' => pg_name, 'strategy' => 'cluster' } + end + pg_name + end + + def needs_placement_group? + cloud.flavor_info[:placement_groupable] + end + def associate_public_ip address = self.cloud.public_ip return unless self.in_cloud? && address @@ -136,8 +159,11 @@ def set_instance_attributes # have to set it every time. safely do step(" setting #{desc}", :blue) - Ironfan.fog_connection.modify_instance_attribute(self.fog_server.id, { - 'DisableApiTermination.Value' => permanent?, }) + unless_dry_run do + Ironfan.fog_connection.modify_instance_attribute(self.fog_server.id, { + 'DisableApiTermination.Value' => permanent?, }) + end + true end end