[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Paul Berry paul at puppetlabs.com
Tue May 10 07:59:47 UTC 2011


The following commit has been merged in the experimental branch:
commit 6c116015ce4a9e6e7de392047f38b7a9e911bc0c
Author: Paul Berry <paul at puppetlabs.com>
Date:   Mon Nov 1 13:26:41 2010 -0700

    Refactor Puppet::Node::Inventory::Yaml in preparation for adding freshness

diff --git a/lib/puppet/indirector/inventory/yaml.rb b/lib/puppet/indirector/inventory/yaml.rb
index c6b1a14..5acbef6 100644
--- a/lib/puppet/indirector/inventory/yaml.rb
+++ b/lib/puppet/indirector/inventory/yaml.rb
@@ -15,23 +15,7 @@ class Puppet::Node::Inventory::Yaml < Puppet::Indirector::Yaml
       type, name, operator = key.to_s.split(".")
       operator ||= 'eq'
 
-      next unless type == "facts"
-      return false unless facts.values[name]
-
-      return false unless case operator
-      when "eq"
-        facts.values[name].to_s == value.to_s
-      when "le"
-        facts.values[name].to_f <= value.to_f
-      when "ge"
-        facts.values[name].to_f >= value.to_f
-      when "lt"
-        facts.values[name].to_f < value.to_f
-      when "gt"
-        facts.values[name].to_f > value.to_f
-      when "ne"
-        facts.values[name].to_s != value.to_s
-      end
+      return false unless node_matches_option?(type, name, operator, value, facts)
     end
     return true
   end
@@ -44,4 +28,32 @@ class Puppet::Node::Inventory::Yaml < Puppet::Indirector::Yaml
     end
     node_names
   end
+
+  private
+
+  def node_matches_option?(type, name, operator, value, facts)
+    case type
+    when "facts"
+      compare_facts(operator, facts.values[name], value)
+    end
+  end
+
+  def compare_facts(operator, value1, value2)
+    return false unless value1
+
+    case operator
+    when "eq"
+      value1.to_s == value2.to_s
+    when "le"
+      value1.to_f <= value2.to_f
+    when "ge"
+      value1.to_f >= value2.to_f
+    when "lt"
+      value1.to_f < value2.to_f
+    when "gt"
+      value1.to_f > value2.to_f
+    when "ne"
+      value1.to_s != value2.to_s
+    end
+  end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list