diff options
author | Alberto Murillo Silva <alberto.murillo.silva@intel.com> | 2017-06-28 15:26:03 -0500 |
---|---|---|
committer | Alberto Murillo Silva <alberto.murillo.silva@intel.com> | 2017-06-28 17:54:08 -0500 |
commit | 60ac6b3de69d4a473b32f57b3f38e1aadb70600f (patch) | |
tree | 4a1a9976b1366e33563eae18a33654737008e9a6 | |
parent | 1dfddaacae818d4fcc165cb8dfa7697eb7199824 (diff) | |
download | ohai-60ac6b3de69d4a473b32f57b3f38e1aadb70600f.tar.gz |
Add support for ClearLinux
Set platform and platform_family to 'clearlinux'
on Clear Linux OS nodes.
Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 33 |
2 files changed, 41 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index ae6d6589..a926f40f 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -127,6 +127,8 @@ Ohai.plugin(:Platform) do "exherbo" when /alpine/ "alpine" + when /clearlinux/ + "clearlinux" end end @@ -232,6 +234,12 @@ Ohai.plugin(:Platform) do elsif File.exist?("/etc/alpine-release") platform "alpine" platform_version File.read("/etc/alpine-release").strip() + elsif File.exist?("/usr/lib/os-release") + contents = File.read("/usr/lib/os-release") + if /Clear Linux/ =~ contents + platform "clearlinux" + platform_version contents[/VERSION_ID=(\d+)/, 1] + end elsif lsb[:id] =~ /RedHat/i platform "redhat" platform_version lsb[:release] diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 00f1425c..807c2b09 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -35,6 +35,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_parallels_release) { false } let(:have_raspi_config) { false } let(:have_os_release) { false } + let(:have_usr_lib_os_release) { false } let(:have_cisco_release) { false } let(:have_cumulus_dir) { false } @@ -57,6 +58,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("/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) @@ -861,4 +863,35 @@ CISCO_RELEASE expect(@plugin[:platform_version]).to eq("6.0.0.14I") end end + + describe "on clearlinux" do + let(:have_usr_lib_os_release) { true } + let(:usr_lib_os_release_content) do + <<-CLEARLINUX_RELEASE +NAME="Clear Linux Software for Intel Architecture" +VERSION=1 +ID=clear-linux-os +VERSION_ID=16140 +PRETTY_NAME="Clear Linux OS for Intel Architecture" +ANSI_COLOR="1;35" +HOME_URL="https://clearlinux.org" +SUPPORT_URL="https://clearlinux.org" +BUG_REPORT_URL="mailto:dev@lists.clearlinux.org" +PRIVACY_POLICY_URL="http://www.intel.com/privacy" +CLEARLINUX_RELEASE + end + + before do + expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content) + end + + it "should set platform to clearlinux and platform_family to clearlinux" do + @plugin.lsb = nil + @plugin.run + + expect(@plugin[:platform]).to eq("clearlinux") + expect(@plugin[:platform_family]).to eq("clearlinux") + expect(@plugin[:platform_version]).to eq("16140") + end + end end |