diff options
author | Tim Smith <tsmith@chef.io> | 2017-07-19 10:39:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-19 10:39:49 -0700 |
commit | ae215e63d608d455d57f9335d76e3d25f57d0083 (patch) | |
tree | 20a94b61e76a5d37ebda074bd465955da101ed77 | |
parent | 44974f03f6810cc1d37fce3b922d89600c6088b9 (diff) | |
parent | 070441f81bb1da0c45fb0b25b0f7a62c9c19c374 (diff) | |
download | ohai-ae215e63d608d455d57f9335d76e3d25f57d0083.tar.gz |
Merge pull request #1035 from chef/f5
Detect F5 Big-IPs as platform bigip
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 18 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 19 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index a926f40f..d8048eae 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -86,6 +86,19 @@ Ohai.plugin(:Platform) do end # + # Determines the platform version for F5 Big-IP systems + # + # @returns [String] bigip Linux version from /etc/f5-release + # + def bigip_version + release_contents = File.read("/etc/f5-release") + release_contents.match(/BIG-IP release (\S*)/)[1] # http://rubular.com/r/O8nlrBVqSb + rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied + Ohai::Log.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version") + nil + end + + # # Determines the platform version for Debian based systems # # @returns [String] version of the platform @@ -107,7 +120,7 @@ Ohai.plugin(:Platform) do case platform when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/ "debian" - when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID" + when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID" "rhel" when /amazon/ "amazon" @@ -142,6 +155,9 @@ Ohai.plugin(:Platform) do contents = File.read("/etc/enterprise-release").chomp platform "oracle" platform_version get_redhatish_version(contents) + elsif File.exist?("/etc/f5-release") + platform "bigip" + platform_version bigip_version elsif File.exist?("/etc/debian_version") # Ubuntu and Debian both have /etc/debian_version # Ubuntu should always have a working lsb, debian does not by default diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 807c2b09..efe2884e 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -37,6 +37,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_os_release) { false } let(:have_usr_lib_os_release) { false } let(:have_cisco_release) { false } + let(:have_f5_release) { false } let(:have_cumulus_dir) { false } before(:each) do @@ -58,6 +59,7 @@ describe Ohai::System, "Linux plugin platform" do allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release) allow(File).to receive(:exist?).with("/usr/bin/raspi-config").and_return(have_raspi_config) allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release) + allow(File).to receive(:exist?).with("/etc/f5-release").and_return(have_f5_release) allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release) allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release) allow(Dir).to receive(:exist?).with("/etc/cumulus").and_return(have_cumulus_dir) @@ -309,6 +311,23 @@ OS_RELEASE end end + describe "on f5 big-ip" do + + let(:have_f5_release) { true } + + before(:each) do + @plugin.lsb = nil + end + + it "should set platform to bigip" do + expect(File).to receive(:read).with("/etc/f5-release").and_return("BIG-IP release 13.0.0 (Final)") + @plugin.run + expect(@plugin[:platform]).to eq("bigip") + expect(@plugin[:platform_family]).to eq("rhel") + expect(@plugin[:platform_version]).to eq("13.0.0") + end + end + describe "on exherbo" do let(:have_exherbo_release) { true } |