Class: Chef::Knife::ClusterKill

Inherits:
Ironfan::Script show all
Defined in:
lib/chef/knife/cluster_kill.rb

Instance Attribute Summary

Attributes included from Ironfan::KnifeCommon

#broker, #problems

Instance Method Summary collapse

Methods inherited from Ironfan::Script

#_run, #aggregates_on_noop?, #prepares_on_noop?

Methods included from Ironfan::KnifeCommon

#all_computers, #bootstrapper, #configure_dry_run, #confirm_or_exit, #die, #discover_computers, #exit_if_unhealthy!, #gemfile, #get_relevant_slice, #get_slice, #has_problem, #healthy?, included, load_deps, #load_ironfan, #pick_apart, #predicate_str, #progressbar_for_threads, #run, #run_bootstrap, #section, #sub_command, #wait_for_ssh

Instance Method Details

#aggregates?Boolean

Returns:

  • (Boolean)

78
# File 'lib/chef/knife/cluster_kill.rb', line 78

def aggregates?() false   end

#confirm_execution(target) ⇒ Object


68
69
70
71
72
73
74
75
# File 'lib/chef/knife/cluster_kill.rb', line 68

def confirm_execution(target)
  nodes           = target.map(&:node).compact
  machines       = target.map(&:machine).compact
  delete_message = [
    (((!config[:chef])   || nodes.empty?)  ? nil : "#{nodes.length} chef nodes"),
    (((!config[:cloud])  || machines.empty?) ? nil : "#{machines.length} fog servers") ].compact.join(" and ")
  confirm_or_exit("Are you absolutely certain that you want to delete #{delete_message}? (Type 'Yes' to confirm) ", 'Yes')
end

#display(target, *args, &block) ⇒ Object


58
59
60
61
62
63
64
65
66
# File 'lib/chef/knife/cluster_kill.rb', line 58

def display(target, *args, &block)
  super

  permanent = target.select(&:permanent?)
  ui.info Formatador.display_line("servers with [red]'permanent=true'[reset] ignored: [blue]#{permanent.map(&:name).inspect}[reset]. (To kill, change 'permanent' to false, run knife cluster sync, and re-try)") unless permanent.empty?

  bogus = target.select(&:bogus?)
  ui.info Formatador.display_line("[red]Bogus servers detected[reset]: [blue]#{bogus.map(&:name).inspect}[reset]") unless bogus.empty?
end

#perform_execution(target) ⇒ Object

Execute every last mf'ing one of em


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chef/knife/cluster_kill.rb', line 46

def perform_execution(target)
  if config[:cloud]
    section("Killing Cloud Computers")
    target.kill :providers => :iaas
  end

  if config[:chef]
    section("Killing Chef")
    target.kill :providers => :chef
  end
end

#prepares?Boolean

Returns:

  • (Boolean)

77
# File 'lib/chef/knife/cluster_kill.rb', line 77

def prepares?()   false   end

#relevant?(server) ⇒ Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/chef/knife/cluster_kill.rb', line 41

def relevant?(server)
  server.killable?
end