summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChibuikem Amaechi <cramaechi@me.com>2018-01-23 02:38:59 -0600
committerChibuikem Amaechi <cramaechi@me.com>2018-01-23 02:39:10 -0600
commit519cc87236585b0e5e0f1636d72fe90052552814 (patch)
tree7e81910bbfecc009b8cdc0bbf89636c0af5fa585
parent4919b83e8dd397f159e33d11756138f2e044cd38 (diff)
downloadchef-519cc87236585b0e5e0f1636d72fe90052552814.tar.gz
Update status line
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