54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/chef/knife/status.rb', line 54
def run
ui.use_presenter Knife::Core::StatusPresenter
if config[:long_output]
opts = {}
else
opts = { filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
cloud: ["cloud"], run_list: ["run_list"], platform: ["platform"],
platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }
end
@query ||= ""
append_to_query(@name_args[0]) if @name_args[0]
append_to_query("chef_environment:#{config[:environment]}") if config[:environment]
if config[:hide_by_mins]
hide_by_mins = config[:hide_by_mins].to_i
time = Time.now.to_i
@query << " " unless @query.empty?
@query << "NOT ohai_time:[#{(time - hide_by_mins * 60)} TO #{time}]"
end
@query = @query.empty? ? "*:*" : @query
all_nodes = []
q = Chef::Search::Query.new
Chef::Log.info("Sending query: #{@query}")
q.search(:node, @query, opts) do |node|
all_nodes << node
end
all_nodes.sort_by! { |n| n["ohai_time"] || 0 }
all_nodes.reverse! if config[:sort_reverse] || config[:sort_status_reverse]
output(all_nodes)
end
|