Skip to content

Commit 17ef580

Browse files
author
Christopher Brown
committed
added delete_clients
1 parent 3f48d25 commit 17ef580

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎chef/bin/knife‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ class Knife < Thor
251251
puts "Done."
252252
end
253253

254+
desc "delete_clients", "Delete *all* clients"
255+
def delete_clients
256+
setup
257+
destroy_clients(get_list("clients"))
258+
puts "Done."
259+
end
260+
254261

255262
#############
256263
# Cookbooks #
@@ -551,6 +558,17 @@ class Knife < Thor
551558
end
552559
end
553560

561+
def destroy_clients(clientlist)
562+
clientlist.each do |client|
563+
begin
564+
@rest.delete_rest("clients/#{client}") unless client =~ /-validator$/
565+
rescue Net::HTTPServerException
566+
raise unless ($!.message =~ /Not Found/ or $!.message =~ /Forbidden/)
567+
puts "Client: #{client}, Exception! #{$!.message}"
568+
end
569+
end
570+
end
571+
554572
def save_node(node)
555573
puts "Storing node data for #{expand_node(options[:node])}..."
556574
begin

0 commit comments

Comments
 (0)