diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-11-01 13:46:21 -0700 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-11-01 13:46:21 -0700 |
| commit | 3d32fe836eefac1974e00b2763322c998b452ddb (patch) | |
| tree | 7db8f8f29f3c20235940374f7f6a68f6d92a247b /lib/puppet | |
| parent | 1f80cc6ed0caadd82171b4fb9fbe117142cd535e (diff) | |
| download | puppet-3d32fe836eefac1974e00b2763322c998b452ddb.tar.gz puppet-3d32fe836eefac1974e00b2763322c998b452ddb.tar.xz puppet-3d32fe836eefac1974e00b2763322c998b452ddb.zip | |
(#5166) Inventory service is now searchable by timestamp.
It is now possible to specify queries in the form “meta.timestamp.xx”
where xx is eq,ne,gt,lt,ge,le when searching the inventory service.
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/indirector/inventory/yaml.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/puppet/indirector/inventory/yaml.rb b/lib/puppet/indirector/inventory/yaml.rb index 5acbef60c..fe3489a95 100644 --- a/lib/puppet/indirector/inventory/yaml.rb +++ b/lib/puppet/indirector/inventory/yaml.rb @@ -33,6 +33,11 @@ class Puppet::Node::Inventory::Yaml < Puppet::Indirector::Yaml def node_matches_option?(type, name, operator, value, facts) case type + when "meta" + case name + when "timestamp" + compare_timestamp(operator, facts.timestamp, Time.parse(value)) + end when "facts" compare_facts(operator, facts.values[name], value) end @@ -56,4 +61,21 @@ class Puppet::Node::Inventory::Yaml < Puppet::Indirector::Yaml value1.to_s != value2.to_s end end + + def compare_timestamp(operator, value1, value2) + case operator + when "eq" + value1 == value2 + when "le" + value1 <= value2 + when "ge" + value1 >= value2 + when "lt" + value1 < value2 + when "gt" + value1 > value2 + when "ne" + value1 != value2 + end + end end |
