[Pkg-puppet-devel] [facter] 329/352: (fact-155) Add operatingsystemmajrelease fact for Solaris

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 49e94df1e08d26446b7dc0244c9fda602d786398
Author: Stefan Schulte <stefan.schulte at taunusstein.net>
Date:   Thu Jan 9 23:22:30 2014 +0100

    (fact-155) Add operatingsystemmajrelease fact for Solaris
---
 lib/facter/operatingsystemmajrelease.rb     | 17 +++++++++++++++--
 spec/unit/operatingsystemmajrelease_spec.rb | 22 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lib/facter/operatingsystemmajrelease.rb b/lib/facter/operatingsystemmajrelease.rb
index f530125..f058a9f 100644
--- a/lib/facter/operatingsystemmajrelease.rb
+++ b/lib/facter/operatingsystemmajrelease.rb
@@ -2,8 +2,11 @@
 #
 # Purpose: Returns the major release of the operating system.
 #
-# Resolution: splits down the operatingsystemrelease fact at decimal point for
-#  osfamily RedHat derivatives and Debian.
+# Resolution:
+#   Splits down the operatingsystemrelease fact at decimal point for
+#   osfamily RedHat derivatives and Debian.
+#   Uses operatingsystemrelease to the first non decimal character for
+#   operatingsystem Solaris
 #
 # This should be the same as lsbmajdistrelease, but on minimal systems there
 # are too many dependencies to use LSB
@@ -13,6 +16,7 @@
 #"Debian" "Fedora" "Gentoo" "Mandrake" "Mandriva" "MeeGo" "OEL" "OpenSuSE" 
 #"OracleLinux" "OVS" "PSBM" "RedHat" "Scientific" "Slackware" "Slamd64" "SLC"
 #"SLED" "SLES" "SuSE" "Ubuntu" "VMWareESX"
+
 Facter.add(:operatingsystemmajrelease) do
   confine :operatingsystem => [
     :Amazon,
@@ -31,3 +35,12 @@ Facter.add(:operatingsystemmajrelease) do
     Facter.value('operatingsystemrelease').split('.').first
   end
 end
+
+Facter.add(:operatingsystemmajrelease) do
+  confine :operatingsystem => :solaris
+  setcode do
+    if match = Facter.value(:operatingsystemrelease).match(/^(\d+)/)
+      match.captures[0]
+    end
+  end
+end
diff --git a/spec/unit/operatingsystemmajrelease_spec.rb b/spec/unit/operatingsystemmajrelease_spec.rb
index 9c1a467..9973b23 100644
--- a/spec/unit/operatingsystemmajrelease_spec.rb
+++ b/spec/unit/operatingsystemmajrelease_spec.rb
@@ -13,4 +13,26 @@ describe "OS Major Release fact" do
       end
     end
   end
+
+  context "on Solaris operatingsystems" do
+    before :each do
+      Facter.fact(:kernel).stubs(:value).returns("SunOS")
+      Facter.fact(:operatingsystem).stubs(:value).returns("Solaris")
+    end
+
+    it "should correctly derive from operatingsystemrelease on solaris 10" do
+      Facter.fact(:operatingsystemrelease).expects(:value).returns("10_u8")
+      Facter.fact(:operatingsystemmajrelease).value.should == "10"
+    end
+
+    it "should correctly derive from operatingsystemrelease on solaris 11 (old version scheme)" do
+      Facter.fact(:operatingsystemrelease).expects(:value).returns("11 11/11")
+      Facter.fact(:operatingsystemmajrelease).value.should == "11"
+    end
+
+    it "should correctly derive from operatingsystemrelease on solaris 11 (new version scheme)" do
+      Facter.fact(:operatingsystemrelease).expects(:value).returns("11.1")
+      Facter.fact(:operatingsystemmajrelease).value.should == "11"
+    end
+  end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list