diff options
author | Bryan McLellan <btm@opscode.com> | 2012-06-21 10:45:59 -0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-06-21 10:45:59 -0700 |
commit | 2edb3935f031e06a08dda0b7b42a44cf00dec1bc (patch) | |
tree | fbf94851456b334741c49a80b2be647e60819fbe | |
parent | d9c2db242f43359f2e955a88bbd238df01428f5f (diff) | |
parent | 4a72f007abdad5af2474f48b6d5e686a44c7ae62 (diff) | |
download | chef-2edb3935f031e06a08dda0b7b42a44cf00dec1bc.tar.gz |
Merge branch 'CHEF-3130'
-rw-r--r-- | chef/lib/chef/knife/status.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/chef/lib/chef/knife/status.rb b/chef/lib/chef/knife/status.rb index 428adf494d..5b098c9d0c 100644 --- a/chef/lib/chef/knife/status.rb +++ b/chef/lib/chef/knife/status.rb @@ -34,6 +34,16 @@ class Chef :long => "--run-list", :description => "Show the run list" + option :sort_reverse, + :short => "-s", + :long => "--sort-reverse", + :description => "Sort the status list by last run time descending" + + option :hide_healthy, + :short => "-H", + :long => "--hide-healthy", + :description => "Hide nodes that have run chef in the last hour" + def highline @h ||= HighLine.new end @@ -45,7 +55,14 @@ class Chef q.search(:node, query) do |node| all_nodes << node end - all_nodes.sort { |n1, n2| (n1["ohai_time"] or 0) <=> (n2["ohai_time"] or 0) }.each do |node| + + all_nodes.sort { |n1, n2| + if (config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse]) + (n2["ohai_time"] or 0) <=> (n1["ohai_time"] or 0) + else + (n1["ohai_time"] or 0) <=> (n2["ohai_time"] or 0) + end + }.each do |node| if node.has_key?("ec2") fqdn = node['ec2']['public_hostname'] ipaddress = node['ec2']['public_ipv4'] @@ -82,7 +99,7 @@ class Chef line_parts << platform end - highline.say(line_parts.join(', ') + '.') + highline.say(line_parts.join(', ') + '.') unless (config[:hide_healthy] && hours < 1) end end |