summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-03-06 15:17:44 -0800
committerTim Smith <tsmith84@gmail.com>2020-03-06 16:05:14 -0800
commit5c64875047c594baa235f24dd19ad70ff3506a84 (patch)
tree26ae5e5c1d0f5b7613ad43da391858e3516f5faa
parent78bb0d404f632f1bf3c0f74022010366d8aac18c (diff)
downloadchef-5c64875047c594baa235f24dd19ad70ff3506a84.tar.gz
Use Ohai's cloud attributes in knife node / status presenters
Right now we have a specific case for EC2. This extends the same logic to all clouds by using the node['cloud'] data. This really only changes things if you run knife status with the --long flag. The output doesn't change for EC2 nodes: bundle exec knife status --long 36666 hours ago, smith-0, smith-0, 172.16.1.13, ubuntu 14.04. 7411 hours ago, myhost, ec2-13-59-123-123.us-east-2.compute.amazonaws.com, 13.59.123.123, ubuntu 18.04. 7298 hours ago, tim_test, ec2-34-123-123-2.us-west-2.compute.amazonaws.com, 34.221.123.123, ubuntu 16.04. 7298 hours ago, tim_test2, ec2-52-88-123-123.us-west-2.compute.amazonaws.com, 52.88.123.123, redhat 7.6. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/knife/core/node_presenter.rb4
-rw-r--r--lib/chef/knife/core/status_presenter.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index 258a4822fd..23f8fd9815 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -94,8 +94,8 @@ class Chef
def summarize(data)
if data.is_a?(Chef::Node)
node = data
- # special case ec2 with their split horizon whatsis.
- ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
+ # special case clouds with their split horizon whatsis.
+ ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
summarized = <<~SUMMARY
#{ui.color("Node Name:", :bold)} #{ui.color(node.name, :bold)}
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index b33bd95da4..1b47eccc5d 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -95,9 +95,9 @@ class Chef
summarized = ""
list.each do |data|
node = data
- # 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]
+ # special case clouds with their split horizon whatsis.
+ ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
+ fqdn = (node[:cloud] && node[:cloud][:public_hostname]) || node[:fqdn]
name = node["name"] || node.name
if config[:run_list]