Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #8194: file_check_ on branch master use deprecated _logger interface #343

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions tree/30_generic_methods/_file_check_special.cf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ bundle agent file_check_special(file_name, file_type)
{
vars:
"file_has_type" string => filestat("${file_name}", "type");
"class_prefix" string => canonify("file_check_${file_type}_${file_name}");

"old_class_prefix" string => canonify("file_check_${file_type}_${file_name}");
"promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";
"class_prefix" string => canonify(join("_", "promisers"));
"args" slist => { "${file_name}", "${file_type}" };


classes:
"file_exists" expression => fileexists("${file_name}");
Expand All @@ -43,14 +48,18 @@ bundle agent file_check_special(file_name, file_type)

methods:
exists_special::
"file_exists_and_is_special"
usebundle => _classes_success("${old_class_prefix}");
"file_exists_and_is_special"
usebundle => _classes_success("${class_prefix}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would normally only call the _classes_success method for the new class_prefix if the has_promiser_stack class is defined. See for example https://github.com/Normation/ncf/blob/master/tree/30_generic_methods/_service_check_running_src.cf#L50.


!exists_special::
"file_doesnt_exists_or_is_not_special"
usebundle => _classes_failure("${old_class_prefix}");
"file_doesnt_exists_or_is_not_special"
usebundle => _classes_failure("${class_prefix}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


any::
"report"
usebundle => _logger("Check if ${file_name} exists and is a ${file_type}", "${class_prefix}");
usebundle => _log("Check if ${file_name} exists and is a ${file_type}", "${old_class_prefix}", "${class_prefix}", @{args});
}
14 changes: 12 additions & 2 deletions tree/30_generic_methods/file_check_hardlink.cf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
bundle agent file_check_hardlink(file_name_1, file_name_2)
{
vars:
"class_prefix" string => canonify("file_check_hardlink_${file_name_1}");
"old_class_prefix" string => canonify("file_check_hardlink_${file_name_1}");
"promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";
"class_prefix" string => canonify(join("_", "promisers"));
"args" slist => { "${file_name_1}", "${file_name_2}" };



"file_1_devno" string => filestat("${file_name_1}", "devno");
"file_1_ino" string => filestat("${file_name_1}", "ino");
"file_2_devno" string => filestat("${file_name_2}", "devno");
Expand All @@ -49,14 +55,18 @@ bundle agent file_check_hardlink(file_name_1, file_name_2)

methods:
files_are_hardlinks::
"files_are_hardlinks"
usebundle => _classes_success("${old_class_prefix}");
"files_are_hardlinks"
usebundle => _classes_success("${class_prefix}");

!files_are_hardlinks::
"files_are_not_hardlinks"
usebundle => _classes_failure("${old_class_prefix}");
"files_are_not_hardlinks"
usebundle => _classes_failure("${class_prefix}");

any::
"report"
usebundle => _logger("Check if ${file_name_1} and ${file_name_2} are the same", "${class_prefix}");
usebundle => _log("Check if ${file_name_1} and ${file_name_2} are the same", "${old_class_prefix}", "${class_prefix}", @{args});
}
13 changes: 10 additions & 3 deletions tree/30_generic_methods/file_check_regular.cf
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,30 @@ bundle agent file_check_regular(file_name)
{

vars:
"class_prefix"
string => canonify("file_check_regular_${file_name}");
"old_class_prefix" string => canonify("file_check_regular_${file_name}");
"promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";
"class_prefix" string => canonify(join("_", "promisers"));
"args" slist => { "${file_name}" };


classes:
"file_exists_and_is_regular"
expression => isplain("${file_name}");

methods:
file_exists_and_is_regular::
"file_exists_and_is_regular"
usebundle => _classes_success("${old_class_prefix}");
"file_exists_and_is_regular"
usebundle => _classes_success("${class_prefix}");

!file_exists_and_is_regular::
"file_dont_exists_or_is_not_a_regular"
usebundle => _classes_failure("${old_class_prefix}");
"file_dont_exists_or_is_not_a_regular"
usebundle => _classes_failure("${class_prefix}");

any::
"report"
usebundle => _logger("Check if ${file_name} is a regular file", "${class_prefix}");
usebundle => _log("Check if ${file_name} is a regular file", "${old_class_prefix}", "${class_prefix}", @{args});
}
12 changes: 9 additions & 3 deletions tree/30_generic_methods/file_check_symlink.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@
bundle agent file_check_symlink(file_name)
{
vars:
"class_prefix"
string => canonify("file_check_symlink_${file_name}");
"old_class_prefix" string => canonify("file_check_symlink_${file_name}");
"promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";
"class_prefix" string => canonify(join("_", "promisers"));
"args" slist => { "${file_name}" };

classes:
"file_exists_and_is_symlink"
expression => islink("${file_name}");

methods:
file_exists_and_is_symlink::
"file_exists_and_is_symlink"
usebundle => _classes_success("${old_class_prefix}");
"file_exists_and_is_symlink"
usebundle => _classes_success("${class_prefix}");

!file_exists_and_is_symlink::
"file_dont_exists_or_is_not_a_symlink"
usebundle => _classes_failure("${old_class_prefix}");
"file_dont_exists_or_is_not_a_symlink"
usebundle => _classes_failure("${class_prefix}");

any::
"report"
usebundle => _logger("Check if ${file_name} is a symlink", "${class_prefix}");
usebundle => _log("Check if ${file_name} is a symlink", "${old_class_prefix}", "${class_prefix}", @{args});
}
14 changes: 11 additions & 3 deletions tree/30_generic_methods/file_check_symlinkto.cf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
bundle agent file_check_symlinkto(symlink, target)
{
vars:
"class_prefix" string => canonify("file_check_symlinkto_${symlink}");
"old_class_prefix" string => canonify("file_check_symlinkto_${symlink}");
"promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";
"class_prefix" string => canonify(join("_", "promisers"));
"args" slist => { "${symlink}", "${target}" };


"real_path" string => execresult("/bin/readlink -f \"${symlink}\"", "noshell");

classes:
Expand All @@ -44,15 +49,18 @@ bundle agent file_check_symlinkto(symlink, target)

methods:
is_ok::
"symlink_points_to_file"
usebundle => _classes_success("${old_class_prefix}");
"symlink_points_to_file"
usebundle => _classes_success("${class_prefix}");

!is_ok::
"symlink_does_not_point_to_file"
usebundle => _classes_failure("${old_class_prefix}");
"symlink_does_not_point_to_file"
usebundle => _classes_failure("${class_prefix}");

any::
"report"
usebundle => _logger("Check if ${symlink} points to ${target}", "${class_prefix}");
usebundle => _log("Check if ${symlink} points to ${target}", "${old_class_prefix}", "${class_prefix}", @{args});

}