summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Vidner <martin@vidner.net>2013-03-19 16:54:22 +0100
committerBryan McLellan <btm@opscode.com>2013-06-24 16:49:42 -0700
commit45846ce59dd89b74c3b992d424a0b07d61b1f9f7 (patch)
treed8ae12a5650ff5f37cd90ea409744a5e57f72869
parentdd15a6c6fe09fc1ef83b84cd0ff3d0c01a3bede4 (diff)
downloadohai-45846ce59dd89b74c3b992d424a0b07d61b1f9f7.tar.gz
[OHAI-339] distinguish openSUSE from SUSE Linux Enterprise
- platform_family: stays "suse" for both - platform: SLE, being the more stable platform, gets to keep platform "suse" openSUSE is now platform "opensuse" - platform_version: is "MAJOR.MINOR" even for SLE which officially is versioned as "MAJOR [SP MINOR]" I considered to change the platform only for *future* openSUSE versions (12.3 or later) but decided against it: "suse" >= 12 would then conflict with a future SLE 12 (scheduled for 2014).
-rw-r--r--lib/ohai/plugins/linux/platform.rb11
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb15
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index 3bc6e3a3..4d17b5d7 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -69,10 +69,15 @@ elsif File.exists?('/etc/gentoo-release')
platform "gentoo"
platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
elsif File.exists?('/etc/SuSE-release')
- platform "suse"
suse_release = File.read("/etc/SuSE-release")
- platform_version suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
- platform_version suse_release.scan(/VERSION = ([\d\.]{2,})/).flatten.join(".") if platform_version == ""
+ suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
+ suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
+ platform_version suse_version
+ if suse_release =~ /^openSUSE/
+ platform "opensuse"
+ else
+ platform "suse"
+ end
elsif File.exists?('/etc/slackware-version')
platform "slackware"
platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 189b3430..7c3b86aa 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -384,12 +384,11 @@ describe Ohai::System, "Linux plugin platform" do
@ohai[:lsb][:id] = "SUSE LINUX"
end
- it "should read the platform as suse" do
+ it "should read the platform as opensuse on openSUSE" do
@ohai[:lsb][:release] = "12.1"
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
@ohai._require_plugin("linux::platform")
- @ohai[:platform].should == "suse"
- @ohai[:platform_version].should == "12.1"
+ @ohai[:platform].should == "opensuse"
@ohai[:platform_family].should == "suse"
end
end
@@ -429,7 +428,6 @@ describe Ohai::System, "Linux plugin platform" do
it "[OHAI-272] should read the version as 11.3" do
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
@ohai._require_plugin("linux::platform")
- @ohai[:platform].should == "suse"
@ohai[:platform_version].should == "11.3"
@ohai[:platform_family].should == "suse"
end
@@ -437,7 +435,6 @@ describe Ohai::System, "Linux plugin platform" do
it "[OHAI-272] should read the version as 9.1" do
File.should_receive(:read).with("/etc/SuSE-release").and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
@ohai._require_plugin("linux::platform")
- @ohai[:platform].should == "suse"
@ohai[:platform_version].should == "9.1"
@ohai[:platform_family].should == "suse"
end
@@ -445,10 +442,16 @@ describe Ohai::System, "Linux plugin platform" do
it "[OHAI-272] should read the version as 11.4" do
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
@ohai._require_plugin("linux::platform")
- @ohai[:platform].should == "suse"
@ohai[:platform_version].should == "11.4"
@ohai[:platform_family].should == "suse"
end
+
+ it "should read the platform as opensuse on openSUSE" do
+ File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
+ @ohai._require_plugin("linux::platform")
+ @ohai[:platform].should == "opensuse"
+ @ohai[:platform_family].should == "suse"
+ end
end
end