From c13f8ccf91b64d8c6488a8b29c2a05673bdf9592 Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 19 Feb 2008 17:26:16 +0000 Subject: [PATCH] Updated to generate autonetwork conf git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8974 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/modules/SIPackages.pm | 11 +++++----- gosa-si/server/events/gosaTriggered.pm | 30 ++++++++++++++++++++++++++ gosa-si/tests/client.php | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 672ad4d62..8f052d07c 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -433,16 +433,14 @@ sub process_incoming_msg { &main::daemon_log("SIPackages: trigger wake for $_", 1); do_wake($_); } - } else { &main::daemon_log("ERROR: $header is an unknown core function", 1); $error++; } - } - else { - &main::daemon_log("msg is not for gosa-si-server '$server_address', deliver it to target '$target'", 5); - push(@out_msg_l, $msg); - } + } else { + &main::daemon_log("msg is not for gosa-si-server '$server_address', deliver it to target '$target'", 5); + push(@out_msg_l, $msg); + } } return \@out_msg_l; @@ -1195,4 +1193,5 @@ sub execute_actions { } +#vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: 1; diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index fcde81eee..dbb7ed7f1 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -4,6 +4,7 @@ use Exporter; my @events = ( "get_events", "ping", + "network_completition", "set_activated_for_installation", "new_key_for_client", "detect_hardware", @@ -22,6 +23,9 @@ my @events = ( use strict; use warnings; use GOSA::GosaSupportDaemon; +use Net::ARP; +use Net::Ping; +use Socket; BEGIN {} @@ -47,6 +51,32 @@ sub ping { return ( $out_msg ); } +sub network_completition { + my ($msg, $msg_hash, $session_id) = @_ ; + my $source = @{$msg_hash->{source}}[0]; + my $target = @{$msg_hash->{target}}[0]; + my $name = @{$msg_hash->{hostname}}[0]; + + # Can we resolv the name? + my %data; + if (inet_aton($name)){ + my $address = inet_ntoa(inet_aton($name)); + my $p = Net::Ping->new('tcp'); + my $mac= ""; + if ($p->ping($address, 1)){ + $mac = Net::ARP::arp_lookup("", $address); + } + + %data= ('ip' => $address, 'mac' => $mac); + } else { + %data= ('ip' => '', 'mac' => ''); + } + + my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data ); + + return ( $out_msg ); +} + sub detect_hardware { my ($msg, $msg_hash) = @_ ; # just forward msg to client, but dont forget to split off 'gosa_' in header diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index d0e189b53..288676b93 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -16,7 +16,7 @@ if($sock->connected()){ /* Prepare a hunge bunch of data to be send */ # add -$data = "
gosa_ping
GOSA00:01:6c:9d:b9:fa
"; +$data = "
gosa_network_completition
GOSAGOSAws-muc-2
"; #$data = "
job_sayHello
10.89.1.155:2008300:1B:77:04:8A:6C 20130102133900
"; #$data = "
job_ping
10.89.1.155:20083 10.89.1.155:2008100:1B:77:04:8A:6C 20130102133900
"; -- 2.30.2