Class: Puppet::Transaction::Event Private

Inherits:
Object
  • Object
show all
Includes:
Network::FormatSupport, Util::Logging, Util::MethodHelper, Util::Tagging
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]
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}.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::Tagging

Util::Tagging::ValidTagRegex

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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!

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
# File 'lib/puppet/transaction/event.rb', line 28

def initialize(options = {})
  @audited = false

  set_options(options)
  @time = Time.now
end

Instance Attribute Details

#default_log_levelObject (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

#timeObject

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

#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.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/puppet/transaction/event.rb', line 35

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
end

#inspectObject

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.



86
87
88
# File 'lib/puppet/transaction/event.rb', line 86

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.



62
63
64
# File 'lib/puppet/transaction/event.rb', line 62

def property=(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.



66
67
68
69
70
71
# File 'lib/puppet/transaction/event.rb', line 66

def resource=(res)
  if res.respond_to?(:[]) and level = res[:loglevel]
    @default_log_level = level
  end
  @resource = res.to_s
end

#send_logObject

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
# File 'lib/puppet/transaction/event.rb', line 73

def send_log
  super(log_level, message)
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.

Raises:

  • (ArgumentError)


77
78
79
80
# File 'lib/puppet/transaction/event.rb', line 77

def status=(value)
  raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value)
  @status = value
end

#to_data_hashObject

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.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/puppet/transaction/event.rb', line 48

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),
  }
end

#to_sObject

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.



82
83
84
# File 'lib/puppet/transaction/event.rb', line 82

def to_s
  message
end

#to_yaml_propertiesObject

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.



90
91
92
# File 'lib/puppet/transaction/event.rb', line 90

def to_yaml_properties
  YAML_ATTRIBUTES & super
end