You add some trailing whitespace in this patch, could you trim that and resend.
warning: 9 lines add whitespace errors. git show --check commit 73998a3a6e8a46a3bf7b618985621080cb83d1fd Author: Luke Kanies <[email protected]> Date: Fri Jan 2 16:16:21 2009 -0600 Fixing indentation everywhere Signed-off-by: Luke Kanies <[email protected]> lib/facter/ipmess.rb:34: trailing whitespace. + Facter::IPAddress.get_interface_value(interface, label) lib/facter/kernelversion.rb:4: trailing whitespace. + end lib/facter/util/ip.rb:88: trailing whitespace. + end lib/facter/util/ip.rb:106: trailing whitespace. + value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.') lib/facter/util/ip.rb:113: trailing whitespace. + if tmp1 lib/facter/virtual.rb:3: trailing whitespace. + lib/facter/virtual.rb:5: trailing whitespace. + lib/facter/virtual.rb:6: trailing whitespace. + setcode do lib/facter/virtual.rb:24: trailing whitespace. + result = "xenu" Cheers Paul 2009/1/2 Luke Kanies <[email protected]>: > > Signed-off-by: Luke Kanies <[email protected]> > --- > lib/facter/Cfkey.rb | 4 +- > lib/facter/fqdn.rb | 3 +- > lib/facter/ipmess.rb | 42 +++++----- > lib/facter/kernelrelease.rb | 4 +- > lib/facter/kernelversion.rb | 6 +- > lib/facter/macaddress.rb | 52 ++++++------ > lib/facter/operatingsystemrelease.rb | 16 ++-- > lib/facter/puppetversion.rb | 4 +- > lib/facter/util/ip.rb | 151 > +++++++++++++++++----------------- > lib/facter/util/macosx.rb | 49 ++++++------ > lib/facter/util/manufacturer.rb | 3 +- > lib/facter/util/netmask.rb | 44 +++++----- > lib/facter/util/plist.rb | 2 +- > lib/facter/virtual.rb | 133 +++++++++++++++--------------- > spec/unit/util/ip.rb | 5 +- > 15 files changed, 256 insertions(+), 262 deletions(-) > > diff --git a/lib/facter/Cfkey.rb b/lib/facter/Cfkey.rb > index 4c17a0a..a4e0c11 100644 > --- a/lib/facter/Cfkey.rb > +++ b/lib/facter/Cfkey.rb > @@ -22,7 +22,7 @@ Facter.add(:Cfkey) do > "/var/cfengine/ppkeys/localhost.pub", > "/var/lib/cfengine/ppkeys/localhost.pub", > "/var/lib/cfengine2/ppkeys/localhost.pub" > - ].each { |file| > + ].each do |file| > if FileTest.file?(file) > File.open(file) { |openfile| > value = openfile.readlines.reject { |line| > @@ -35,7 +35,7 @@ Facter.add(:Cfkey) do > if value > break > end > - } > + end > > value > end > diff --git a/lib/facter/fqdn.rb b/lib/facter/fqdn.rb > index 1fcc764..5ebc5f5 100644 > --- a/lib/facter/fqdn.rb > +++ b/lib/facter/fqdn.rb > @@ -1,4 +1,5 @@ > -Facter.add(:fqdn) do setcode do > +Facter.add(:fqdn) do > + setcode do > host = Facter.value(:hostname) > domain = Facter.value(:domain) > if host and domain > diff --git a/lib/facter/ipmess.rb b/lib/facter/ipmess.rb > index e879300..1dcd8ed 100644 > --- a/lib/facter/ipmess.rb > +++ b/lib/facter/ipmess.rb > @@ -15,32 +15,32 @@ Facter.add(:interfaces) do > end > > case Facter.value(:kernel) > - when 'SunOS', 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > - Facter::IPAddress.get_interfaces.each do |interface| > - mi = interface.gsub(/[:.]/, '_') > +when 'SunOS', 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > + Facter::IPAddress.get_interfaces.each do |interface| > + mi = interface.gsub(/[:.]/, '_') > > - Facter.add("ipaddress_" + mi) do > - confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ] > - setcode do > - label = 'ipaddress' > - Facter::IPAddress.get_interface_value(interface, label) > + Facter.add("ipaddress_" + mi) do > + confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux > ] > + setcode do > + label = 'ipaddress' > + Facter::IPAddress.get_interface_value(interface, label) > + end > end > - end > > - Facter.add("macaddress_" + mi) do > - confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ] > - setcode do > - label = 'macaddress' > - Facter::IPAddress.get_interface_value(interface, label) > + Facter.add("macaddress_" + mi) do > + confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux > ] > + setcode do > + label = 'macaddress' > + Facter::IPAddress.get_interface_value(interface, label) > + end > end > - end > > - Facter.add("netmask_" + mi) do > - confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ] > - setcode do > - label = 'netmask' > - Facter::IPAddress.get_interface_value(interface, label) > + Facter.add("netmask_" + mi) do > + confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux > ] > + setcode do > + label = 'netmask' > + Facter::IPAddress.get_interface_value(interface, label) > + end > end > end > - end > end > diff --git a/lib/facter/kernelrelease.rb b/lib/facter/kernelrelease.rb > index 5dccf8f..2f6ae45 100644 > --- a/lib/facter/kernelrelease.rb > +++ b/lib/facter/kernelrelease.rb > @@ -14,10 +14,10 @@ Facter.add(:kernelrelease) do > version = "" > connection_string = "winmgmts://./root/cimv2" > wmi = WIN32OLE.connect(connection_string) > - wmi.ExecQuery("SELECT Version from Win32_OperatingSystem").each { > |ole| > + wmi.ExecQuery("SELECT Version from Win32_OperatingSystem").each do > |ole| > version = "#{ole.Version}" > break > - } > + end > version > end > end > diff --git a/lib/facter/kernelversion.rb b/lib/facter/kernelversion.rb > index 7d2b31d..bfa8d0d 100644 > --- a/lib/facter/kernelversion.rb > +++ b/lib/facter/kernelversion.rb > @@ -1,5 +1,5 @@ > Facter.add("kernelversion") do > - setcode do > - Facter['kernelrelease'].value.split('-')[0] > - end > + setcode do > + Facter['kernelrelease'].value.split('-')[0] > + end > end > diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb > index 28ded4c..e048209 100644 > --- a/lib/facter/macaddress.rb > +++ b/lib/facter/macaddress.rb > @@ -3,9 +3,9 @@ Facter.add(:macaddress) do > setcode do > ether = [] > output = %x{/sbin/ifconfig -a} > - output.each {|s| > - ether.push($1) if s =~ /(?:ether|HWaddr) > (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > - } > + output.each do |s| > + ether.push($1) if s =~ /(?:ether|HWaddr) > (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > + end > ether[0] > end > end > @@ -15,11 +15,11 @@ Facter.add(:macaddress) do > setcode do > ether = [] > output = %x{/sbin/ifconfig} > - output.each {|s| > - if s =~ > /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ > - ether.push($1) > - end > - } > + output.each do |s| > + if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ > + ether.push($1) > + end > + end > ether[0] > end > end > @@ -30,12 +30,12 @@ Facter.add(:macaddress) do > ether = nil > output = %x{/sbin/ifconfig} > > - output.split(/^\S/).each { |str| > + output.split(/^\S/).each do |str| > if str =~ /10baseT/ # we're wired > str =~ /ether (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ > ether = $1 > end > - } > + end > > ether > end > @@ -47,19 +47,19 @@ Facter.add(:macaddress) do > ether = [] > ip = nil > output = %x{/usr/sbin/ifconfig -a} > - output.each { |str| > + output.each do |str| > if str =~ /([a-z]+\d+): flags=/ > devname = $1 > unless devname =~ /lo0/ > - output2 = %x{/usr/bin/entstat #{devname}} > - output2.each { |str2| > - if str2 =~ /^Hardware Address: > (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > - ether.push($1) > - end > - } > + output2 = %x{/usr/bin/entstat #{devname}} > + output2.each do |str2| > + if str2 =~ /^Hardware Address: > (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > + ether.push($1) > + end > + end > end > end > - } > + end > ether[0] > end > end > @@ -67,13 +67,13 @@ end > Facter.add(:macaddress) do > confine :kernel => %w(windows) > setcode do > - ether = [] > - output = %x{ipconfig /all} > - output.split(/\r\n/).each do |str| > - if str =~ /.*Physical Address.*: > (\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2})/ > - ether.push($1.gsub(/-/, ":")) > - end > - end > - ether[0] > + ether = [] > + output = %x{ipconfig /all} > + output.split(/\r\n/).each do |str| > + if str =~ /.*Physical Address.*: > (\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2})/ > + ether.push($1.gsub(/-/, ":")) > + end > + end > + ether[0] > end > end > diff --git a/lib/facter/operatingsystemrelease.rb > b/lib/facter/operatingsystemrelease.rb > index 586d104..f88278a 100644 > --- a/lib/facter/operatingsystemrelease.rb > +++ b/lib/facter/operatingsystemrelease.rb > @@ -29,11 +29,11 @@ end > Facter.add(:operatingsystemrelease) do > confine :operatingsystem => %w{CentOS} > setcode do > - centos_release = Facter::Util::Resolution.exec("sed -r -e 's/CentOS > release //' -e 's/ \((Branch|Final)\)//' /etc/redhat-release") > + centos_release = Facter::Util::Resolution.exec("sed -r -e 's/CentOS > release //' -e 's/ \((Branch|Final)\)//' /etc/redhat-release") > if centos_release =~ /5/ > - release = Facter::Util::Resolution.exec('rpm -q --qf > \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1,2') > + release = Facter::Util::Resolution.exec('rpm -q --qf > \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1,2') > else > - release = centos_release > + release = centos_release > end > end > end > @@ -42,16 +42,16 @@ Facter.add(:operatingsystemrelease) do > confine :operatingsystem => %w{Debian} > setcode do > release = Facter::Util::Resolution.exec('cat /etc/debian_version') > - end > + end > end > > Facter.add(:operatingsystemrelease) do > confine :operatingsystem => %w{Ubuntu} > setcode do > release = Facter::Util::Resolution.exec('cat /etc/issue') > - if release =~ /Ubuntu (\d+.\d+)/ > - $1 > - end > + if release =~ /Ubuntu (\d+.\d+)/ > + $1 > + end > end > end > > @@ -76,7 +76,7 @@ end > Facter.add(:operatingsystemrelease) do > confine :operatingsystem => %w{Solaris} > setcode do > - release = Facter::Util::Resolution.exec('uname -v') > + release = Facter::Util::Resolution.exec('uname -v') > end > end > > diff --git a/lib/facter/puppetversion.rb b/lib/facter/puppetversion.rb > index 66fcfe8..d2eb1f3 100644 > --- a/lib/facter/puppetversion.rb > +++ b/lib/facter/puppetversion.rb > @@ -1,10 +1,10 @@ > Facter.add(:puppetversion) do > - setcode { > + setcode do > begin > require 'puppet' > Puppet::PUPPETVERSION.to_s > rescue LoadError > nil > end > - } > + end > end > diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb > index 5449858..d90c204 100644 > --- a/lib/facter/util/ip.rb > +++ b/lib/facter/util/ip.rb > @@ -1,27 +1,27 @@ > +# A base module for collecting IP-related > +# information from all kinds of platforms. > module Facter::IPAddress > - > def self.get_interfaces > - > - int = nil > - > - output = Facter::IPAddress.get_all_interface_output() > > - # We get lots of warnings on platforms that don't get an output > - # made. > - if output > - int = output.scan(/^\w+[.:]?\d+/) > - else > - [] > - end > - > + int = nil > + > + output = Facter::IPAddress.get_all_interface_output() > + > + # We get lots of warnings on platforms that don't get an output > + # made. > + if output > + int = output.scan(/^\w+[.:]?\d+/) > + else > + [] > + end > end > > def self.get_all_interface_output > case Facter.value(:kernel) > - when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > - output = %x{/sbin/ifconfig -a} > - when 'SunOS' > - output = %x{/usr/sbin/ifconfig -a} > + when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > + output = %x{/sbin/ifconfig -a} > + when 'SunOS' > + output = %x{/usr/sbin/ifconfig -a} > end > output > end > @@ -29,9 +29,9 @@ module Facter::IPAddress > def self.get_single_interface_output(interface) > output = "" > case Facter.value(:kernel) > - when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > - output = %x{/sbin/ifconfig #{interface}} > - when 'SunOS' > + when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD' > + output = %x{/sbin/ifconfig #{interface}} > + when 'SunOS' > output = %x{/usr/sbin/ifconfig #{interface}} > end > output > @@ -43,75 +43,76 @@ module Facter::IPAddress > end > # We need ip instead of ifconfig because it will show us > # the bonding master device. > - if not FileTest.executable?("/sbin/ip") > + if not FileTest.executable?("/sbin/ip") > return nil > end > regex = /SLAVE[,>].* (bond[0-9]+)/ > - ethbond = regex.match(%x{/sbin/ip link show #{interface}}) > - if ethbond > + ethbond = regex.match(%x{/sbin/ip link show #{interface}}) > + if ethbond > device = ethbond[1] > else > device = nil > end > device > end > - > + > > def self.get_interface_value(interface, label) > - > - tmp1 = [] > + tmp1 = [] > > - case Facter.value(:kernel) > - when 'Linux' > - addr = /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > - mac = > /(?:ether|HWaddr)\s+(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > - mask = /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > - when 'OpenBSD', 'NetBSD', 'FreeBSD' > - addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > - mac = /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ > - mask = /netmask\s+(\w{10})/ > - when 'SunOS' > - addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > - mac = /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/ > - mask = /netmask\s+(\w{8})/ > - end > + # LAK:NOTE This is pretty ugly - two case statements being used for > most of the > + # logic. These should be pulled into a small dispatch table. We > don't have tests for this code, > + # though, so it's not exactly trivial to do so. > + case Facter.value(:kernel) > + when 'Linux' > + addr = /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > + mac = > /(?:ether|HWaddr)\s+(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ > + mask = /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > + when 'OpenBSD', 'NetBSD', 'FreeBSD' > + addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > + mac = /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ > + mask = /netmask\s+(\w{10})/ > + when 'SunOS' > + addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ > + mac = /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/ > + mask = /netmask\s+(\w{8})/ > + end > + > + case label > + when 'ipaddress' > + regex = addr > + when 'macaddress' > + regex = mac > + when 'netmask' > + regex = mask > + end > > - case label > - when 'ipaddress' > - regex = addr > - when 'macaddress' > - regex = mac > - when 'netmask' > - regex = mask > - end > + # Linux changes the MAC address reported via ifconfig when an > ethernet interface > + # becomes a slave of a bonding device to the master MAC address. > + # We have to dig a bit to get the original/real MAC address of the > interface. > + bonddev = get_bonding_master(interface) > + if label == 'macaddress' and bonddev > + bondinfo = IO.readlines("/proc/net/bonding/#{bonddev}") > + hwaddrre = /^Slave Interface: #{interface}\n[^\n].+?\nPermanent > HW addr: (([0-9a-fA-F]{2}:?)*)$/m > + value = hwaddrre.match(bondinfo.to_s)[1].upcase > + else > + output_int = get_single_interface_output(interface) > > - # Linux changes the MAC address reported via ifconfig when an ethernet > interface > - # becomes a slave of a bonding device to the master MAC address. > - # We have to dig a bit to get the original/real MAC address of the > interface. > - bonddev = get_bonding_master(interface) > - if label == 'macaddress' and bonddev > - bondinfo = IO.readlines("/proc/net/bonding/#{bonddev}") > - hwaddrre = /^Slave Interface: #{interface}\n[^\n].+?\nPermanent HW > addr: (([0-9a-fA-F]{2}:?)*)$/m > - value = hwaddrre.match(bondinfo.to_s)[1].upcase > - else > - output_int = get_single_interface_output(interface) > - > - if interface != "lo" && interface != "lo0" > - output_int.each { |s| > - if s =~ regex > - value = $1 > - if label == 'netmask' && Facter.value(:kernel) == "SunOS" > - value = value.scan(/../).collect do |byte| > byte.to_i(16) end.join('.') > - end > - tmp1.push(value) > - end > - } > - end > + if interface != "lo" && interface != "lo0" > + output_int.each { |s| > + if s =~ regex > + value = $1 > + if label == 'netmask' && Facter.value(:kernel) == > "SunOS" > + value = value.scan(/../).collect do |byte| > byte.to_i(16) end.join('.') > + end > + tmp1.push(value) > + end > + } > + end > > - if tmp1 > - value = tmp1.shift > - end > + if tmp1 > + value = tmp1.shift > + end > + end > end > - > - end > end > diff --git a/lib/facter/util/macosx.rb b/lib/facter/util/macosx.rb > index 1e596d8..2704a7c 100644 > --- a/lib/facter/util/macosx.rb > +++ b/lib/facter/util/macosx.rb > @@ -17,34 +17,33 @@ > ## > > module Facter::Macosx > - require 'thread' > - require 'facter/util/plist' > + require 'thread' > + require 'facter/util/plist' > > - # JJM I'd really like to dynamically generate these methods > - # by looking at the _name key of the _items dict for each _dataType > + # JJM I'd really like to dynamically generate these methods > + # by looking at the _name key of the _items dict for each _dataType > > - def self.hardware_overview > - # JJM Perhaps we should cache the XML data in a "class" level object. > - top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml > SPHardwareDataType} > - system_hardware = top_level_plist[0]['_items'][0] > - system_hardware.delete '_name' > - system_hardware > - end > + def self.hardware_overview > + # JJM Perhaps we should cache the XML data in a "class" level object. > + top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml > SPHardwareDataType} > + system_hardware = top_level_plist[0]['_items'][0] > + system_hardware.delete '_name' > + system_hardware > + end > > - # SPSoftwareDataType > - def self.os_overview > - top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml > SPSoftwareDataType} > - os_stuff = top_level_plist[0]['_items'][0] > - os_stuff.delete '_name' > - os_stuff > - end > + # SPSoftwareDataType > + def self.os_overview > + top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml > SPSoftwareDataType} > + os_stuff = top_level_plist[0]['_items'][0] > + os_stuff.delete '_name' > + os_stuff > + end > > - def self.sw_vers > - ver = Hash.new > - [ "productName", "productVersion", "buildVersion" ].each do |option| > - ver["macosx_#{option}"] = %x{sw_vers -#{option}}.strip > + def self.sw_vers > + ver = Hash.new > + [ "productName", "productVersion", "buildVersion" ].each do |option| > + ver["macosx_#{option}"] = %x{sw_vers -#{option}}.strip > + end > + ver > end > - ver > - end > end > - > diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb > index 657901d..ff12e7e 100644 > --- a/lib/facter/util/manufacturer.rb > +++ b/lib/facter/util/manufacturer.rb > @@ -42,6 +42,5 @@ module Facter::Manufacturer > end > end > end > + end > end > -end > - > diff --git a/lib/facter/util/netmask.rb b/lib/facter/util/netmask.rb > index 71696ad..dcbb795 100644 > --- a/lib/facter/util/netmask.rb > +++ b/lib/facter/util/netmask.rb > @@ -1,36 +1,34 @@ > module Facter::NetMask > - > -def self.get_netmask > + def self.get_netmask > netmask = nil; > ipregex = %r{(\d{1,3}\.){3}\d{1,3}} > > ops = nil > case Facter.value(:kernel) > - when 'Linux' > - ops = { > - :ifconfig => '/sbin/ifconfig', > - :regex => %r{\s+ inet\saddr: > #{Facter.ipaddress} .*? Mask: (#{ipregex})}x, > - :munge => nil, > - } > - when 'SunOS' > - ops = { > - :ifconfig => '/usr/sbin/ifconfig -a', > - :regex => %r{\s+ inet\s+? > #{Facter.ipaddress} \+? mask (\w{8})}x, > - :munge => Proc.new { |mask| > mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') } > - } > + when 'Linux' > + ops = { > + :ifconfig => '/sbin/ifconfig', > + :regex => %r{\s+ inet\saddr: #{Facter.ipaddress} .*? Mask: > (#{ipregex})}x, > + :munge => nil, > + } > + when 'SunOS' > + ops = { > + :ifconfig => '/usr/sbin/ifconfig -a', > + :regex => %r{\s+ inet\s+? #{Facter.ipaddress} \+? mask > (\w{8})}x, > + :munge => Proc.new { |mask| mask.scan(/../).collect do > |byte| byte.to_i(16) end.join('.') } > + } > end > > %x{#{ops[:ifconfig]}}.split(/\n/).collect do |line| > - matches = line.match(ops[:regex]) > - if !matches.nil? > - if ops[:munge].nil? > - netmask = matches[1] > - else > - netmask = ops[:munge].call(matches[1]) > - end > + matches = line.match(ops[:regex]) > + if !matches.nil? > + if ops[:munge].nil? > + netmask = matches[1] > + else > + netmask = ops[:munge].call(matches[1]) > end > + end > end > netmask > -end > - > + end > end > diff --git a/lib/facter/util/plist.rb b/lib/facter/util/plist.rb > index 32e9e2b..54f5248 100644 > --- a/lib/facter/util/plist.rb > +++ b/lib/facter/util/plist.rb > @@ -18,7 +18,7 @@ require 'facter/util/plist/generator' > require 'facter/util/plist/parser' > > module Plist > - VERSION = '3.0.0' > + VERSION = '3.0.0' > end > > # $Id: plist.rb 1781 2006-10-16 01:01:35Z luke $ > diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb > index db8dc33..7c1ee91 100644 > --- a/lib/facter/virtual.rb > +++ b/lib/facter/virtual.rb > @@ -1,76 +1,75 @@ > Facter.add("virtual") do > - confine :kernel => %w{Linux FreeBSD OpenBSD SunOS} > - > - result = "physical" > - > - setcode do > + confine :kernel => %w{Linux FreeBSD OpenBSD SunOS} > + > + result = "physical" > + > + setcode do > + if FileTest.exists?("/proc/user_beancounters") > + # openvz. can be hardware node or virtual environment > + # read the init process' status file, it has laxer permissions > + # than /proc/user_beancounters (so this won't fail as non-root) > + txt = File.read("/proc/1/status") > + if txt =~ /^envID:[[:blank:]]+0$/mi > + result = "openvzhn" > + else > + result = "openvzve" > + end > + end > > - if FileTest.exists?("/proc/user_beancounters") > - # openvz. can be hardware node or virtual environment > - # read the init process' status file, it has laxer permissions > - # than /proc/user_beancounters (so this won't fail as non-root) > - txt = File.read("/proc/1/status") > - if txt =~ /^envID:[[:blank:]]+0$/mi > - result = "openvzhn" > - else > - result = "openvzve" > - end > - end > + if FileTest.exists?("/proc/xen/capabilities") && > FileTest.readable?("/proc/xen/capabilities") > + txt = File.read("/proc/xen/capabilities") > + if txt =~ /control_d/i > + result = "xen0" > + else > + result = "xenu" > + end > + end > > - if FileTest.exists?("/proc/xen/capabilities") && > FileTest.readable?("/proc/xen/capabilities") > - txt = File.read("/proc/xen/capabilities") > - if txt =~ /control_d/i > - result = "xen0" > - else > - result = "xenu" > - end > - end > + if result == "physical" > + path = %x{which lspci 2> /dev/null}.chomp > + if path !~ /no lspci/ > + output = %x{#{path}} > + output.each do |p| > + # --- look for the vmware video card to determine if it > is virtual => vmware. > + # --- 00:0f.0 VGA compatible controller: VMware Inc > [VMware SVGA II] PCI Display Adapter > + result = "vmware" if p =~ /VM[wW]are/ > + end > + else > + path = %x{which dmidecode 2> /dev/null}.chomp > + if path !~ /no dmidecode/ > + output = %x{#{path}} > + output.each do |pd| > + result = "vmware" if pd =~ /VMware|Parallels/ > + end > + else > + path = %x{which prtdiag 2> /dev/null}.chomp > + if path !~ /no prtdiag/ > + output = %x{#{path}} > + output.each do |pd| > + result = "vmware" if pd =~ /VMware|Parallels/ > + end > + end > + end > + end > + end > > - if result == "physical" > - path = %x{which lspci 2> /dev/null}.chomp > - if path !~ /no lspci/ > - output = %x{#{path}} > - output.each {|p| > - # --- look for the vmware video card to determine if it is virtual > => vmware. > - # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware > SVGA II] PCI Display Adapter > - result = "vmware" if p =~ /VM[wW]are/ > - } > - else > - path = %x{which dmidecode 2> /dev/null}.chomp > - if path !~ /no dmidecode/ > - output = %x{#{path}} > - output.each {|pd| > - result = "vmware" if pd =~ /VMware|Parallels/ > - } > - else > - path = %x{which prtdiag 2> /dev/null}.chomp > - if path !~ /no prtdiag/ > - output = %x{#{path}} > - output.each {|pd| > - result = "vmware" if pd =~ /VMware|Parallels/ > - } > - end > - end > - end > - end > + # VMware server 1.0.3 rpm places vmware-vmx in this place, other > versions or platforms may not. > + if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx") > + result = "vmware_server" > + end > > - # VMware server 1.0.3 rpm places vmware-vmx in this place, other > versions or platforms may not. > - if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx") > - result = "vmware_server" > - end > + mountexists = system "which mount > /dev/null 2>&1" > + if $?.exitstatus == 0 > + output = %x{mount} > + output.each do |p| > + result = "vserver" if p =~ /\/dev\/hdv1/ > + end > + end > > - mountexists = system "which mount > /dev/null 2>&1" > - if $?.exitstatus == 0 > - output = %x{mount} > - output.each {|p| > - result = "vserver" if p =~ /\/dev\/hdv1/ > - } > - end > + if FileTest.directory?('/proc/virtual') > + result = "vserver_host" > + end > > - if FileTest.directory?('/proc/virtual') > - result = "vserver_host" > + result > end > - > - result > - end > end > diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb > index e27531e..059bdd1 100644 > --- a/spec/unit/util/ip.rb > +++ b/spec/unit/util/ip.rb > @@ -5,7 +5,6 @@ require File.dirname(__FILE__) + '/../../spec_helper' > require 'facter/util/ip' > > describe Facter::IPAddress do > - > it "should return a list of interfaces" do > Facter::IPAddress.should respond_to(:get_interfaces) > end > @@ -23,7 +22,7 @@ describe Facter::IPAddress do > end > > it "should return a value for a specific interface" do > - Facter::IPAddress.should respond_to(:get_interface_value) > + Facter::IPAddress.should respond_to(:get_interface_value) > end > > it "should return a human readable netmask on Solaris" do > @@ -35,6 +34,4 @@ describe Facter::IPAddress do > > Facter::IPAddress.get_interface_value("e1000g0", "netmask").should == > "255.255.255.0" > end > - > end > - > -- > 1.5.6.5 > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
