From 519cc87236585b0e5e0f1636d72fe90052552814 Mon Sep 17 00:00:00 2001 From: Chibuikem Amaechi Date: Tue, 23 Jan 2018 02:38:59 -0600 Subject: Update status line Signed-off-by: Chibuikem Amaechi --- lib/chef/knife/core/status_presenter.rb | 44 ++++++++++++++++----------------- 1 file 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 -- cgit v1.2.1