Class: Chef::Knife::Status
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::Status
- Defined in:
- lib/chef/knife/status.rb
Instance Attribute Summary
Attributes inherited from Chef::Knife
Instance Method Summary collapse
Methods inherited from Chef::Knife
#api_key, #apply_computed_config, category, chef_config_dir, common_name, #config_file_settings, config_loader, #configure_chef, #create_object, #delete_object, dependency_loaders, deps, #format_rest_error, guess_category, #humanize_exception, #humanize_http_exception, inherited, #initialize, list_commands, load_commands, load_config, load_deps, #merge_configs, msg, #noauth_rest, #parse_options, reset_config_loader!, reset_subcommands!, #rest, run, #run_with_pretty_exceptions, #server_url, #show_usage, snake_case_name, subcommand_category, subcommand_class_from, subcommand_loader, subcommands, subcommands_by_category, ui, unnamed?, use_separate_defaults?, #username
Methods included from Mixin::ConvertToClassName
#constantize, #convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::PathSanity
Constructor Details
This class inherits a constructor from Chef::Knife
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/knife/status.rb', line 47 def run ui.use_presenter Knife::Core::StatusPresenter all_nodes = [] q = Chef::Search::Query.new query = @name_args[0] ? @name_args[0].dup : '*:*' if config[:hide_healthy] time = Time.now.to_i query_unhealthy = "NOT ohai_time:[" << (time - 60*60).to_s << " TO " << time.to_s << "]" query << ' AND ' << query_unhealthy << @name_args[0] if @name_args[0] query = query_unhealthy unless @name_args[0] end q.search(:node, query) do |node| all_nodes << node end output(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 }) end |