summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd2a37e)
raw | patch | inline | side by side (parent: fd2a37e)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Mar 2008 17:07:31 +0000 (17:07 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Mar 2008 17:07:31 +0000 (17:07 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9624 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/server/events/clMessages.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 14f1ed75d68cd4d4e3a6ec5afe9d639ad6e04dfc..e0e11bd43baa62b67f32cf460b48a31a88504fa2 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use XML::Simple;
use Net::DNS;
use File::Basename;
+use File::Spec;
my $event_dir = "/usr/lib/gosa-si/client/events";
use lib "/usr/lib/gosa-si/client/events";
# all x seconds the client reports logged_in users to gosa-si-server
my $trigger_logged_in_users_report_delay = 600;
+# directory where all log files from installation are stored
+my $fai_log_dir = "/tmp/fai";
+
%cfg_defaults = (
"general" =>
{"log-file" => [\$log_file, "/var/run/".$prg.".log"],
return;
}
+
sub fifo_got_record {
my $file_record = $_[ARG0];
my $header;
&add_content2xml_hash($clmsg_hash, "macaddress", $client_mac_address);
my $clmsg = &create_xml_string($clmsg_hash);
&send_msg_to_target($clmsg, $server_address, $server_key, "CLMSG_$header");
+
+ # if installation finished, save all log files
+ if ($file_record eq "TASKBEGIN finish") {
+ &save_fai_log($fai_log_dir);
+ }
+
return;
}
+sub save_fai_log {
+ my ($fai_log_dir) = @_ ;
+ my $FAI_DIR;
+
+print STDERR "===========================================\n";
+print STDERR "fai_log_dir: $fai_log_dir\n";
+
+ opendir($FAI_DIR, $fai_log_dir);
+ if (not defined $FAI_DIR) {
+ daemon_log("ERROR: can not open directory $fai_log_dir: $!", 1);
+ return;
+ }
+
+ my @log_files = readdir($FAI_DIR);
+ closedir($FAI_DIR);
+ my @log_list;
+
+ foreach my $log_file (@log_files) {
+ if( $log_file eq "." || $log_file eq ".." ) { next; }
+ my $log = "log_file:$log_file\n";
+ $log_file = File::Spec->catfile( $fai_log_dir, $log_file );
+ open(my $FILE, "<$log_file");
+ if (not defined $FILE ) {
+ daemon_log("ERROR: can not open '$log_file': $!", 1);
+ next;
+ }
+ my @lines = <$FILE>;
+ my $log_string = join("", @lines);
+ $log .= &encode_base64($log_string);
+ push(@log_list, $log);
+ close ($FILE);
+ }
+
+ my $all_log_string = join("\n", @log_list);
+ my $msg_hash = &create_xml_hash("CLMSG_save_fai_log", $client_address, $server_address, $all_log_string);
+ &add_content2xml_hash($msg_hash, "macaddress", $client_mac_address);
+ my $msg = &create_xml_string($msg_hash);
+ &send_msg_to_target($msg, $server_address, $server_key, "CLMSG_save_fai_log");
+
+}
+
+
sub _start {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('client_session');
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 0907860f23927e72277d35bef9975ac90e0556e4..a8e2bf2494da232ee7e6fd2f7d3f78a0aff5b837 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
our @messaging_col_names = ('subject', 'from', 'to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER', );
my $messaging_file_name;
+# path to directory to store client install log files
+our $client_fai_log_dir = "/var/log/fai";
+
%cfg_defaults = (
"general" => {
"log-file" => [\$log_file, "/var/run/".$prg.".log"],
return $result;
}
+
sub get_local_ip_for_remote_ip {
my $remote_ip= shift;
my $result="0.0.0.0";
return $error;
}
-###
-#
-# HIER LĂ„UFT WAS SCHIEF - GENAU HIER KACK MIST
-#
-# ERROR
-#
-# TODO
-#
-###
+
sub update_jobdb_status_for_send_msgs {
my ($answer, $error) = @_;
if( $answer =~ /<jobdb_id>(\d+)<\/jobdb_id>/ ) {
my $jobdb_id = $1;
if( $error ) {
- # sending msg faild
- my $sql_statement = "UPDATE $job_queue_tn ".
- "SET status='error', result='can not deliver msg, please consult log file' ".
- "WHERE id='$jobdb_id'";
- my $res = $job_db->update_dbentry($sql_statement);
+ if (not $answer =~ /<header>trigger_action_reinstall<\/header>/) {
+ # sending msg faild
+ my $sql_statement = "UPDATE $job_queue_tn ".
+ "SET status='error', result='can not deliver msg, please consult log file' ".
+ "WHERE id='$jobdb_id'";
+ my $res = $job_db->update_dbentry($sql_statement);
+ }
} else {
# sending msg was successful
my $sql_statement = "UPDATE $job_queue_tn ".
index 0ec31d5c177fe4ab75446118aaa8bf5abdf190d5..4e474d80781747f210366cae36c0e4f391dc2a5c 100644 (file)
"LOGIN",
"LOGOUT",
"CURRENTLY_LOGGED_IN",
+ "save_fai_log",
);
@EXPORT = @events;
use Data::Dumper;
use GOSA::GosaSupportDaemon;
use utf8;
+use MIME::Base64;
BEGIN {}
}
+sub save_fai_log {
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $macaddress = @{$msg_hash->{'macaddress'}}[0];
+ my $all_logs = @{$msg_hash->{$header}}[0];
+
+ my $client_fai_log_dir = $main::client_fai_log_dir;
+ if (not -d $client_fai_log_dir) {
+ mkdir($client_fai_log_dir, 0755)
+ }
+
+ $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, $macaddress );
+ if (not -d $client_fai_log_dir) {
+ mkdir($client_fai_log_dir, 0755)
+ }
+
+ my $time = &get_time;
+ $time = substr($time, 1, 8)."_".substr($time, 8, 6);
+ $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install-$time" );
+ mkdir($client_fai_log_dir, 0755);
+
+ my @all_logs = split(/log_file:/, $all_logs);
+ foreach my $log (@all_logs) {
+ if (length $log == 0) { next; };
+ my ($log_file, $log_string) = split("\n", $log, 2);
+ my $client_fai_log_file = File::Spec->catfile( $client_fai_log_dir, $log_file);
+ open(my $LOG_FILE, ">$client_fai_log_file");
+ print $LOG_FILE &decode_base64($log_string);
+ close($LOG_FILE);
+ }
+ return;
+}
+
+
sub LOGIN {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
}
-
sub TASKBEGIN {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
index 7632f70f6b82e5d59e4cd138aa27ff9c8afdec96..3ec4b418026b7de2738d9dc14efddca3d2259627 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
for($count = 1; $count <= $zahl; $count++)
{
-$sock = new Socket_Client("127.0.0.1","20181",TRUE,1);
+$sock = new Socket_Client("127.0.0.1","20081",TRUE,1);
$sock->setEncryptionKey("secret-gosa-password");
if($sock->connected()){
#$data = "<xml> <header>gosa_detect_hardware</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>job_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp></xml>";
-$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+#$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>20130101000000</timestamp> </xml>";
+$data = "<xml> <header>gosa_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";