diff options
author | Tim Smith <tsmith@chef.io> | 2016-08-11 12:34:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-11 12:34:31 -0700 |
commit | af061dd99e771197b9aaec8c63a42b07a72662f2 (patch) | |
tree | 7a62c33466e3b0bd1d2a57e99b403c5c83dd6411 | |
parent | 5aae671a04f43505e4ccbad80fb9c4fd0112846e (diff) | |
parent | de1c9b8876c0ae1c899bfdfe96cdd1c40b7955aa (diff) | |
download | ohai-af061dd99e771197b9aaec8c63a42b07a72662f2.tar.gz |
Merge pull request #860 from jerearista/arista_eos
Add platform detection for Arista EOS
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index 21cc4030..aa7771e8 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -153,6 +153,10 @@ Ohai.plugin(:Platform) do elsif File.exist?("/etc/alpine-release") platform "alpine" platform_version File.read("/etc/alpine-release").strip() + 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 3501610e..fffa7d51 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -26,6 +26,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_gentoo_release) { false } let(:have_exherbo_release) { false } let(:have_alpine_release) { false } + let(:have_eos_release) { false } let(:have_suse_release) { false } let(:have_arch_release) { false } let(:have_system_release) { false } @@ -46,6 +47,7 @@ describe Ohai::System, "Linux plugin platform" do allow(File).to receive(:exist?).with("/etc/gentoo-release").and_return(have_gentoo_release) allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release) allow(File).to receive(:exist?).with("/etc/alpine-release").and_return(have_alpine_release) + allow(File).to receive(:exist?).with("/etc/Eos-release").and_return(have_eos_release) allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release) allow(File).to receive(:exist?).with("/etc/arch-release").and_return(have_arch_release) allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release) @@ -246,6 +248,23 @@ describe Ohai::System, "Linux plugin platform" do end end + describe "on arista eos" do + + let(:have_eos_release) { true } + + before(:each) do + @plugin.lsb = nil + 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") + @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") + end + end + describe "on exherbo" do let(:have_exherbo_release) { true } |