summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction.rb10
-rw-r--r--lib/puppet/transaction/resource_harness.rb22
-rw-r--r--lib/puppet/type.rb43
3 files changed, 26 insertions, 49 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index e57fe5648..d2dbf7a1c 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -318,12 +318,11 @@ class Puppet::Transaction
# Is the resource currently scheduled?
def scheduled?(resource)
- self.ignoreschedules or resource.scheduled?
+ self.ignoreschedules or resource_harness.scheduled?(resource)
end
# Should this resource be skipped?
def skip?(resource)
- skip = false
if missing_tags?(resource)
resource.debug "Not tagged with %s" % tags.join(", ")
elsif ! scheduled?(resource)
@@ -356,11 +355,10 @@ class Puppet::Transaction
# Is this resource tagged appropriately?
def missing_tags?(resource)
- not appropriately_tagged?(resource)
- end
+ return false if ignore_tags?
+ return false if tags.empty?
- def appropriately_tagged?(resource)
- self.ignore_tags? or tags.empty? or resource.tagged?(*tags)
+ not resource.tagged?(*tags)
end
end
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)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index dde342880..4b5a65e1e 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1669,45 +1669,6 @@ class Type
end.flatten.reject { |r| r.nil? }
end
- ###############################
- # All of the scheduling code.
-
- # Look up the schedule and set it appropriately. This is done after
- # the instantiation phase, so that the schedule can be anywhere in the
- # file.
- def schedule
- unless catalog
- warning "Cannot schedule without a schedule-containing catalog"
- return nil
- end
-
- unless defined? @schedule
- if name = self[:schedule]
- if sched = catalog.resource(:schedule, name)
- @schedule = sched
- else
- self.fail "Could not find schedule %s" % name
- end
- else
- @schedule = nil
- end
- end
- @schedule
- end
-
- # Check whether we are scheduled to run right now or not.
- def scheduled?
- return true if Puppet[:ignoreschedules]
- return true unless schedule = self.schedule
-
- # 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?(self.cached(:checked).to_i)
- end
-
# Define the initial list of tags.
def tags=(list)
tag(self.class.name)
@@ -1895,10 +1856,6 @@ class Type
# Set up all of our autorequires.
def finish
- # Scheduling has to be done when the whole config is instantiated, so
- # that file order doesn't matter in finding them.
- self.schedule
-
# Make sure all of our relationships are valid. Again, must be done
# when the entire catalog is instantiated.
self.class.relationship_params.collect do |klass|