@api private
Used mostly for scheduling and auditing at this point.
# File lib/puppet/transaction/resource_harness.rb, line 63 def cache(resource, name, value) Puppet::Util::Storage.cache(resource)[name] = value end
Used mostly for scheduling and auditing at this point.
# File lib/puppet/transaction/resource_harness.rb, line 58 def cached(resource, name) Puppet::Util::Storage.cache(resource)[name] end
# File lib/puppet/transaction/resource_harness.rb, line 15 def evaluate(resource) status = Puppet::Resource::Status.new(resource) begin context = ResourceApplicationContext.from_resource(resource, status) perform_changes(resource, context) if status.changed? && ! resource.noop? cache(resource, :synced, Time.now) resource.flush if resource.respond_to?(:flush) end rescue => detail status.failed_because(detail) ensure status.evaluation_time = Time.now - status.time end status end
# File lib/puppet/transaction/resource_harness.rb, line 47 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
# File lib/puppet/transaction/resource_harness.rb, line 35 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). schedule.match?(cached(resource, :checked).to_i) end
# File lib/puppet/transaction/resource_harness.rb, line 11 def initialize(transaction) @transaction = transaction end