diff options
author | Claire McQuin <mcquin@users.noreply.github.com> | 2014-08-07 15:27:59 -0700 |
---|---|---|
committer | Claire McQuin <mcquin@users.noreply.github.com> | 2014-08-07 15:27:59 -0700 |
commit | 57907f7f448472e2e44aad2c4ab4a690acad2927 (patch) | |
tree | 238d974be71fef272d548ec488fdb83a69ad4019 | |
parent | 121e9db60e562a0fcf3707df8d84544f3181f16e (diff) | |
parent | 250611d17b1c70634f08e432283bea3fd7ec4544 (diff) | |
download | ohai-57907f7f448472e2e44aad2c4ab4a690acad2927.tar.gz |
Merge pull request #369 from Kasen/pcs-support
Parallels cloud server platform support.
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 36 |
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index 90347a45..a6535ab1 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -55,6 +55,10 @@ Ohai.plugin(:Platform) do end platform_version File.read("/etc/debian_version").chomp end + elsif File.exists?("/etc/parallels-release") + contents = File.read("/etc/parallels-release").chomp + platform get_redhatish_platform(contents) + platform_version contents.match(/(\d\.\d\.\d)/)[0] elsif File.exists?("/etc/redhat-release") contents = File.read("/etc/redhat-release").chomp platform get_redhatish_platform(contents) @@ -109,7 +113,7 @@ Ohai.plugin(:Platform) do platform_family "debian" when /fedora/ platform_family "fedora" - when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID" + when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID" platform_family "rhel" when /suse/ platform_family "suse" diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index defe8836..a148ecf9 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 File.stub(:exists?).with("/etc/slackware-version").and_return(false) File.stub(:exists?).with("/etc/enterprise-release").and_return(false) File.stub(:exists?).with("/etc/oracle-release").and_return(false) + File.stub(:exists?).with("/etc/parallels-release").and_return(false) File.stub(:exists?).with("/usr/bin/raspi-config").and_return(false) end @@ -295,6 +296,41 @@ describe Ohai::System, "Linux plugin platform" do @plugin[:platform].should == "fedora" @plugin[:platform_version].to_i.should == 13 end + + end + end + + describe "on pcs linux" do + describe "with lsb_result" do + it "should read the platform as parallels and version as 6.0.5" do + @plugin[:lsb][:id] = "CloudLinuxServer" + @plugin[:lsb][:release] = "6.5" + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)") + File.should_receive(:exists?).with("/etc/parallels-release").and_return(true) + File.should_receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)") + @plugin.run + @plugin[:platform].should == "parallels" + @plugin[:platform_version].should == "6.0.5" + @plugin[:platform_family].should == "rhel" + end + end + + describe "without lsb_results" do + before(:each) do + @plugin.lsb = nil + end + + it "should read the platform as parallels and version as 6.0.5" do + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)") + File.should_receive(:exists?).with("/etc/parallels-release").and_return(true) + File.should_receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)") + @plugin.run + @plugin[:platform].should == "parallels" + @plugin[:platform_version].should == "6.0.5" + @plugin[:platform_family].should == "rhel" + end end end |