diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-03-31 11:44:15 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2016-03-31 11:44:15 -0700 |
commit | 3dcb08cee47263b7a025203ad9b20e7d778a8d5c (patch) | |
tree | 578b1178673d8d7efaada9b7e53596800bee3fd4 | |
parent | 5904607f0dde61751dab4d8c8d03811e369b3f17 (diff) | |
download | ohai-3dcb08cee47263b7a025203ad9b20e7d778a8d5c.tar.gz |
Remove the Xen MAC address detection method
This false detects any Xen system and is less than ideal
-rw-r--r-- | lib/ohai/plugins/ec2.rb | 25 | ||||
-rw-r--r-- | spec/unit/plugins/ec2_spec.rb | 16 |
2 files changed, 1 insertions, 40 deletions
diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 513058c1..725d655f 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -22,7 +22,6 @@ # 1. Ohai ec2 hint exists. This always works # 2. DMI data mentions amazon. This catches HVM instances in a VPC # 3. Kernel data mentioned Amazon. This catches Windows instances -# 4. Has a xen MAC + can connect to metadata. This catches paravirt instances not in a VPC require "ohai/mixin/ec2_metadata" require "base64" @@ -32,31 +31,9 @@ Ohai.plugin(:EC2) do provides "ec2" - depends "network/interfaces" depends "dmi" depends "kernel" - # look for xen arp address - # this gets us detection of paravirt instances that are NOT within a VPC - def has_xen_mac? - network[:interfaces].values.each do |iface| - unless iface[:arp].nil? - if iface[:arp].value?("fe:ff:ff:ff:ff:ff") - # using MAC addresses from ARP is unreliable because they could time-out from the table - # fe:ff:ff:ff:ff:ff is actually a sign of Xen, not specifically EC2 - deprecation_message <<-EOM -ec2 plugin: Detected EC2 by the presence of fe:ff:ff:ff:ff:ff in the ARP table. This method is unreliable and will be removed in a future version of ohai. Bootstrap using knife-ec2 or create "/etc/chef/ohai/hints/ec2.json" instead. -EOM - Ohai::Log.warn(deprecation_message) - Ohai::Log.debug("ec2 plugin: has_xen_mac? == true") - return true - end - end - end - Ohai::Log.debug("ec2 plugin: has_xen_mac? == false") - false - end - # look for amazon string in dmi bios data # this gets us detection of HVM instances that are within a VPC def has_ec2_dmi? @@ -91,7 +68,7 @@ EOM return true if hint?("ec2") # Even if it looks like EC2 try to connect first - if has_ec2_dmi? || has_amazon_org? || has_xen_mac? + if has_ec2_dmi? || has_amazon_org? return true if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80) end end diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index b5d4e87b..ef67bfba 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -24,7 +24,6 @@ require "base64" describe Ohai::System, "plugin ec2" do before(:each) do @plugin = get_plugin("ec2") - @plugin[:network] = { :interfaces => { :eth0 => {} } } allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) end @@ -254,20 +253,6 @@ describe Ohai::System, "plugin ec2" do end end # shared examples for ec2 - describe "without dmi data, kernel organization, with xen mac, and metadata address connected" do - before(:each) do - allow(IO).to receive(:select).and_return([[], [1], []]) - @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "fe:ff:ff:ff:ff:ff" } - end - - it_should_behave_like "ec2" - - it "warns that the arp table method is deprecated" do - expect(Ohai::Log).to receive(:warn).with(/will be removed/) - @plugin.has_xen_mac? - end - end - describe "with ec2 dmi data" do it_should_behave_like "ec2" @@ -316,7 +301,6 @@ describe Ohai::System, "plugin ec2" do allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) @plugin[:dmi] = nil - @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "00:50:56:c0:00:08" } end end |