Class: Puppet::Resource::Status
- Includes:
- Util::Logging, Util::Tagging
- Defined in:
- lib/vendor/puppet/resource/status.rb
Constant Summary collapse
- STATES =
[:skipped, :failed, :failed_to_restart, :restarted, :changed, :out_of_sync, :scheduled]
- YAML_ATTRIBUTES =
%w{@resource @file @line @evaluation_time @change_count @out_of_sync_count @tags @time @events @out_of_sync @changed @resource_type @title @skipped @failed}
Instance Attribute Summary collapse
-
#change_count ⇒ Object
readonly
Returns the value of attribute change_count.
-
#current_values ⇒ Object
Returns the value of attribute current_values.
-
#default_log_level ⇒ Object
readonly
Returns the value of attribute default_log_level.
-
#evaluation_time ⇒ Object
Returns the value of attribute evaluation_time.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#node ⇒ Object
Returns the value of attribute node.
-
#out_of_sync_count ⇒ Object
readonly
Returns the value of attribute out_of_sync_count.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
-
#source_description ⇒ Object
readonly
Returns the value of attribute source_description.
-
#status ⇒ Object
Returns the value of attribute status.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #<<(event) ⇒ Object
- #add_event(event) ⇒ Object
- #events ⇒ Object
-
#initialize(resource) ⇒ Status
constructor
A new instance of Status.
- #to_yaml_properties ⇒ Object
Methods included from Util::Logging
#clear_deprecation_warnings, #deprecation_warning, #send_log
Methods included from Util::Tagging
Constructor Details
#initialize(resource) ⇒ Status
Returns a new instance of Status.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/vendor/puppet/resource/status.rb', line 47 def initialize(resource) @source_description = resource.path @resource = resource.to_s @change_count = 0 @out_of_sync_count = 0 @changed = false @out_of_sync = false @skipped = false @failed = false [:file, :line].each do |attr| send(attr.to_s + "=", resource.send(attr)) end tag(*resource.) @time = Time.now @events = [] @resource_type = resource.type.to_s.capitalize @title = resource.title end |
Instance Attribute Details
#change_count ⇒ Object (readonly)
Returns the value of attribute change_count.
13 14 15 |
# File 'lib/vendor/puppet/resource/status.rb', line 13 def change_count @change_count end |
#current_values ⇒ Object
Returns the value of attribute current_values.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def current_values @current_values end |
#default_log_level ⇒ Object (readonly)
Returns the value of attribute default_log_level.
12 13 14 |
# File 'lib/vendor/puppet/resource/status.rb', line 12 def default_log_level @default_log_level end |
#evaluation_time ⇒ Object
Returns the value of attribute evaluation_time.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def evaluation_time @evaluation_time end |
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def line @line end |
#node ⇒ Object
Returns the value of attribute node.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def node @node end |
#out_of_sync_count ⇒ Object (readonly)
Returns the value of attribute out_of_sync_count.
13 14 15 |
# File 'lib/vendor/puppet/resource/status.rb', line 13 def out_of_sync_count @out_of_sync_count end |
#resource ⇒ Object
Returns the value of attribute resource.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def resource @resource end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
13 14 15 |
# File 'lib/vendor/puppet/resource/status.rb', line 13 def resource_type @resource_type end |
#source_description ⇒ Object (readonly)
Returns the value of attribute source_description.
12 13 14 |
# File 'lib/vendor/puppet/resource/status.rb', line 12 def source_description @source_description end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/vendor/puppet/resource/status.rb', line 7 def status @status end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
12 13 14 |
# File 'lib/vendor/puppet/resource/status.rb', line 12 def time @time end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
13 14 15 |
# File 'lib/vendor/puppet/resource/status.rb', line 13 def title @title end |
Instance Method Details
#<<(event) ⇒ Object
24 25 26 27 |
# File 'lib/vendor/puppet/resource/status.rb', line 24 def <<(event) add_event(event) self end |
#add_event(event) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vendor/puppet/resource/status.rb', line 29 def add_event(event) @events << event if event.status == 'failure' self.failed = true elsif event.status == 'success' @change_count += 1 @changed = true end if event.status != 'audit' @out_of_sync_count += 1 @out_of_sync = true end end |
#events ⇒ Object
43 44 45 |
# File 'lib/vendor/puppet/resource/status.rb', line 43 def events @events end |
#to_yaml_properties ⇒ Object
68 69 70 |
# File 'lib/vendor/puppet/resource/status.rb', line 68 def to_yaml_properties YAML_ATTRIBUTES & instance_variables end |