diff options
Diffstat (limited to 'lib/facter/util')
-rw-r--r-- | lib/facter/util/fact.rb | 4 | ||||
-rw-r--r-- | lib/facter/util/loader.rb | 1 | ||||
-rw-r--r-- | lib/facter/util/macosx.rb | 11 | ||||
-rw-r--r-- | lib/facter/util/memory.rb | 14 | ||||
-rw-r--r-- | lib/facter/util/resolution.rb | 15 | ||||
-rw-r--r-- | lib/facter/util/virtual.rb | 2 |
6 files changed, 16 insertions, 31 deletions
diff --git a/lib/facter/util/fact.rb b/lib/facter/util/fact.rb index e78ed97..935b3c1 100644 --- a/lib/facter/util/fact.rb +++ b/lib/facter/util/fact.rb @@ -41,9 +41,7 @@ class Facter::Util::Fact # Immediately sort the resolutions, so that we always have # a sorted list for looking up values. - # We always want to look them up in the order of number of - # confines, so the most restricted resolution always wins. - @resolves.sort! { |a, b| b.length <=> a.length } + @resolves.sort! { |a, b| b.weight <=> a.weight } return resolve end diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb index 2d2d9e8..a52012c 100644 --- a/lib/facter/util/loader.rb +++ b/lib/facter/util/loader.rb @@ -90,6 +90,7 @@ class Facter::Util::Loader next if fact and env_name != fact Facter.add($1) do + has_weight 1_000_000 setcode { value } end diff --git a/lib/facter/util/macosx.rb b/lib/facter/util/macosx.rb index 6754f18..cc9b2df 100644 --- a/lib/facter/util/macosx.rb +++ b/lib/facter/util/macosx.rb @@ -4,17 +4,6 @@ ## Copyright (C) 2007 Jeff McCune ## Author: Jeff McCune <jeff.mccune@northstarlabs.net> ## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation (version 2 of the License) -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA -## module Facter::Util::Macosx require 'thread' diff --git a/lib/facter/util/memory.rb b/lib/facter/util/memory.rb index 029b117..d49079d 100644 --- a/lib/facter/util/memory.rb +++ b/lib/facter/util/memory.rb @@ -1,17 +1,6 @@ ## memory.rb ## Support module for memory related facts ## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation (version 2 of the License) -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA -## module Facter::Memory require 'thread' @@ -75,7 +64,7 @@ module Facter::Memory memspecfree = 0 vmstats = Facter::Util::Resolution.exec('vm_stat') - vmstats.each do |vmline| + vmstats.each_line do |vmline| case when vmline =~ /page\ssize\sof\s(\d+)\sbytes/ pagesize = $1.to_i @@ -94,4 +83,3 @@ module Facter::Memory end end end - diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb index 4a99c35..d82fab2 100644 --- a/lib/facter/util/resolution.rb +++ b/lib/facter/util/resolution.rb @@ -85,17 +85,26 @@ class Facter::Util::Resolution end end + def has_weight(weight) + @weight = weight + end + # Create a new resolution mechanism. def initialize(name) @name = name @confines = [] @value = nil @timeout = 0 + @weight = nil end - # Return the number of confines. - def length - @confines.length + # Return the importance of this resolution. + def weight + if @weight + @weight + else + @confines.length + end end # We need this as a getter for 'timeout', because some versions diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb index 4355451..8bdde16 100644 --- a/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb @@ -1,6 +1,6 @@ module Facter::Util::Virtual def self.openvz? - FileTest.directory?("/proc/vz") + FileTest.directory?("/proc/vz") and FileTest.exists?( '/proc/vz/veinfo' ) end def self.openvz_type |