Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform detection for Arista EOS #860

Merged
merged 2 commits into from
Aug 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ohai/plugins/linux/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def os_release_file_is_cisco?
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")
Expand Down
19 changes: 19 additions & 0 deletions spec/unit/plugins/linux/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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 }
Expand All @@ -46,6 +47,7 @@
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)
Expand Down Expand Up @@ -246,6 +248,23 @@
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 }
Expand Down