From 42b04ffceafa3db6681d38d9915fa36449954d85 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 6 Nov 2018 12:47:38 -0800 Subject: Update knife status --long to use cloud attributes not ec2 specific attributes This way we get the public IP / hostname on Azure, GCE, DigitalOcean, Softlayer, etc. Signed-off-by: Tim Smith --- lib/chef/knife/core/status_presenter.rb | 6 +++--- lib/chef/knife/status.rb | 4 ++-- spec/unit/knife/status_spec.rb | 4 ++-- 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 () -# 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 () -# 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 () -# 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 -- cgit v1.2.1