Skip to content

Commit

Permalink
Merge pull request #649 from ncharles/bug_6465/update_rudder_common_r…
Browse files Browse the repository at this point in the history
…eport_and_rudder_common_reports_generic_to_be_compatible_wiht_multi_instance_technique

Fixes #6465: Update rudder_common_report and rudder_common_reports_generic to be compatible wiht multi instance technique
  • Loading branch information
peckpeck committed Apr 7, 2015
2 parents 704cd3c + 7ebac23 commit 2558c51
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions techniques/system/common/1.0/rudder_stdlib.st
Expand Up @@ -180,10 +180,34 @@ body select_region rudder_section_selector(section_start, section_end)
# message : An explanation message understandable by a human
#
bundle agent rudder_common_report(technique_name, status, identifier, component_name, component_key, message)
{
methods:
"report" usebundle => rudder_common_report("${technique_name}", "${status}", "${identifier}", "${component_name}", "${component_key}", "${message}", "");
}
# Create and send a report to the server - to be used when dealing with multiinstance technique
# This bundle takes 7 parameters :
# technique_name : the name of the technique, human readable
# status : the status of the Component, among the following values
# result_success
# result_error
# result_repaired
# log_repaired (for logging only)
# log_warn (for logging only)
# log_info (for logging only)
# log_debug (for logging only)
# log_trace (for logging only)
# identifier : the identifier of the current Rule and Directive
# component_name : the name of the component within the Technique
# component_key : the value of the component reference variable (or None if undefined)
# message : An explanation message understandable by a human
# index : the current index, that will distinguish two identical reports and ensure they are both sent
bundle agent rudder_common_report_index(technique_name, status, identifier, component_name, component_key, message, index)
{
reports:
cfengine_3::
"@@${technique_name}@@${status}@@${identifier}@@${component_name}@@${component_key}@@${g.execRun}##${g.uuid}@#${message}";
"@@${technique_name}@@${status}@@${identifier}@@${component_name}@@${component_key}@@${g.execRun}##${g.uuid}@#${message}"
comment => "Reporting for ${technique_name} message ${message} for index ${index}";
}
Expand All @@ -199,18 +223,36 @@ bundle agent rudder_common_report(technique_name, status, identifier, component_
# message_prefix : The begining of an explanation message understandable by a human
#
bundle agent rudder_common_reports_generic(technique_name, class_prefix, identifier, component_name, component_key, message_prefix)
{
methods:
"report"
usebundle => rudder_common_report("${technique_name}", "${class_prefix}", "${identifier}", "${component_name}", "${component_key}", "${message_prefix}", "");
}
#
# Automatically create reports based on existing classes starting by
# class_prefix (as defined by the body classes rudder_common_classes)
# Takes 7 parameters
# technique_name : the name of the technique, human readable
# class_prefix : the prefix of a set of classes to reporting on (suffixes with "kept", "repaired" or "error")
# identifier : the identifier of the current Rule and Directive
# component_name : the name of the component within the Technique
# component_key : the value of the component reference variable (None if it does not exists)
# message_prefix : The begining of an explanation message understandable by a human
# index : the current index, that will distinguish two identical reports and ensure they are both sent
#
bundle agent rudder_common_reports_generic_index(technique_name, class_prefix, identifier, component_name, component_key, message_prefix, index)
{
methods:
"success"
usebundle => rudder_common_report("${technique_name}", "result_success", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was correct"),
usebundle => rudder_common_report_index("${technique_name}", "result_success", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was correct", "${index}"),
ifvarclass => "${class_prefix}_kept.!${class_prefix}_repaired.!${class_prefix}_error";
"repaired"
usebundle => rudder_common_report("${technique_name}", "result_repaired", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was repaired"),
usebundle => rudder_common_report_index("${technique_name}", "result_repaired", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was repaired", "${index}"),
ifvarclass => "${class_prefix}_repaired.!${class_prefix}_error";
"error"
usebundle => rudder_common_report("${technique_name}", "result_error", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} could not be repaired"),
usebundle => rudder_common_report_index("${technique_name}", "result_error", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} could not be repaired", "${index}"),
ifvarclass => "${class_prefix}_error";
}

0 comments on commit 2558c51

Please sign in to comment.