Class: Chef::Audit::AuditReporter
Constant Summary
collapse
- PROTOCOL_VERSION =
'0.1.1'
Instance Method Summary
collapse
#attribute_file_load_failed, #attribute_file_loaded, #attribute_load_complete, #attribute_load_start, #converge_complete, #converge_failed, #converge_start, #cookbook_clean_complete, #cookbook_clean_start, #cookbook_resolution_complete, #cookbook_resolution_failed, #cookbook_resolution_start, #cookbook_sync_complete, #cookbook_sync_failed, #cookbook_sync_start, #definition_file_load_failed, #definition_file_loaded, #definition_load_complete, #definition_load_start, #handler_executed, #handlers_completed, #handlers_start, #library_file_load_failed, #library_file_loaded, #library_load_complete, #library_load_start, #lwrp_file_load_failed, #lwrp_file_loaded, #lwrp_load_complete, #lwrp_load_start, #msg, #node_load_completed, #node_load_failed, #node_load_start, #ohai_completed, #provider_requirement_failed, #recipe_file_load_failed, #recipe_file_loaded, #recipe_load_complete, #recipe_load_start, #recipe_not_found, #registration_completed, #registration_failed, #registration_start, #removed_cookbook_file, #resource_action_start, #resource_bypassed, #resource_completed, #resource_current_state_load_bypassed, #resource_current_state_loaded, #resource_failed, #resource_failed_retriable, #resource_skipped, #resource_up_to_date, #resource_update_applied, #resource_updated, #run_list_expand_failed, #run_start, #run_started, #skipping_registration, #stream_closed, #stream_opened, #stream_output, #synchronized_cookbook, #updated_cookbook_file, #whyrun_assumption
Constructor Details
#initialize(rest_client) ⇒ AuditReporter
33
34
35
36
37
|
# File 'lib/chef/audit/audit_reporter.rb', line 33
def initialize(rest_client)
@rest_client = rest_client
@ordered_control_groups = Hash.new
end
|
Instance Method Details
#audit_phase_complete ⇒ Object
49
50
51
52
53
54
|
# File 'lib/chef/audit/audit_reporter.rb', line 49
def audit_phase_complete
Chef::Log.debug("Audit Reporter completed successfully without errors.")
ordered_control_groups.each do |name, control_group|
audit_data.add_control_group(control_group)
end
end
|
#audit_phase_failed(error) ⇒ Object
If the audit phase failed, its because there was some kind of error in the framework that runs tests - normal errors are interpreted as EXAMPLE failures and captured. We still want to send available audit information to the server so we process the known control groups.
60
61
62
63
64
65
66
|
# File 'lib/chef/audit/audit_reporter.rb', line 60
def audit_phase_failed(error)
Chef::Log.debug("Audit Reporter failed.")
ordered_control_groups.each do |name, control_group|
audit_data.add_control_group(control_group)
end
end
|
#audit_phase_start(run_status) ⇒ Object
43
44
45
46
47
|
# File 'lib/chef/audit/audit_reporter.rb', line 43
def audit_phase_start(run_status)
Chef::Log.debug("Audit Reporter starting")
@audit_data = AuditData.new(run_status.node.name, run_status.run_id)
@run_status = run_status
end
|
#auditing_enabled? ⇒ Boolean
If @audit_enabled is nil or true, we want to run audits
95
96
97
|
# File 'lib/chef/audit/audit_reporter.rb', line 95
def auditing_enabled?
Chef::Config[:audit_mode] != :disabled
end
|
#control_example_failure(control_group_name, example_data, error) ⇒ Object
89
90
91
92
|
# File 'lib/chef/audit/audit_reporter.rb', line 89
def control_example_failure(control_group_name, example_data, error)
control_group = ordered_control_groups[control_group_name]
control_group.example_failure(example_data, error.message)
end
|
#control_example_success(control_group_name, example_data) ⇒ Object
84
85
86
87
|
# File 'lib/chef/audit/audit_reporter.rb', line 84
def control_example_success(control_group_name, example_data)
control_group = ordered_control_groups[control_group_name]
control_group.example_success(example_data)
end
|
#control_group_started(name) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/chef/audit/audit_reporter.rb', line 76
def control_group_started(name)
if ordered_control_groups.has_key?(name)
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
metadata = run_context.audits[name].metadata
ordered_control_groups.store(name, ControlGroupData.new(name, metadata))
end
|
#run_completed(node) ⇒ Object
68
69
70
|
# File 'lib/chef/audit/audit_reporter.rb', line 68
def run_completed(node)
post_auditing_data
end
|
#run_context ⇒ Object
39
40
41
|
# File 'lib/chef/audit/audit_reporter.rb', line 39
def run_context
run_status.run_context
end
|
#run_failed(error) ⇒ Object
72
73
74
|
# File 'lib/chef/audit/audit_reporter.rb', line 72
def run_failed(error)
post_auditing_data(error)
end
|