summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChibuikem Amaechi <cramaechi@me.com>2018-01-23 02:38:59 -0600
committerTim Smith <tsmith@chef.io>2018-02-21 10:06:07 -0800
commit54fe560fd691a2d3f0c97a0ebd6857d9ee342fd0 (patch)
tree1c60ba30b1e4d4f42f79a77d870099d80e57b874
parent7fb50e9f4a05d4556e0c7163c50e39d94261da1b (diff)
downloadchef-knife_status.tar.gz
Update status lineknife_status
Signed-off-by: Chibuikem Amaechi <cramaechi@me.com>
-rw-r--r--lib/chef/knife/core/status_presenter.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 899da21003..1e2d9b41b6 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -101,32 +101,32 @@ class Chef
fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
name = node["name"] || node.name
- if !node["ohai_time"]
- ui.error("Ohai has not yet ran on node #{name}.")
- exit(1)
- end
-
- hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
- hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}"
- minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}"
- seconds_text = "#{seconds} second#{seconds == 1 ? ' ' : 's'}"
run_list = "#{node['run_list']}" if config[:run_list]
- if hours > 24
- color = :red
- text = hours_text
- elsif hours >= 1
- color = :yellow
- text = hours_text
- elsif minutes >= 1
- color = :green
- text = minutes_text
+ line_parts = Array.new
+
+ if node["ohai_time"]
+ hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
+ hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}"
+ minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}"
+ seconds_text = "#{seconds} second#{seconds == 1 ? ' ' : 's'}"
+ if hours > 24
+ color = :red
+ text = hours_text
+ elsif hours >= 1
+ color = :yellow
+ text = hours_text
+ elsif minutes >= 1
+ color = :green
+ text = minutes_text
+ else
+ color = :green
+ text = seconds_text
+ end
+ line_parts << @ui.color(text, color) + " ago" << name
else
- color = :green
- text = seconds_text
+ line_parts << "Node #{name} has not yet converged"
end
- line_parts = Array.new
- 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