Parent

Included Modules

Class/Module Index [+]

Quicksearch

Chef::Knife::ClusterLaunch

Public Instance Methods

perform_after_launch_tasks(computer) click to toggle source
# File lib/chef/knife/cluster_launch.rb, line 110
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)
    nil until tcp_test_ssh(computer.machine.dns_name){ sleep @initial_sleep_delay ||= 10  }
  end

  Ironfan.step(computer.name, 'final provisioning', :white)
  computer.save
  
  # Run Bootstrap
  if config[:bootstrap]
    Chef::Log.warn "UNTESTED --bootstrap"
    run_bootstrap(computer)
  end
end
run() click to toggle source
# File lib/chef/knife/cluster_launch.rb, line 58
def run
  load_ironfan
  die(banner) if @name_args.empty?
  configure_dry_run

  #
  # Load the facet
  #
  full_target = get_slice(*@name_args)
  display(full_target)
  target = full_target.select(&:launchable?)

  warn_or_die_on_bogus_servers(full_target) unless full_target.select(&:bogus?).empty?

  die("", "#{ui.color("All computers are running -- not launching any.",:blue)}", "", 1) if target.empty?

  # If a bootstrap was requested, ensure that we will be able to perform the
  # bootstrap *before* trying to launch all of the servers in target. This
  # will save the user a lot of time if they've made a configuration mistake
  if config[:bootstrap]
    ensure_common_environment(target)
  end

  # Pre-populate information in chef
  section("Syncing to chef")
  target.save :providers => :chef

  unless target.empty?
    ui.info "Preparing shared resources:"
    all_computers(*@name_args).prepare
  end

  # Launch computers
  ui.info("")
  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
    Ironfan.step(computer.name, 'launching', :white)
    perform_after_launch_tasks(computer)
  end

  if healthy?
    ui.info "Applying aggregations:"
    all_computers(*@name_args).aggregate
  end

  display(target)
end
tcp_test_ssh(hostname) click to toggle source
# File lib/chef/knife/cluster_launch.rb, line 131
def tcp_test_ssh(hostname)
  tcp_socket = TCPSocket.new(hostname, 22)
  readable = IO.select([tcp_socket], nil, nil, 5)
  if readable
    Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
    yield
    true
  else
    false
  end
rescue Errno::ETIMEDOUT
  false
rescue Errno::ECONNREFUSED
  sleep 2
  false
rescue Errno::EHOSTUNREACH
  sleep 2
  false
ensure
  tcp_socket && tcp_socket.close
end
warn_or_die_on_bogus_servers(target) click to toggle source
# File lib/chef/knife/cluster_launch.rb, line 153
def warn_or_die_on_bogus_servers(target)
  ui.info("")
  ui.info "Cluster has servers in a transitional or undefined state (shown as 'bogus'):"
  ui.info("")
  display(target)
  ui.info("")
  unless config[:force]
    die(
      "Launch operations may be unpredictable under these circumstances.",
      "You should wait for the cluster to stabilize, fix the undefined server problems",
      "(run \"knife cluster show CLUSTER\" to see what the problems are), or launch",
      "the cluster anyway using the --force option.", "", -2)
  end
  ui.info("")
  ui.info "--force specified"
  ui.info "Proceeding to launch anyway. This may produce undesired results."
  ui.info("")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.