Skip to content

Commit

Permalink
add ACCESSLOG node in inventory for Android
Browse files Browse the repository at this point in the history
OCSInventory does not support ACCESSLOG (but fusioninventory does)
We add this node in cfengine. An possible improvement is to check for the
existence of this node before adding it in order to be compatible with
fusioninventory
  • Loading branch information
Cédric Cabessa committed May 22, 2013
1 parent f2a34d0 commit ce3de96
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions initial-promises/node-server/inventory/1.0/fusionAgent.cf
Expand Up @@ -331,6 +331,7 @@ bundle agent addInformationsToInventory {
"android_name" string => "Android";
"android_version" string => execresult("/system/bin/getprop ro.build.version.release", "noshell");
"android_fullname" string => "Android $(android_version)";
"logdate" string => execresult("/system/bin/date '+%Y-%m-%d %H:%M:%S'", "noshell");

classes:
xen::
Expand Down Expand Up @@ -367,6 +368,10 @@ bundle agent addInformationsToInventory {
edit_line => add_information_to_android_inventory($(android_fullname), $(android_kernelname), $(android_kernelversion), $(android_name), $(android_version)),
edit_defaults => def_no_backup;

"${g.rudder_var_tmp}/inventory/.*.ocs"
edit_line => add_accesslog_to_android_inventory($(logdate)),
edit_defaults => def_no_backup;

}

# Move the inventory file in the shared directory
Expand Down Expand Up @@ -485,6 +490,20 @@ insert_lines:

}

#this bundle is necessary for OCSInventory (but not for fusioninventory)
bundle edit_line add_accesslog_to_android_inventory(logdate)
{
insert_lines:

android::

"<ACCESSLOG><LOGDATE>$(logdate)</LOGDATE></ACCESSLOG>"
location => after_location("<CONTENT>"),
comment => "Adding log date";

}


bundle edit_line add_users_information_to_inventory(userlist)
{
insert_lines:
Expand Down
17 changes: 17 additions & 0 deletions techniques/system/inventory/1.0/fusionAgent.st
Expand Up @@ -345,6 +345,7 @@ bundle agent addInformationsToInventory {
"android_name" string => "Android";
"android_version" string => execresult("/system/bin/getprop ro.build.version.release", "noshell");
"android_fullname" string => "Android $(android_version)";
"logdate" string => execresult("/system/bin/date '+%Y-%m-%d %H:%M:%S'", "noshell");
classes:
Expand Down Expand Up @@ -381,6 +382,9 @@ bundle agent addInformationsToInventory {
edit_line => add_information_to_android_inventory($(android_fullname), $(android_kernelname), $(android_kernelversion), $(android_name), $(android_version)),
edit_defaults => def_no_backup;
"${g.rudder_var_tmp}/inventory/.*.ocs"
edit_line => add_accesslog_to_android_inventory($(logdate)),
edit_defaults => def_no_backup;
}
Expand Down Expand Up @@ -500,6 +504,19 @@ insert_lines:

}

#this bundle is necessary for OCSInventory (but not for fusioninventory)
bundle edit_line add_accesslog_to_android_inventory(logdate)
{
insert_lines:

android::

"<ACCESSLOG><LOGDATE>$(logdate)</LOGDATE></ACCESSLOG>"
location => after_location("<CONTENT>"),
comment => "Adding log date";

}

bundle edit_line add_users_information_to_inventory(userlist)
{
insert_lines:
Expand Down

1 comment on commit ce3de96

@CedricCabessa
Copy link
Owner

Choose a reason for hiding this comment

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

DO NO MERGE

the after_location("") is not used correctly
We (sometime) have 2 lines with ACCESSLOG (timestamp are the same or 1sec different).
According to the doc https://cfengine.com/manuals/cf3-Reference#insert_005flines-in-edit_005fline-promises this syntax should not converge.
I try to use after_location(""), it seem to works, but I'll wait a bit before pushing it.

Please sign in to comment.