summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd1b722)
raw | patch | inline | side by side (parent: dd1b722)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 1 Feb 2008 10:22:49 +0000 (10:22 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 1 Feb 2008 10:22:49 +0000 (10:22 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8713 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/modules/GosaPackages.pm | patch | blob | history | |
gosa-si/modules/SIPackages.pm | patch | blob | history |
index 6bf2e3658bcb077a4ca11e8fde1765462237e7cb..cbacc51cde3f3a24d8c95ff2bfb942e1bacc2a66 100644 (file)
use GOSA::DBsqlite;
use MIME::Base64;
-
BEGIN{}
END{}
}
# keep job queue uptodate and save result and status
- if ($out_msg =~ /<jobdb_id>(\d*?)<\/jobdb_id>/) {
+ if (defined ($out_msg) && $out_msg =~ /<jobdb_id>(\d*?)<\/jobdb_id>/) {
my $job_id = $1;
my $sql = "UPDATE '".$main::job_queue_table_name.
"' SET status='done', result='".$out_msg.
}
my @out_msg_l;
- push(@out_msg_l, $out_msg);
+ if (defined $out_msg){
+ push(@out_msg_l, $out_msg);
+ }
return \@out_msg_l;
}
$out_msg = &update_status_jobdb_entry
} elsif ($header eq 'count_jobdb' ) {
$out_msg = &count_jobdb
+ } elsif ($header eq 'trigger_action_wake' ) {
+ # Forward messages to all known servers as "trigger_wake"
+
} else {
# msg could not be assigned to core function
# fetch all available eventhandler under $server_event_dir
index e7372d8df493647fb517801de24b7374b1084f8f..ce7fdfc3f760c818ea1ff4660904784e6f7218f8 100644 (file)
use XML::Simple;
use Data::Dumper;
use Net::LDAP;
-use Socket qw/PF_INET SOCK_DGRAM inet_ntoa sockaddr_in/;
+use Socket;
+use Net::hostent;
BEGIN{}
END {}
}
+
+sub do_wake {
+ my $host = shift;
+ my $ipaddr = shift || '255.255.255.255';
+ my $port = getservbyname('discard', 'udp');
+
+ my ($raddr, $them, $proto);
+ my ($hwaddr, $hwaddr_re, $pkt);
+
+ # get the hardware address (ethernet address)
+
+ $hwaddr_re = join(':', ('[0-9A-Fa-f]{1,2}') x 6);
+ if ($host =~ m/^$hwaddr_re$/) {
+ $hwaddr = $host;
+ } else {
+ # $host is not a hardware address, try to resolve it
+ my $ip_re = join('\.', ('([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))') x 4);
+ my $ip_addr;
+ if ($host =~ m/^$ip_re$/) {
+ $ip_addr = $host;
+ } else {
+ my $h;
+ unless ($h = gethost($host)) {
+ return undef;
+ }
+ $ip_addr = inet_ntoa($h->addr);
+ }
+ }
+
+ # Generate magic sequence
+ foreach (split /:/, $hwaddr) {
+ $pkt .= chr(hex($_));
+ }
+ $pkt = chr(0xFF) x 6 . $pkt x 16;
+
+ # Allocate socket and send packet
+
+ $raddr = gethostbyname($ipaddr)->addr;
+ $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;
+}
+
+
#=== FUNCTION ================================================================
# NAME: read_configfile
# PARAMETERS: cfg_file - string -
if( 1 == length @target_l) {
my $target = $target_l[0];
if( $target eq $server_address ) {
- if ($header eq 'new_passwd') { @out_msg_l = &new_passwd($msg_hash) }
- elsif ($header eq 'here_i_am') { @out_msg_l = &here_i_am($msg_hash) }
- elsif ($header eq 'who_has') { @out_msg_l = &who_has($msg_hash) }
- elsif ($header eq 'who_has_i_do') { @out_msg_l = &who_has_i_do($msg_hash) }
- elsif ($header eq 'got_ping') { @out_msg_l = &got_ping($msg_hash)}
- elsif ($header eq 'get_load') { @out_msg_l = &execute_actions($msg_hash)}
- elsif ($header eq 'detected_hardware') { @out_msg_l = &process_detected_hardware($msg_hash)}
- else {
+ if ($header eq 'new_passwd') {
+ @out_msg_l = &new_passwd($msg_hash)
+ } elsif ($header eq 'here_i_am') {
+ @out_msg_l = &here_i_am($msg_hash)
+ } elsif ($header eq 'who_has') {
+ @out_msg_l = &who_has($msg_hash)
+ } elsif ($header eq 'who_has_i_do') {
+ @out_msg_l = &who_has_i_do($msg_hash)
+ } elsif ($header eq 'got_ping') {
+ @out_msg_l = &got_ping($msg_hash)
+ } elsif ($header eq 'get_load') {
+ @out_msg_l = &execute_actions($msg_hash)
+ } elsif ($header eq 'detected_hardware') {
+ @out_msg_l = &process_detected_hardware($msg_hash)
+ } elsif ($header eq 'trigger_wake') {
+ my $in_hash= &transform_msg2hash($msg);
+ foreach (@{$in_hash->{macAddress}}){
+ &main::daemon_log("SIPackages: trigger wake for $_", 1);
+ do_wake($_);
+ }
+
+ } else {
&main::daemon_log("ERROR: $header is an unknown core function", 1);
$error++;
}