Class: Puppet::Transaction::ResourceHarness Private
- Extended by:
- Forwardable
- Defined in:
- lib/puppet/transaction/resource_harness.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: ResourceApplicationContext
Constant Summary collapse
- NO_ACTION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Object.new
Instance Attribute Summary collapse
- #transaction ⇒ Object readonly private
Instance Method Summary collapse
-
#cache(resource, name, value) ⇒ Object
private
Used mostly for scheduling and auditing at this point.
-
#cached(resource, name) ⇒ Object
private
Used mostly for scheduling and auditing at this point.
- #evaluate(resource) ⇒ Object private
-
#initialize(transaction) ⇒ ResourceHarness
constructor
private
A new instance of ResourceHarness.
- #schedule(resource) ⇒ Object private
- #scheduled?(resource) ⇒ Boolean private
Constructor Details
#initialize(transaction) ⇒ ResourceHarness
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ResourceHarness.
13 14 15 16 |
# File 'lib/puppet/transaction/resource_harness.rb', line 13 def initialize(transaction) @transaction = transaction @persistence = transaction.persistence end |
Instance Attribute Details
#transaction ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/puppet/transaction/resource_harness.rb', line 11 def transaction @transaction end |
Instance Method Details
#cache(resource, name, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used mostly for scheduling and auditing at this point.
70 71 72 |
# File 'lib/puppet/transaction/resource_harness.rb', line 70 def cache(resource, name, value) Puppet::Util::Storage.cache(resource)[name] = value end |
#cached(resource, name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used mostly for scheduling and auditing at this point.
65 66 67 |
# File 'lib/puppet/transaction/resource_harness.rb', line 65 def cached(resource, name) Puppet::Util::Storage.cache(resource)[name] end |
#evaluate(resource) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet/transaction/resource_harness.rb', line 18 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 |
#schedule(resource) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/puppet/transaction/resource_harness.rb', line 52 def schedule(resource) unless resource.catalog resource.warning _("Cannot schedule without a schedule-containing catalog") return nil end name = resource[:schedule] return nil unless name resource.catalog.resource(:schedule, name) || resource.fail(_("Could not find schedule %{name}") % { name: name }) end |
#scheduled?(resource) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/puppet/transaction/resource_harness.rb', line 38 def scheduled?(resource) return true if Puppet[:ignoreschedules] schedule = schedule(resource) return true unless 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). schedule.match?(cached(resource, :checked).to_i) end |