diff --git a/tree/30_generic_methods/condition_from_expression.cf b/tree/30_generic_methods/condition_from_expression.cf index d670912b..72b3bb77 100644 --- a/tree/30_generic_methods/condition_from_expression.cf +++ b/tree/30_generic_methods/condition_from_expression.cf @@ -70,11 +70,7 @@ bundle agent condition_from_expression(condition, expression) { vars: - "old_class_prefix" string => canonify("condition_from_expression_${condition}"); - "args" slist => { "${condition}", "${expression}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("condition_from_expression_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "class_prefix" string => canonify("condition_from_expression_${condition}"); classes: "${condition}_true" expression => "${expression}", @@ -84,13 +80,11 @@ bundle agent condition_from_expression(condition, expression) scope => "namespace"; methods: - "success" usebundle => _classes_success("${old_class_prefix}"); - "success" usebundle => _classes_success("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_success("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the condition ${condition}_{true,false} with ${expression}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); - reports: - "Condition ${condition}_true defined" - if => "${condition}_true"; - "Condition ${condition}_false defined" - if => "${condition}_false"; + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "Condition ${condition}_true was defined", ""), + if => "${condition}_true"; + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "Condition ${condition}_false was defined", ""), + if => "${condition}_false"; } diff --git a/tree/30_generic_methods/condition_from_expression_persistent.cf b/tree/30_generic_methods/condition_from_expression_persistent.cf index 8d3c8581..0a4cfdfe 100644 --- a/tree/30_generic_methods/condition_from_expression_persistent.cf +++ b/tree/30_generic_methods/condition_from_expression_persistent.cf @@ -71,24 +71,23 @@ bundle agent condition_from_expression_persistent(condition, expression, duration) { vars: - "old_class_prefix" string => canonify("condition_from_expression_persistent_${condition}"); - "args" slist => { "${condition}", "${expression}", "${duration}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("condition_from_expression_persistent_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "class_prefix" string => canonify("condition_from_expression_persistent_${condition}"); classes: - "${condition}_true" expression => "${expression}", - persistence => "${duration}", - scope => "namespace"; + "${condition}_true" expression => "${expression}", + persistence => "${duration}", + scope => "namespace"; - "${condition}_false" expression => "!(${expression})", - persistence => "${duration}", - scope => "namespace"; + "${condition}_false" expression => "!(${expression})", + persistence => "${duration}", + scope => "namespace"; methods: - "success" usebundle => _classes_success("${old_class_prefix}"); - "success" usebundle => _classes_success("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_success("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the persistent condition ${condition}_{true,false} with ${expression}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "The condition ${condition}_true was defined and will persist for ${duration} minutes", ""), + if => "${expression}"; + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "The condition ${condition}_false was defined and will persist for ${duration} minutes", ""), + if => "!(${expression})"; } diff --git a/tree/30_generic_methods/condition_from_variable_existence.cf b/tree/30_generic_methods/condition_from_variable_existence.cf index 7aba5037..7ea48400 100644 --- a/tree/30_generic_methods/condition_from_variable_existence.cf +++ b/tree/30_generic_methods/condition_from_variable_existence.cf @@ -39,23 +39,21 @@ bundle agent condition_from_variable_existence(condition, variable_name) { vars: - "old_class_prefix" string => canonify("condition_from_variable_existence_${condition}"); - "args" slist => { "${condition}", "${variable_name}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("condition_from_variable_existence_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "class_prefix" string => canonify("condition_from_variable_existence_${condition}"); classes: - "${condition}_true" expression => isvariable("${variable_name}"), - scope => "namespace"; + scope => "namespace"; - "${condition}_false" not => isvariable("${variable_name}"), - scope => "namespace"; + "${condition}_false" not => isvariable("${variable_name}"), + scope => "namespace"; methods: - "success" usebundle => _classes_success("${old_class_prefix}"); - "success" usebundle => _classes_success("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_success("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the condition ${condition}_{true,false} from the existence of variable ${variable_name}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "The condition ${condition}_true was defined as the variable ${variable_name} was defined", ""), + if => isvariable("${variable_name}"); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "The condition ${condition}_false was defined as the variable ${variable_name} was undefined", ""), + not => isvariable("${variable_name}"); } diff --git a/tree/30_generic_methods/condition_from_variable_match.cf b/tree/30_generic_methods/condition_from_variable_match.cf index e38be410..60c83415 100644 --- a/tree/30_generic_methods/condition_from_variable_match.cf +++ b/tree/30_generic_methods/condition_from_variable_match.cf @@ -55,11 +55,7 @@ bundle agent condition_from_variable_match(condition, variable_name, expected_match) { vars: - "old_class_prefix" string => canonify("condition_from_variable_match_${condition}"); - "args" slist => { "${condition}", "${variable_name}", "${expected_match}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("condition_from_variable_match_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "class_prefix" string => canonify("condition_from_variable_match_${condition}"); classes: "pass1" expression => "any"; @@ -67,25 +63,34 @@ bundle agent condition_from_variable_match(condition, variable_name, expected_ma "pass3" expression => "pass2"; pass2:: - "var_exists" expression => isvariable("${variable_name}"); + "var_exists" expression => isvariable("${variable_name}"); "${condition}_true" and => {regcmp("${expected_match}", "${${variable_name}}"), "var_exists"}, - scope => "namespace"; + scope => "namespace"; "${condition}_false" or => {"!${condition}_true", "!var_exists"}, - scope => "namespace"; + scope => "namespace"; methods: pass3:: - "failure" usebundle => _classes_failure("${old_class_prefix}"), - ifvarclass => "!var_exists"; - "failure" usebundle => _classes_failure("${class_prefix}"), - ifvarclass => "!var_exists"; + "${report_data.method_id}" usebundle => _classes_failure("${report_data.method_id}"), + not => "var_exists"; + "${report_data.method_id}" usebundle => _classes_failure("${class_prefix}"), + not => "var_exists"; - "success" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "var_exists"; - "success" usebundle => _classes_success("${class_prefix}"), - ifvarclass => "var_exists"; + "${report_data.method_id}" usebundle => _classes_success("${report_data.method_id}"), + if => "var_exists"; + "${report_data.method_id}" usebundle => _classes_success("${class_prefix}"), + if => "var_exists"; - "report" usebundle => _log("Create the condition ${condition}_{true,false} from the result of regex: /${expected_match}/ on variable ${variable_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}","Condition ${condition}_true was defined as the variable ${variable_name} matched the expected pattern", ""), + if => and( regcmp("${expected_match}", "${${variable_name}}"), + "var_exists" + ); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "Condition ${condition}_false was defined as the variable ${variable_name} did not match the expected pattern", ""), + if => and( "var_exists", + not(regcmp("${expected_match}", "${${variable_name}}")) + ); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "Condition ${condition}_false was defined as the variable ${variable_name} was undefined", ""), + not => "var_exists"; } diff --git a/tree/30_generic_methods/condition_once.cf b/tree/30_generic_methods/condition_once.cf index 03cbf34f..04ca9655 100644 --- a/tree/30_generic_methods/condition_once.cf +++ b/tree/30_generic_methods/condition_once.cf @@ -49,26 +49,22 @@ bundle agent condition_once(condition) { vars: - "c_condition" string => canonify("${condition}"); - "old_class_prefix" string => canonify("condition_once_${condition}"); - "args" slist => { "${condition}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("condition_once_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "c_condition" string => canonify("${condition}"); + "class_prefix" string => canonify("condition_once_${condition}"); classes: - "reserved" expression => strcmp("${reserve[1]}", "ok"); - "already_set" expression => strcmp("${reserve[1]}", "failed_set"); + "reserved" expression => strcmp("${reserve[1]}", "ok"); + "already_set" expression => strcmp("${reserve[1]}", "failed_set"); "already_reserved" expression => strcmp("${reserve[1]}", "failed_reserved"); - "set_ok" expression => strcmp("${set[1]}", "ok"); + "set_ok" expression => strcmp("${set[1]}", "ok"); "${c_condition}" expression => "set_ok", scope => "namespace"; "should_report" expression => "${report_data.should_report}"; - "pass3" expression => "pass2"; - "pass2" expression => "pass1"; - "pass1" expression => "any"; + "pass3" expression => "pass2"; + "pass2" expression => "pass1"; + "pass1" expression => "any"; methods: "reserve the flag" usebundle => reserve_flag("condition_once_${c_condition}"), @@ -78,27 +74,25 @@ bundle agent condition_once(condition) useresult => "set"; set_ok:: - "success" usebundle => _classes_repaired("${old_class_prefix}"); - "success" usebundle => _classes_repaired("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_repaired("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_repaired("${class_prefix}"); pass3.reserved.!set_ok:: - "failure" usebundle => _classes_failure("${old_class_prefix}"); - "failure" usebundle => _classes_failure("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_failure("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_failure("${class_prefix}"); pass3.(already_set|already_reserved):: - "success" usebundle => _classes_success("${old_class_prefix}"); - "success" usebundle => _classes_success("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_success("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_success("${class_prefix}"); pass3.already_reserved:: - "disable_reporting_${class_prefix}" - usebundle => disable_reporting; - "failure" usebundle => _classes_failure("temp_${old_class_prefix}_warn"); - "failure" usebundle => _classes_failure("temp_${class_prefix}_warn"); - "report" usebundle => _log_v3("The '${c_condition}' condition was reserved but not set, this is unexpected", "${condition}", "temp_${old_class_prefix}_warn", "temp_${class_prefix}_warn", @{args}); - "reenable_reporting_${class_prefix}" - usebundle => enable_reporting, - if => "should_report"; + "disable_reporting_${class_prefix}" usebundle => disable_reporting; + "${report_data.method_id}" usebundle => _classes_failure("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_failure("${report_data.method_id}"); + "${report_data.method_id}" usebundle => log_rudder_v4("${c_condition}", "condition was reserved but not set, this is unexpected"); + "reenable_reporting_${class_prefix}" usebundle => enable_reporting, + if => "should_report"; pass3:: - "report" usebundle => _log_v3("Create the condition ${c_condition} once", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); + "${report_data.method_id}" usebundle => log_rudder_v4("${condition}", "Create the condition ${c_condition} once", ""); } diff --git a/tree/30_generic_methods/directory_absent.cf b/tree/30_generic_methods/directory_absent.cf index 9591a84f..66efb74f 100644 --- a/tree/30_generic_methods/directory_absent.cf +++ b/tree/30_generic_methods/directory_absent.cf @@ -33,29 +33,22 @@ bundle agent directory_absent(path, recursive) { vars: - "old_class_prefix" string => canonify("directory_absent_${path}"); - - # don't rewrite the class prefix based on defaults - !pass1:: - "args" slist => { "${path}", "${recursive}" }; - "report_param" string => join("_", args); - "full_class_prefix" string => canonify("directory_absent_${report_param}"); - "class_prefix" string => string_head("${full_class_prefix}", "1000"); + "class_prefix" string => canonify("directory_absent_${path}"); defaults: - "recursive" string => "false", if_match_regex => ""; + "recursive" string => "false", if_match_regex => ""; classes: - "is_recursive" expression => strcmp("true", "${recursive}"); + "is_recursive" expression => strcmp("true", "${recursive}"); pass2:: "directory_exists_after" expression => isdir("${path}"); "path_exists_after" expression => fileexists("${path}"); any:: - "pass3" expression => "pass2"; - "pass2" expression => "pass1"; - "pass1" expression => "any"; + "pass3" expression => "pass2"; + "pass2" expression => "pass1"; + "pass1" expression => "any"; files: @@ -64,34 +57,33 @@ bundle agent directory_absent(path, recursive) delete => tidy, file_select => all, depth_search => recurse_with_base("inf"), - classes => classes_generic_two("${old_class_prefix}_inside", "${class_prefix}_inside"); + classes => classes_generic_two("${report_data.method_id}_inside", "${class_prefix}_inside"); pass1:: "${path}/." delete => tidy, file_select => all, - classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), - ifvarclass => "!${class_prefix}_inside_error"; + classes => classes_generic_two("${report_data.method_id}", "${class_prefix}"), + if => "!${report_data.method_id}_inside_error"; methods: # If path was not empty, we need to trigger an error manually as the files promise will be kept # Because of https://tracker.mender.io/browse/CFE-1570 pass3.directory_exists_after:: - "fail_if_not_empty" usebundle => _classes_failure("${class_prefix}"); - "clean_if_not_empty" usebundle => _classes_sanitize("${class_prefix}"); - - "fail_if_not_empty" usebundle => _classes_failure("${old_class_prefix}"); - "clean_if_not_empty" usebundle => _classes_sanitize("${old_class_prefix}"); + "${report_data.method_id}" usebundle => _classes_failure("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_failure("${report_data.method_id}"); + "${report_data.method_id}" usebundle => _classes_sanitize("${class_prefix}"); + "${report_data.method_id}" usebundle => _classes_sanitize("${report_data.method_id}"); pass3:: # Use classes of the first promise when it failed - "copy_inside_error" usebundle => _classes_copy("${class_prefix}_inside", "${class_prefix}"), - ifvarclass => "${class_prefix}_inside_error"; - "copy_inside_error" usebundle => _classes_copy("${old_class_prefix}_inside", "${old_class_prefix}"), - ifvarclass => "${old_class_prefix}_inside_error"; + "${report_data.method_id}" usebundle => _classes_copy("${report_data.method_id}_inside", "${report_data.method_id}"), + if => "${report_data.method_id}_inside_error"; + "${report_data.method_id}" usebundle => _classes_copy("${report_data.method_id}_inside", "${class_prefix}"), + if => "${report_data.method_id}_inside_error"; - "report" usebundle => _log_v3("Remove directory ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); + "${report_data.method_id}" usebundle => log_rudder_v4("${path}", "Remove directory ${path}", ""); reports: pass3.info.path_exists_after.!directory_exists_after::