I talked with Luke on the phone about this and he suggested that this code is acceptable.
On Fri, May 1, 2009 at 9:39 AM, Luke Kanies <[email protected]> wrote: > > On Apr 27, 2009, at 7:10 PM, [email protected] wrote: > >> >> From: Sam Rowe <[email protected]> >> >> hardware model >> serialnumber is in a new file per James Turnbull >> memory and swap sizing >> processor count >> >> Signed-off-by: Sam Rowe <[email protected]> >> --- >> lib/facter/hardwaremodel.rb | 5 +++++ >> lib/facter/memory.rb | 24 ++++++++++++++++++++++++ >> lib/facter/processor.rb | 11 +++++++++++ >> lib/facter/serialnumber.rb | 4 ++++ >> 4 files changed, 44 insertions(+), 0 deletions(-) >> create mode 100644 lib/facter/serialnumber.rb >> >> diff --git a/lib/facter/hardwaremodel.rb b/lib/facter/hardwaremodel.rb >> index 6201bdd..bbf5421 100644 >> --- a/lib/facter/hardwaremodel.rb >> +++ b/lib/facter/hardwaremodel.rb >> @@ -19,3 +19,8 @@ Facter.add(:hardwaremodel) do >> Config::CONFIG['host_cpu'] >> end >> end >> + >> +Facter.add(:hardwaremodel) do >> + confine :operatingsystem => :"hp-ux" >> + setcode '/bin/getconf MACHINE_MODEL' >> +end >> diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb >> index 6880731..dd6c4a8 100644 >> --- a/lib/facter/memory.rb >> +++ b/lib/facter/memory.rb >> @@ -44,3 +44,27 @@ if Facter.value(:kernel) == "AIX" >> end >> end >> end >> +if Facter.value(:kernel) == "HP-UX" > > I, too, would prefer this to be swapped to use 'confine'. Then you > pull the memory info in the fact, rather than just polling it once at > startup. > >> >> + # no MemoryFree because hopefully there is none >> + if FileTest.exists?("/opt/ignite/bin/print_manifest") >> + mem = %x{/opt/ignite/bin/print_manifest}.split(/\n/).grep(/ >> Main Memory:/).collect{|l| l.split[2]} >> + Facter.add(:MemorySize) do >> + setcode do >> + Facter::Memory.scale_number(mem[0].to_f,"MB") >> + end >> + end >> + end >> + swapt = %x{/usr/sbin/swapinfo -dtm}.split(/\n/).grep(/^total/) >> + swap = swapt[0].split[1] >> + swapf = swapt[0].split[3] >> + Facter.add("SwapTotal") do >> + setcode do >> + Facter::Memory.scale_number(swap.to_f,"MB") >> + end >> + end >> + Facter.add("SwapFree") do >> + setcode do >> + Facter::Memory.scale_number(swapf.to_f,"MB") >> + end >> + end > > Same here - if the swap facts calculated the swap each time they were > run, it would be better, and then just confine the facts to hp. > >> >> +end >> diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb >> index 154cced..ac8b37a 100644 >> --- a/lib/facter/processor.rb >> +++ b/lib/facter/processor.rb >> @@ -72,3 +72,14 @@ if Facter.value(:kernel) == "AIX" >> end >> end >> end >> + >> +if Facter.value(:kernel) == "HP-UX" >> + if FileTest.exists?("/opt/ignite/bin/print_manifest") >> + cpus = %x{/opt/ignite/bin/print_manifest}.split(/\n/).grep(/ >> Processors:/).collect{|l| l.split[1]} >> + Facter.add("ProcessorCount") do >> + setcode do >> + cpus[0] >> + end >> + end >> + end >> +end > > And here, of course. :) > >> >> diff --git a/lib/facter/serialnumber.rb b/lib/facter/serialnumber.rb >> new file mode 100644 >> index 0000000..130844a >> --- /dev/null >> +++ b/lib/facter/serialnumber.rb >> @@ -0,0 +1,4 @@ >> +Facter.add(:serialnumber) do >> + confine :operatingsystem => :"hp-ux" >> + setcode '/bin/getconf MACHINE_SERIAL' >> +end >> -- >> 1.5.6.3 >> >> >> > > > > -- > The intelligent man finds almost everything ridiculous, the sensible > man hardly anything. -- Johann Wolfgang von Goethe > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" 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-dev?hl=en -~----------~----~----~----~------~----~------~--~---
