summaryrefslogtreecommitdiffstats
path: root/lib/puppet/transaction
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-06-10 20:31:34 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit0b95a8528e554df07efe970c9ecfc34535d17c92 (patch)
tree42ac163a4ab9497e3fb9f676365c1b3da35c5c7d /lib/puppet/transaction
parent4627b8fe11dc14bf42e98b84121b885df73c709e (diff)
downloadpuppet-0b95a8528e554df07efe970c9ecfc34535d17c92.tar.gz
puppet-0b95a8528e554df07efe970c9ecfc34535d17c92.tar.xz
puppet-0b95a8528e554df07efe970c9ecfc34535d17c92.zip
Working #3139 - scheduling moved to resource harness
We previously had the schedule checking code in Puppet::Type, but it's more of a transactional function, and in order to do proper auditing in the transactional area, we need the cache checking done there. Scheduling is one of the few functions that actually uses cached data currently. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib/puppet/transaction')
-rw-r--r--lib/puppet/transaction/resource_harness.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb
index 76148e69f..05e569b92 100644
--- a/lib/puppet/transaction/resource_harness.rb
+++ b/lib/puppet/transaction/resource_harness.rb
@@ -73,6 +73,28 @@ class Puppet::Transaction::ResourceHarness
@transaction = transaction
end
+ def scheduled?(resource)
+ return true if Puppet[:ignoreschedules]
+ return true unless schedule = schedule(resource)
+
+ # We use 'checked' here instead of 'synced' because otherwise we'll
+ # end up checking most resources most times, because they will generally
+ # have been synced a long time ago (e.g., a file only gets updated
+ # once a month on the server and its schedule is daily; the last sync time
+ # will have been a month ago, so we'd end up checking every run).
+ return schedule.match?(resource.cached(:checked).to_i)
+ end
+
+ def schedule(resource)
+ unless resource.catalog
+ resource.warning "Cannot schedule without a schedule-containing catalog"
+ return nil
+ end
+
+ return nil unless name = resource[:schedule]
+ resource.catalog.resource(:schedule, name) || resource.fail("Could not find schedule #{name}")
+ end
+
private
def absent_and_not_being_created?(current, param)