diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm
index 819b10be616029d308908a6de67e40fd6191444e..686d9f7687b09a54f9f69edfd2688545196948d9 100644 (file)
'confirm_new_server',
'new_foreign_client',
'trigger_wake',
+ 'foreign_job_updates',
);
@EXPORT = @events;
}
+sub foreign_job_updates {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+
+ my @act_keys = keys %$msg_hash;
+ my @jobs;
+ foreach my $key (@act_keys) {
+ if ($key =~ /answer\d+/ ) { push(@jobs, $key); }
+ }
+
+ foreach my $foreign_job (@jobs) {
+
+ # add job to job queue
+ my $func_dic = {table=>$main::job_queue_tn,
+ primkey=>['macaddress', 'headertag'],
+ timestamp=>@{@{$msg_hash->{$foreign_job}}[0]->{'timestamp'}}[0],
+ status=>@{@{$msg_hash->{$foreign_job}}[0]->{'status'}}[0],
+ result=>@{@{$msg_hash->{$foreign_job}}[0]->{'result'}}[0],
+ progress=>@{@{$msg_hash->{$foreign_job}}[0]->{'progress'}}[0],
+ headertag=>@{@{$msg_hash->{$foreign_job}}[0]->{'headertag'}}[0],
+ targettag=>@{@{$msg_hash->{$foreign_job}}[0]->{'targettag'}}[0],
+ xmlmessage=>@{@{$msg_hash->{$foreign_job}}[0]->{'xmlmessage'}}[0],
+ macaddress=>@{@{$msg_hash->{$foreign_job}}[0]->{'macaddress'}}[0],
+ plainname=>@{@{$msg_hash->{$foreign_job}}[0]->{'plainname'}}[0],
+ siserver=>$source,
+ modified=>"0",
+ };
+ my $res = $main::job_db->add_dbentry($func_dic);
+ if (not $res == 0) {
+ &main::daemon_log("$session_id ERROR: ServerPackages: process_job_msg: $res", 1);
+ } else {
+ &main::daemon_log("$session_id INFO: ServerPackages: $header, job '".@{@{$msg_hash->{$foreign_job}}[0]->{'headertag'}}[0].
+ "' successfully added to job queue", 5);
+ }
+ }
+
+ return;
+}
+
+
sub new_server {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{'header'}}[0];
my $host = $_;
my $ipaddr = '255.255.255.255';
my $port = getservbyname('discard', 'udp');
+ if (not defined $port) {
+ &main::daemon_log("$session_id ERROR: cannot determine port for wol $_: 'getservbyname('discard', 'udp')' failed!",1);
+ next;
+ }
my ($raddr, $them, $proto);
my ($hwaddr, $hwaddr_re, $pkt);
# Allocate socket and send packet
$raddr = gethostbyname($ipaddr);
+ if (not defined $raddr) {
+ &main::daemon_log("$session_id ERROR: cannot determine raddr for wol $_: 'gethostbyname($ipaddr)' failed!", 1);
+ next;
+ }
+
$them = pack_sockaddr_in($port, $raddr);
$proto = getprotobyname('udp');
socket(S, AF_INET, SOCK_DGRAM, $proto) or die "socket : $!";
setsockopt(S, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt : $!";
-
send(S, $pkt, 0, $them) or die "send : $!";
close S;
}