summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9fbf970)
raw | patch | inline | side by side (parent: 9fbf970)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 9 Apr 2008 08:14:44 +0000 (08:14 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 9 Apr 2008 08:14:44 +0000 (08:14 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10293 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/server/events/logHandling.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
index 0b636108141245a99e7e75a80e1b3bafff38f910..c06a0b2f9d80ac16cf5328487f8512cda030dd02 100644 (file)
### Start ######################################################################
-#&main::read_configfile($main::cfg_file, %cfg_defaults);
+#=== FUNCTION ================================================================
+# NAME: get_events
+# PARAMETERS: none
+# RETURNS: reference of exported events
+# DESCRIPTION: tells the caller which functions are available
+#===============================================================================
sub get_events {
return \@events
}
+
+#=== FUNCTION ================================================================
+# NAME: show_log_by_date
+# DESCRIPTION: reporting installed hosts matching to regex of date
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub show_log_by_date {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{header}}[0];
my $target = @{$msg_hash->{target}}[0];
my $source = @{$msg_hash->{source}}[0];
my $date_l = $msg_hash->{date};
-
+ my $out_msg;
$header =~ s/gosa_//;
if (not -d $main::client_fai_log_dir) {
- &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1);
- return;
+ my $error_string = "client fai log directory '$main::client_fai_log_dir' do not exist";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# build out_msg
}
}
- my $out_msg = &create_xml_string($out_hash);
+ $out_msg = &create_xml_string($out_hash);
return ($out_msg);
}
+
+#=== FUNCTION ================================================================
+# NAME: show_log_by_mac
+# DESCRIPTION: reporting installation dates matching to regex of mac address
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub show_log_by_mac {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{header}}[0];
$header =~ s/gosa_//;
if (not -d $main::client_fai_log_dir) {
- &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1);
- return;
+ my $error_string = "client fai log directory '$main::client_fai_log_dir' do not exist";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# build out_msg
}
+#=== FUNCTION ================================================================
+# NAME: show_log_by_date_and_mac
+# DESCRIPTION: reporting host and installation dates matching to regex of date and regex of mac address
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub show_log_by_date_and_mac {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
$header =~ s/gosa_//;
if (not -d $main::client_fai_log_dir) {
- &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1);
- return;
+ my $error_string = "client fai log directory '$main::client_fai_log_dir' do not exist";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# build out_msg
}
+#=== FUNCTION ================================================================
+# NAME: show_log_files_by_date_and_mac
+# DESCRIPTION: reporting installation log files matching exatly to date and mac address
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub show_log_files_by_date_and_mac {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
my $act_log_dir = File::Spec->catdir($main::client_fai_log_dir, $mac, $date);
if (not -d $act_log_dir) {
- &main::daemon_log("$session_id ERROR: client fai log directory '$act_log_dir' do not exist", 1);
- return;
+ my $error_string = "client fai log directory '$act_log_dir' do not exist";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# build out_msg
}
+#=== FUNCTION ================================================================
+# NAME: get_log_file_by_date_and_mac
+# DESCRIPTION: returning the given log file, base64 coded, matching exactly to date and mac address
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub get_log_file_by_date_and_mac {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
# sanity check
my $act_log_file = File::Spec->catfile($main::client_fai_log_dir, $mac, $date, $log_file);
if (not -f $act_log_file) {
- &main::daemon_log("$session_id ERROR: client fai log file '$act_log_file' do not exist or could not be read", 1);
- return;
+ my $error_string = "client fai log file '$act_log_file' do not exist or could not be read";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# read log file
sub by_log_date {
&transform($a) <=> &transform($b);
}
+#=== FUNCTION ================================================================
+# NAME: get_recent_log_by_mac
+# DESCRIPTION: reporting the latest installation date matching to regex of mac address
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub get_recent_log_by_mac {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
if (not -d $main::client_fai_log_dir) {
my $error_string = "client fai log directory '$main::client_fai_log_dir' do not exist";
&main::daemon_log("$session_id ERROR: $error_string", 1);
- my $out_hash = &create_xml_hash($header, $target, $source, $error_string);
- my $out_msg = &create_xml_string($out_hash);
- return $out_msg;
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
opendir (DIR, $main::client_fai_log_dir);
if (not defined $act_log_dir) {
my $error_string = "do not find mac '$mac' in directory '$main::client_fai_log_dir'";
&main::daemon_log("$session_id ERROR: $error_string", 1);
- my $out_hash = &create_xml_hash($header, $target, $source, $error_string);
- my $out_msg = &create_xml_string($out_hash);
- return $out_msg;
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
# read mac directory
}
+#=== FUNCTION ================================================================
+# NAME: delete_log_by_date_and_mac
+# DESCRIPTION: delete installation date directory matching to regex of date and regex of mac address
+# missing date or mac is substitutet with regex '.'; if both is missing, deleting is rejected
+# PARAMETERS: [$msg] original incoming message
+# [$msg_hash] incoming message transformed to hash concerning XML::Simple
+# [$session_id] POE session id
+# RETURNS: gosa-si valid answer string
+#===============================================================================
sub delete_log_by_date_and_mac {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
# sanity check
if (not -d $main::client_fai_log_dir) {
- &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1);
- return;
+ my $error_string = "client fai log directory '$main::client_fai_log_dir' do not exist";
+ &main::daemon_log("$session_id ERROR: $session_id", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
if ((not defined $date) && (not defined $mac)) {
- my $err_string = "deleting all log files from gosa-si-server by an empty delete message is not permitted";
- &main::daemon_log("$session_id INFO: $err_string", 5);
- my $out_hash = &create_xml_hash($header, $target, $source, $err_string);
- my $out_msg = &create_xml_string($out_hash);
- return $out_msg;
+ my $error_string = "deleting all log files from gosa-si-server by an empty delete message is not permitted";
+ &main::daemon_log("$session_id INFO: $error_string", 5);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
}
if (not defined $date) { $date = "."; } # set date to a regular expression matching to everything
if (not defined $mac) { $mac = "."; } # set mac to a regular expression matching to everything
index b46aea2d67277162ae2d6b755fb6ea67ef126501..3301212494078c12f105906856a55624e15c872d 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
################
# logHandling.pm
# all date and mac parameter accept regular expression as input unless other instructions are given
-#$data = "<xml> <header>gosa_show_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6C:9D:B9:FA</mac> <mac>00:01:6c:9d:b9:fb</mac> </xml>";
+# show_log_by_mac, show_log_by_date, show_log_by_date_and_mac, show_log_files_by_date_and_mac,
+# get_log_file_by_date_and_mac, delete_log_by_date_and_mac, get_recent_log_by_mac
+$data = "<xml> <header>gosa_show_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6C:9D:B9:FA</mac> <mac>00:01:6c:9d:b9:fb</mac> </xml>";
#$data = "<xml> <header>gosa_show_log_by_date</header> <target>GOSA</target> <source>GOSA</source> <date>20080313</date> <date>20080323</date> </xml>";
#$data = "<xml> <header>gosa_show_log_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>200803</date> <mac>00:01:6c:9d:b9:FA</mac> </xml>";
-# exact date and mac are required as input for show_log_files_by_date_and_mac
+#$data = "<xml> <header>gosa_delete_log_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac></xml>";
+#$data = "<xml> <header>gosa_get_recent_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac></xml>";
+
+# exact date and mac are required as input
#$data = "<xml> <header>gosa_show_log_files_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>install_20080311_090900</date> <mac>00:01:6c:9d:b9:fa</mac> </xml>";
-# exact date and mac parameter are required as input for get_log_file_by_date_and_mac
#$data = "<xml> <header>gosa_get_log_file_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>install_20080311_090900</date> <mac>00:01:6c:9d:b9:fa</mac> <log_file>boot.log</log_file></xml>";
-#$data = "<xml> <header>gosa_delete_log_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac></xml>";
-# exact mac parameter are required as input for get_recent_log_by_mac
-$data = "<xml> <header>gosa_get_recent_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fA</mac></xml>";