class Chef::Knife::KillerSlaughter

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/killer_slaughter.rb, line 17
def run
  if(config[:over_minutes])
    cutoff = Time.now.to_f - (config[:over_minutes].to_i * 60)
    term = "ohai_time:[0.0 TO #{cutoff}]"
  end
  result = Chef::Search::Query.new.search(:node, [name_args.first, term].flatten.compact.join(' AND '))
  if(result.first.empty?)
    warn 'No results found!'
  else
    confirm "Found #{result.first.size} matches. Proceed"
    result.first.each do |node|
      scrub(node.name)
    end
  end
end