Class: Chef::Knife::ClusterKill

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

Instance Method Summary collapse

Methods inherited from ClusterChef::Script

#run

Methods included from ClusterChef::KnifeCommon

#bootstrapper, #configure_dry_run, #confirm_or_exit, #die, #get_relevant_slice, #get_slice, included, #load_cluster_chef, load_deps, #predicate_str, #progressbar_for_threads, #run_bootstrap, #section, #sub_command

Instance Method Details

#confirm_execution(target) ⇒ Object



64
65
66
67
68
69
# File 'lib/chef/knife/cluster_kill.rb', line 64

def confirm_execution(target)
  delete_message = [
    (((!config[:chef])   || target.chef_nodes.empty?)  ? nil : "#{target.chef_nodes.length} chef nodes"),
    (((!config[:cloud])  || target.fog_servers.empty?) ? nil : "#{target.fog_servers.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



59
60
61
62
# File 'lib/chef/knife/cluster_kill.rb', line 59

def display(target, *args, &block)
  super
  ui.info Formatador.display_line("[red]Bogus servers detected[reset]: [blue]#{target.bogus_servers.map(&:fullname).inspect}[reset]") unless target.bogus_servers.empty?
end

#perform_execution(target) ⇒ Object

Execute every last mf’ing one of em



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

def perform_execution(target)
  if config[:cloud]
    section("Killing Cloud Machines")
    target.select(&:in_cloud?).destroy
  end

  if config[:chef]
    section("Killing Chef")
    target.select(&:in_chef? ).delete_chef
  end
end

#relevant?(server) ⇒ Boolean

Returns:

  • (Boolean)


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

def relevant?(server)
  server.killable?
end