index 0b636108141245a99e7e75a80e1b3bafff38f910..714b9768e948bdf38681b6d9ecc730a42d9c1d24 100644 (file)
### Start ######################################################################
### 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
}
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};
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) {
$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
}
# build out_msg
}
}
}
}
- my $out_msg = &create_xml_string($out_hash);
+ $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return ($out_msg);
}
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];
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) {
$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
}
# build out_msg
}
my $out_msg = &create_xml_string($out_hash);
}
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return ($out_msg);
}
return ($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];
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) {
$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
}
# build out_msg
}
my $out_msg = &create_xml_string($out_hash);
}
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return $out_msg;
}
return $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];
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) {
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
}
# build out_msg
}
my $out_msg = &create_xml_string($out_hash);
}
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return $out_msg;
}
return $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];
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) {
# 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
}
# read log file
my $out_hash = &create_xml_hash($header, $target, $source);
&add_content2xml_hash($out_hash, $log_file, $log_content);
my $out_msg = &create_xml_string($out_hash);
my $out_hash = &create_xml_hash($header, $target, $source);
&add_content2xml_hash($out_hash, $log_file, $log_content);
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return $out_msg;
}
return $out_msg;
}
sub by_log_date {
&transform($a) <=> &transform($b);
}
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];
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);
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);
}
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);
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
}
# read mac directory
}
my $out_msg = &create_xml_string($out_hash);
}
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return $out_msg;
}
return $out_msg;
}
+#=== 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];
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) {
# 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)) {
}
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
}
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
}
my $out_msg = &create_xml_string($out_hash);
}
my $out_msg = &create_xml_string($out_hash);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
return $out_msg;
}
return $out_msg;
}