+1 Using WMI queries where we can makes sense
On 19 October 2010 00:28, Rein Henrichs <r...@puppetlabs.com> wrote: > From: William Van Hevelingen <wva...@gmail.com> > > Signed-off-by: William Van Hevelingen <wva...@gmail.com> > Signed-off-by: Rein Henrichs <r...@puppetlabs.com> > --- > lib/facter/manufacturer.rb | 8 ++++++++ > lib/facter/util/manufacturer.rb | 17 +++++++++++++++++ > 2 files changed, 25 insertions(+), 0 deletions(-) > > diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb > index 9d66465..68f5b96 100644 > --- a/lib/facter/manufacturer.rb > +++ b/lib/facter/manufacturer.rb > @@ -13,6 +13,14 @@ if Facter.value(:kernel) == "OpenBSD" > } > > Facter::Manufacturer.sysctl_find_system_info(mfg_keys) > + > +elsif Facter.value(:kernel) == "windows" > + win32_keys = { > + 'manufacturer' => ['Manufacturer', 'Bios'], > + 'serialNumber' => ['Serialnumber', 'Bios'], > + 'productname' => ['Name', 'ComputerSystemProduct'] > + } > + Facter::Manufacturer.win32_find_system_info(win32_keys) > else > query = { > '[Ss]ystem [Ii]nformation' => [ > diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb > index 112380b..368e8c1 100644 > --- a/lib/facter/util/manufacturer.rb > +++ b/lib/facter/util/manufacturer.rb > @@ -60,4 +60,21 @@ module Facter::Manufacturer > end > end > end > + > + def self.win32_find_system_info(name) > + require 'win32ole' > + value = "" > + wmi = WIN32OLE.connect("winmgmts://") > + name.each do |facterkey, win32key| > + query = wmi.ExecQuery("select * from Win32_#{win32key.last}") > + Facter.add(facterkey) do > + confine :kernel => :windows > + setcode do > + query.each { |x| value = x.__send__( (win32key.first).to_sym) } > + value > + end > + end > + end > + end > + > end > -- > 1.7.0.4 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to puppet-...@googlegroups.com. > To unsubscribe from this group, send email to > puppet-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.