summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-28 10:43:25 -0800
committerTim Smith <tsmith@chef.io>2018-12-05 13:39:25 -0800
commit4ca65351a8986819852cfed09ccab92e85331a2d (patch)
treeab43126f5553a8f3a49ce40d3dbaeba8ad6172ec
parent97dd2ef5c907dea035b4b7bb37075e6098f2d669 (diff)
downloadohai-4ca65351a8986819852cfed09ccab92e85331a2d.tar.gz
Fix arista detection
Modern arista systems include not only /etc/Eos-release, but also /etc/redhat-release and /etc/system-release. Due to the order we did detection with this meant we read /etc/redhat-release first and identified arista as being fedora. Correct the order and wire things up in a way that will fail if we try to refactor the code back in the future. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/linux/platform.rb7
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb6
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index a8c8646e..86d9fa5e 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -198,6 +198,9 @@ Ohai.plugin(:Platform) do
contents = File.read("/etc/parallels-release").chomp
platform get_redhatish_platform(contents)
platform_version contents.match(/(\d\.\d\.\d)/)[0]
+ elsif File.exist?("/etc/Eos-release")
+ platform "arista_eos"
+ platform_version File.read("/etc/Eos-release").strip.split[-1]
elsif File.exist?("/etc/redhat-release")
if os_release_file_is_cisco? # Cisco guestshell
platform "nexus_centos"
@@ -226,10 +229,6 @@ Ohai.plugin(:Platform) do
else
platform "suse"
end
- elsif File.exist?("/etc/Eos-release")
- platform "arista_eos"
- platform_version File.read("/etc/Eos-release").strip.split[-1]
- platform_family "fedora"
elsif os_release_file_is_cisco?
raise "unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field" if
os_release_info["ID_LIKE"].nil? || ! os_release_info["ID_LIKE"].include?("wrlinux")
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index bc486396..65a81aae 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -296,6 +296,8 @@ OS_RELEASE
describe "on arista eos" do
+ let(:have_system_release) { true }
+ let(:have_redhat_release) { true }
let(:have_eos_release) { true }
before(:each) do
@@ -303,11 +305,11 @@ OS_RELEASE
end
it "should set platform to arista_eos" do
- expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.16.7M")
+ expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.21.1.1F")
@plugin.run
expect(@plugin[:platform]).to eq("arista_eos")
expect(@plugin[:platform_family]).to eq("fedora")
- expect(@plugin[:platform_version]).to eq("4.16.7M")
+ expect(@plugin[:platform_version]).to eq("4.21.1.1F")
end
end