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.

API:

  • private

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.

API:

  • private

[: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.

API:

  • private

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

API:

  • private

%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_msgpack, #to_pson

Methods included from Util::Logging

#clear_deprecation_warnings, #deprecation_warning, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning

Methods included from Util::Tagging

#raw_tagged?, #tag, #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.

API:

  • private



33
34
35
36
37
38
# File 'lib/puppet/transaction/event.rb', line 33

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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



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

.from_pson(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.

API:

  • private



28
29
30
31
# File 'lib/puppet/transaction/event.rb', line 28

def self.from_pson(data)
  Puppet.deprecation_warning("from_pson is being removed in favour of from_data_hash.")
  self.from_data_hash(data)
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.

API:

  • private



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet/transaction/event.rb', line 40

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

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

API:

  • private



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

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.

API:

  • private



71
72
73
74
75
76
# File 'lib/puppet/transaction/event.rb', line 71

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.

API:

  • private



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

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:

API:

  • private



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

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.

API:

  • private



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/puppet/transaction/event.rb', line 53

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.

API:

  • private



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

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.

API:

  • private



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

def to_yaml_properties
  YAML_ATTRIBUTES & super
end