summaryrefslogtreecommitdiff
path: root/lib/chef/knife/core
diff options
context:
space:
mode:
authorThom May <thom@clearairturbulence.org>2015-04-09 19:44:51 +0100
committerThom May <thom@clearairturbulence.org>2015-04-09 19:44:51 +0100
commitad10282d962aa2c09130b29b4ebcf10e4ae321e5 (patch)
tree590e827408f7a3466e4cc7f5cde17f9dcfc907f2 /lib/chef/knife/core
parent648c9f91d4a0ccbcf661a5ee4d3ec67d8538a5f3 (diff)
parent604a1e63722832bed6f0109218652a3f384f90cb (diff)
downloadchef-ad10282d962aa2c09130b29b4ebcf10e4ae321e5.tar.gz
Merge pull request #3067 from chef/tm/knife_status_environment
Allow knife status to filter by environment
Diffstat (limited to 'lib/chef/knife/core')
-rw-r--r--lib/chef/knife/core/status_presenter.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 3298d5e4ac..9cf839d3a6 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -66,16 +66,16 @@ class Chef
list.each do |node|
result = {}
- result["name"] = node.name
- result["chef_environment"] = node.chef_environment
- ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
- fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
+ result["name"] = node["name"] || node.name
+ result["chef_environment"] = node["chef_environment"]
+ ip = (node["ec2"] && node["ec2"]["public_ipv4"]) || node["ipaddress"]
+ fqdn = (node["ec2"] && node["ec2"]["public_hostname"]) || node["fqdn"]
result["ip"] = ip if ip
result["fqdn"] = fqdn if fqdn
- result["run_list"] = node.run_list if config[:run_list]
- result["ohai_time"] = node[:ohai_time]
- result["platform"] = node[:platform] if node[:platform]
- result["platform_version"] = node[:platform_version] if node[:platform_version]
+ result["run_list"] = node.run_list if config["run_list"]
+ result["ohai_time"] = node["ohai_time"]
+ result["platform"] = node["platform"] if node["platform"]
+ result["platform_version"] = node["platform_version"] if node["platform_version"]
if config[:long_output]
result["default"] = node.default_attrs
@@ -99,11 +99,12 @@ class Chef
# special case ec2 with their split horizon whatsis.
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
+ name = node['name'] || node.name
- hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
+ hours, minutes, _ = time_difference_in_hms(node["ohai_time"])
hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}"
minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}"
- run_list = "#{node.run_list}" if config[:run_list]
+ run_list = "#{node['run_list']}" if config[:run_list]
if hours > 24
color = :red
text = hours_text
@@ -116,7 +117,7 @@ class Chef
end
line_parts = Array.new
- line_parts << @ui.color(text, color) + ' ago' << node.name
+ line_parts << @ui.color(text, color) + ' ago' << name
line_parts << fqdn if fqdn
line_parts << ip if ip
line_parts << run_list if run_list