Hi all,

I am new to Ruby, Puppet & this project so bear with me if I am on the 
wrong track.

I am in the process of deploying Puppet to a large fleet of HP-UX versions 
11.00, 11.11, 11.23 and 11.31 as well as Solaris versions 2.5, 2.6, 7, 8 & 
9 (as well as plenty of AIX & RHEL/CentOS that isn't relevant to this post).

We have found that facter's processorcount & processorN code breaks on 
HP-UX (where HP-UX doesn't appear to be supported) and also on all versions 
of Solaris prior to Solaris 10.  This relates to Bug #14674.

I am proposing the following changes to 1.6.x to fix the code per 
suggestions from Josh Cooper as well as providing patches for the versions 
of HP-UX and legacy Solaris we can test on.

* I would begin by refactoring util/processor.rb a little moving iterative 
code to the top, all Facter.add blocks after this, and standardise naming 
of 'ProcessorCount' using camel case.  I would do this in a single commit?

* I understand Josh Cooper's suggestion "It should only call these methods 
on the appropriate platform, and it should only call them when needed (if 
processor_list is empty)" (from 
http://projects.puppetlabs.com/issues/14674) thus have rewritten 

## We have to enumerate these outside a Facter.add block to get the 
processorN descriptions iteratively
## (but we need them inside the Facter.add block above for tests on 
processorcount to work)
processor_list = Facter::Util::Processor.enum_cpuinfo
processor_list_aix = Facter::Util::Processor.enum_lsdev
processor_list_sunos = Facter::Util::Processor.enum_kstat

if processor_list.length != 0
etc

as 

## We have to enumerate these outside a Facter.add block to get the 
processorN descriptions iteratively
## (but we need them inside the Facter.add block above for tests on 
processorcount to work)
if Facter.value(:kernel) == "AIX"
  processor_list = Facter::Util::Processor.enum_lsdev
elsif Facter.value(:kernel) == "SunOS"
  processor_list = Facter::Util::Processor.enum_kstat
else
  processor_list = Facter::Util::Processor.enum_cpuinfo
end

if processor_list.length != 0
  processor_list.each_with_index do |desc, i|
    Facter.add("Processor#{i}") do
      confine :kernel => [ :linux, :"gnu/kfreebsd", :aix, :sunos ]
      setcode do
        desc
      end
    end
  end
end

* Having done that I would then open bugs for the failures I get in HP-UX 
and legacy Solaris.  I documented the HP-UX problem in an update to #14674 
and feel it might be reasonable to fix HP-UX under the same bug?  Thus I 
would in a single commit add a case for HP-UX -

elsif Facter.value(:kernel) == "HP-UX"
  processor_list = Facter::Util::Processor.enum_machinfo
...

and provide the method enum_machinfo in util/processor.rb to get CPU 
information on HP-UX.  

* Then I will open a bug for legacy Solaris.  The problem with legacy 
Solaris is that 'kstat cpu_info' was not introduced until Solaris 8; on 
Solaris 7 and earlier this code fails.  I'll work out a solution to this 
problem prior to raising the bug.  

I have read the documentation about how to contribute, and so forth, so 
will follow that.  Otherwise, do I sound like I am on the right track?

Kind regards,
Alex Harvey

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-dev/-/xQsajJ6FTccJ.
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-dev?hl=en.

Reply via email to