summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-06 12:47:38 -0800
committerTim Smith <tsmith84@gmail.com>2020-01-28 11:28:08 -0800
commit42b04ffceafa3db6681d38d9915fa36449954d85 (patch)
tree24333e35c68f236fc42141a7e9c09c95a045af1f
parentde71b21a9ed8ea6725f8e4e1eafada0943a33fee (diff)
downloadchef-status_done_right.tar.gz
Update knife status --long to use cloud attributes not ec2 specific attributesstatus_done_right
This way we get the public IP / hostname on Azure, GCE, DigitalOcean, Softlayer, etc. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/knife/core/status_presenter.rb6
-rw-r--r--lib/chef/knife/status.rb4
-rw-r--r--spec/unit/knife/status_spec.rb4
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 9042350295..b33bd95da4 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -1,6 +1,6 @@
#
# Author:: Nicolas DUPEUX (<nicolas.dupeux@arkea.com>)
-# Copyright:: Copyright 2011-2016, Chef Software Inc.
+# Copyright:: Copyright 2011-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -67,8 +67,8 @@ class Chef
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"]
+ ip = (node["cloud"] && node["cloud"]["public_ipv4_addrs"].first) || node["ipaddress"]
+ fqdn = (node["cloud"] && node["cloud"]["public_hostname"]) || node["fqdn"]
result["ip"] = ip if ip
result["fqdn"] = fqdn if fqdn
result["run_list"] = node.run_list if config["run_list"]
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 074488e003..f157c60b41 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -1,6 +1,6 @@
#
# Author:: Ian Meyer (<ianmmeyer@gmail.com>)
-# Copyright:: Copyright 2010-2016, Ian Meyer
+# Copyright:: Copyright 2010-2020, Ian Meyer
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -59,7 +59,7 @@ class Chef
else
opts = { filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
- ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
+ cloud: ["cloud"], run_list: ["run_list"], platform: ["platform"],
platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }
end
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 8af3b3e871..63b3a62e75 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Sahil Muthoo (<sahil.muthoo@gmail.com>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,7 +39,7 @@ describe Chef::Knife::Status do
let(:opts) do
{ filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
- ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
+ cloud: ["cloud"], run_list: ["run_list"], platform: ["platform"],
platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }
end