Issue #11082 has been updated by Stefan Schulte.

Status changed from Tests Insufficient to In Topic Branch Pending Review

I added some tests and just learned about a special behaviour of facter:

If we have more than one operatingsystemrelease fact that suits our system, 
facter will iterate over all instances until one is not returning nil or "". So 
if the newly added `operatingsystemrelease` fact does return nil (release 
string cannot be parsed) or raises an exception (file is not present or empty) 
the next operatingsystemrelase fact is picked. And that is currently the one 
that just returns the kernelrelease fact.

This behaviour is now reflected in the tests but I cannot say I like it. I'd 
prefer to deprecate the operatingsystemrelease fact that returns the 
kernelrelease fact. Like printing a warning 'operatingsystemrelease fact is not 
yet implemented for your system. Please use the kernelrelease fact instead. The 
value of the operatingsystemrelease fact may change in the future'

In the end the operatingsystemrelease fact would either return the correct 
value or nothing but not try to find something in between.

----------------------------------------
Feature #11082: operatingsystemrelease for Solaris
https://projects.puppetlabs.com/issues/11082

Author: John Warburton
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: Stefan Schulte
Category: library
Target version: 1.7.x
Keywords: 
Branch: https://github.com/stschulte/facter/tree/feature/1.6.x/11082
Affected Facter version: 


We need to know what release of Solaris installed. We have code (below) which 
parses /etc/release, which maybe others would like to see in future versions of 
facter rather than returning kernelversion

Code is clunky, as my ruby is pretty basic, but should go into 
lib/facter/operatingsystemrelease.rb. Ideally the regexp should not need the 
extra "ustring" search, but I haven't worked out how to cater for when the "_u" 
is not present - which is why I'm not prepared to submit a patch

The values returned work correctly with the versioncmp function

        releasefile = "/etc/release"
        File::open(releasefile, "r") do |f|
            line = f.readline.chomp

            line =~ /s(\d+)[s|x]*.* [SPARC|X86]/
            relstring = $1

            # sometimes the _u is not there on the initial release
            line =~ /s\d+[s|x]*_u(\d+).* [SPARC|X86]/
            ustring = $1
            if (ustring.nil?)
                operatingsystemrelease = relstring
            else
                operatingsystemrelease = relstring + "_u#{ustring}"
            end

Note that this regexp has been tested against all /etc/release entries from 
Solaris 8 to Solaris 10 U10 (SPARC & x86) per Support Document [How to 
Determine the Release and Default Kernel Version in the Solaris Operating 
System [ID 
1002239.1]](https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=HOWTO&id=1002239.1)
 (you need an Oracle support account to view this file). I do not have a 
Solaris 11 server to validate Solaris 11

Here are my test results:
    Solaris 8 s28_38shwp2 SPARC ==> 28
    Solaris 8 6/00 s28s_u1wos_08 SPARC ==> 28_u1
    Solaris 8 10/00 s28s_u2wos_11b SPARC ==> 28_u2
    Solaris 8 1/01 s28s_u3wos_08 SPARC ==> 28_u3
    Solaris 8 4/01 s28s_u4wos_08 SPARC ==> 28_u4
    Solaris 8 7/01 s28s_u5wos_08 SPARC ==> 28_u5
    Solaris 8 10/01 s28s_u6wos_08a SPARC ==> 28_u6
    Solaris 8 2/02 s28s_u7wos_08a SPARC ==> 28_u7
    Solaris 8 HW 12/02 s28s_hw1wos_06a SPARC ==> 28
    Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC ==> 28
    Solaris 8 HW 7/03 s28s_hw3wos_05a SPARC ==> 28
    Solaris 8 2/04 s28s_hw4wos_05a SPARC ==> 28
    Solaris 9 s9_58shwpl3 SPARC ==> 9
    Solaris 9 9/02 s9s_u1wos_08b SPARC ==> 9_u1
    Solaris 9 12/02 s9s_u2wos_10 SPARC ==> 9_u2
    Solaris 9 4/03 s9s_u3wos_08 SPARC ==> 9_u3
    Solaris 9 8/03 s9s_u4wos_08a SPARC ==> 9_u4
    Solaris 9 12/03 s9s_u5wos_08b SPARC ==> 9_u5
    Solaris 9 4/04 s9s_u6wos_08a SPARC ==> 9_u6
    Solaris 9 9/04 s9s_u7wos_09 SPARC ==> 9_u7
    Solaris 9 9/05 s9s_u8wos_05 SPARC ==> 9_u8
    Solaris 9 9/05 HW s9s_u9wos_06b SPARC ==> 9_u9
    Solaris 10 3/05 s10_74L2a SPARC ==> 10
    Solaris 10 3/05 HW1 s10s_wos_74L2a SPARC ==> 10
    Solaris 10 3/05 HW2 s10s_hw2wos_05 SPARC ==> 10
    Solaris 10 1/06 s10s_u1wos_19a SPARC ==> 10_u1
    Solaris 10 6/06 s10s_u2wos_09a SPARC ==> 10_u2
    Solaris 10 11/06 s10s_u3wos_10 SPARC ==> 10_u3
    Solaris 10 8/07 s10s_u4wos_12b SPARC ==> 10_u4
    Solaris 10 5/08 s10s_u5wos_10 SPARC ==> 10_u5
    Solaris 10 10/08 s10s_u6wos_07b SPARC ==> 10_u6
    Solaris 10 5/09 s10s_u7wos_08 SPARC ==> 10_u7
    Solaris 10 10/09 s10s_u8wos_08a SPARC ==> 10_u8
    Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC ==> 10_u9
    Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC ==> 10_u10
    Solaris 10 3/05 HW1 s10x_wos_74L2a X86  ==> 10
    Solaris 10 1/06 s10x_u1wos_19a X86 ==> 10_u1
    Solaris 10 6/06 s10x_u2wos_09a X86  ==> 10_u2
    Solaris 10 11/06 s10x_u3wos_10 X86  ==> 10_u3
    Solaris 10 8/07 s10x_u4wos_12b X86  ==> 10_u4
    Solaris 10 5/08 s10x_u5wos_10 X86  ==> 10_u5
    Solaris 10 10/08 s10x_u6wos_07b X86  ==> 10_u6
    Solaris 10 5/09 s10x_u7wos_08 X86 ==> 10_u7
    Solaris 10 10/09 s10x_u8wos_08a X86 ==> 10_u8
    Oracle Solaris 10 9/10 s10x_u9wos_14a X86 ==> 10_u9
    Oracle Solaris 10 8/11 s10x_u10wos_17b X86 ==> 10_u10



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to