diff options
author | Jere Julian <jere@arista.com> | 2016-08-10 16:04:07 -0400 |
---|---|---|
committer | Jere Julian <jere@arista.com> | 2016-08-10 16:04:07 -0400 |
commit | 4862f60607b8e49dc88052ae3a15db3c4b4d0850 (patch) | |
tree | f797c769e5ece3da16634c5f83c6ce847f3f50d5 | |
parent | f9992941f3a39937362d1c98cb4dc63bd9d5b680 (diff) | |
download | ohai-4862f60607b8e49dc88052ae3a15db3c4b4d0850.tar.gz |
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 | 18 |
2 files changed, 22 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..409021a9 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -46,6 +46,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 +247,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 } |