Class: Puppet::Transaction::Event Private
- Defined in:
- lib/puppet/transaction/event.rb
Overview
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.
A simple struct for storing what happens on the system.
Constant Summary collapse
- ATTRIBUTES =
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.
[:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited, :invalidate_refreshes, :redacted, :corrective_change]
- YAML_ATTRIBUTES =
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.
%w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time @redacted @corrective_change}.map(&:to_sym)
- EVENT_STATUSES =
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.
%w{noop success failure audit}
Constants included from Util::Logging
Util::Logging::FILE_AND_LINE, Util::Logging::FILE_NO_LINE, Util::Logging::MM, Util::Logging::NO_FILE_LINE
Constants included from Util::Tagging
Instance Attribute Summary collapse
- #default_log_level ⇒ Object readonly private
- #time ⇒ Object private
Class Method Summary collapse
- .from_data_hash(data) ⇒ Object private
Instance Method Summary collapse
-
#calculate_corrective_change(old_system_value) ⇒ bool
private
Calculate and set the corrective_change parameter, based on the old_system_value of the property.
-
#initialize(options = {}) ⇒ Event
constructor
private
A new instance of Event.
- #initialize_from_hash(data) ⇒ Object private
- #inspect ⇒ Object private
- #property=(prop) ⇒ Object private
- #resource=(res) ⇒ Object private
- #send_log ⇒ Object private
- #status=(value) ⇒ Object private
- #to_data_hash ⇒ Object private
- #to_s ⇒ Object private
- #to_yaml_properties ⇒ Object private
Methods included from Network::FormatSupport
included, #mime, #render, #support_format?, #to_json, #to_msgpack, #to_pson
Methods included from Util::Logging
#clear_deprecation_warnings, #debug, #deprecation_warning, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning, setup_facter_logging!, #warn_once
Methods included from Util::Tagging
#merge_into, #merge_tags, #raw_tagged?, #set_tags, #tag, #tag_if_valid, #tagged?, #tags, #tags=
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Constructor Details
#initialize(options = {}) ⇒ Event
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 Event.
28 29 30 31 32 33 34 35 |
# File 'lib/puppet/transaction/event.rb', line 28 def initialize( = {}) @audited = false @redacted = false @corrective_change = false () @time = Time.now end |
Instance Attribute Details
#default_log_level ⇒ 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.
18 19 20 |
# File 'lib/puppet/transaction/event.rb', line 18 def default_log_level @default_log_level end |
#time ⇒ 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.
17 18 19 |
# File 'lib/puppet/transaction/event.rb', line 17 def time @time end |
Class Method Details
.from_data_hash(data) ⇒ 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.
22 23 24 25 26 |
# File 'lib/puppet/transaction/event.rb', line 22 def self.from_data_hash(data) obj = self.allocate obj.initialize_from_hash(data) obj end |
Instance Method Details
#calculate_corrective_change(old_system_value) ⇒ bool
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.
Calculate and set the corrective_change parameter, based on the old_system_value of the property.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/puppet/transaction/event.rb', line 104 def calculate_corrective_change(old_system_value) # Only idempotent properties, and cases where we have an old system_value # are corrective_changes. if @property_instance.idempotent? && !@property_instance.sensitive && !old_system_value.nil? # If the values aren't insync, we have confirmed a corrective_change insync = @property_instance.insync_values?(old_system_value, previous_value) # Preserve the nil state, but flip true/false @corrective_change = insync.nil? ? nil : !insync else @corrective_change = false end end |
#initialize_from_hash(data) ⇒ 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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/puppet/transaction/event.rb', line 37 def initialize_from_hash(data) @audited = data['audited'] @property = data['property'] @previous_value = data['previous_value'] @desired_value = data['desired_value'] @historical_value = data['historical_value'] @message = data['message'] @name = data['name'].intern if data['name'] @status = data['status'] @time = data['time'] @time = Time.parse(@time) if @time.is_a? String @redacted = data.fetch('redacted', false) @corrective_change = data['corrective_change'] end |
#inspect ⇒ 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.
93 94 95 |
# File 'lib/puppet/transaction/event.rb', line 93 def inspect %Q(#<#{self.class.name} @name="#{@name.inspect}" @message="#{@message.inspect}">) end |
#property=(prop) ⇒ 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.
68 69 70 71 |
# File 'lib/puppet/transaction/event.rb', line 68 def property=(prop) @property_instance = prop @property = prop.to_s end |
#resource=(res) ⇒ 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.
73 74 75 76 77 78 |
# File 'lib/puppet/transaction/event.rb', line 73 def resource=(res) if res.respond_to?(:[]) and level = res[:loglevel] @default_log_level = level end @resource = res.to_s end |
#send_log ⇒ 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.
80 81 82 |
# File 'lib/puppet/transaction/event.rb', line 80 def send_log super(log_level, ) end |
#status=(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.
84 85 86 87 |
# File 'lib/puppet/transaction/event.rb', line 84 def status=(value) raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value) @status = value end |
#to_data_hash ⇒ 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 63 64 65 66 |
# File 'lib/puppet/transaction/event.rb', line 52 def to_data_hash { 'audited' => @audited, 'property' => @property, 'previous_value' => @previous_value, 'desired_value' => @desired_value, 'historical_value' => @historical_value, 'message' => @message, 'name' => @name, 'status' => @status, 'time' => @time.iso8601(9), 'redacted' => @redacted, 'corrective_change' => @corrective_change, } end |
#to_s ⇒ 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.
89 90 91 |
# File 'lib/puppet/transaction/event.rb', line 89 def to_s end |
#to_yaml_properties ⇒ 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.
97 98 99 |
# File 'lib/puppet/transaction/event.rb', line 97 def to_yaml_properties YAML_ATTRIBUTES & super end |