Skip to content

Commit

Permalink
Merge pull request #79 from VinceMacBuche/ust_5211/5213/add_class_noop
Browse files Browse the repository at this point in the history
Fixes #5213: Add class_noop generic_method
  • Loading branch information
jooooooon committed Jul 4, 2014
2 parents f3141e3 + 80a9638 commit 5778800
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/acceptance/30_generic_methods/class_noop.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#######################################################
#
# Test if only noop classes are created
#
#######################################################

bundle common acc_path
{
vars:
"root" string => getenv("NCF_TESTS_ACCEPTANCE", 1024);
}

body common control
{
inputs => { "${acc_path.root}/default.cf.sub", "${acc_path.root}/default_ncf.cf.sub", "@{ncf_inputs.default_files}" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init
{
vars:
"tmp" string => getenv("TEMP", 1024);
}

#######################################################

bundle agent test
{
methods:
"ph1" usebundle => _classes_noop("my_class");

}

#######################################################

bundle agent check
{
classes:
"ok_noop" and => { "my_class_noop" };
"ok_success" expression => "!(promise_kept_my_class|my_class_kept|my_class_not_repaired|my_class_ok|my_class_reached)";
"ok_repaired" expression => "!(promise_repaired_my_class|my_class_repaired)";
"ok_error" expression => "!(repair_failed_my_class|repair_denied_class_my_class|repair_timeout_my_class|my_class_failed|my_class_not_ok|my_class_not_kept|my_class_denied|my_class_timeout)";
"ok" and => { "ok_noop", "ok_success", "ok_repaired", "ok_error" };

reports:
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
}
38 changes: 38 additions & 0 deletions tree/30_generic_methods/_classes_noop.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#####################################################################################
# Copyright 2013 Normation SAS
#####################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################

# @name Classes noop definition
# @description Defines noop classes based on a prefix
#
# @parameter class_prefix The prefix of the noop class to defined
#
# @class_prefix
# @class_parameter
# This bundle will define a class ${class_prefix}_noop

bundle agent _classes_noop(class_prefix)
{
vars:
"suffix" slist => { "noop" };

"local_${suffix}"
string => "${class_prefix}_${suffix}",
classes => always("${class_prefix}_${suffix}");
}


4 changes: 4 additions & 0 deletions tree/30_generic_methods/logger_rudder.cf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ bundle agent logger_rudder(message, class_prefix)
report_data_read::

# 4/ Array is ready, reporting time !!!
"@@${report_data[1]}@@result_na@@${report_data[3]}@@${report_data[4]}@@${report_data[5]}@@${g.execRun}##${g.uuid}@#${message}"
ifvarclass => "${class_prefix}_noop.!${class_prefix}_kept.!${class_prefix}_repaired.!${class_prefix}_error",
classes => classes_generic("logger_rudder_${class_prefix}");

"@@${report_data[1]}@@result_success@@${report_data[3]}@@${report_data[4]}@@${report_data[5]}@@${g.execRun}##${g.uuid}@#${message}"
ifvarclass => "${class_prefix}_kept.!${class_prefix}_repaired.!${class_prefix}_error",
classes => classes_generic("logger_rudder_${class_prefix}");
Expand Down

0 comments on commit 5778800

Please sign in to comment.