Code

Updated to generate autonetwork conf
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Feb 2008 17:26:16 +0000 (17:26 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Feb 2008 17:26:16 +0000 (17:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8974 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/modules/SIPackages.pm
gosa-si/server/events/gosaTriggered.pm
gosa-si/tests/client.php

index 672ad4d627b18a0b5aa3e17a3bea4de010b52607..8f052d07c7db414b6aa2761ecb114d1537f7ae65 100644 (file)
@@ -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;
index fcde81eee0a6a42ffa88dfc30737599f469276fd..dbb7ed7f1713be365897eb55736d84650b7a0b8e 100644 (file)
@@ -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
index d0e189b53bee2d63bb2baf7b41ec68df027539b7..288676b93a25659f6ddc0b505328aae723495e2a 100755 (executable)
@@ -16,7 +16,7 @@ if($sock->connected()){
        /* Prepare a hunge bunch of data to be send */
 
 # add
-$data = "<xml> <header>gosa_ping</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target> </xml>";
+$data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source><target>GOSA</target><hostname>ws-muc-2</hostname></xml>";
 #$data = "<xml> <header>job_sayHello</header> <source>10.89.1.155:20083</source><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";
 #$data = "<xml> <header>job_ping</header> <source>10.89.1.155:20083</source> <target>10.89.1.155:20081</target><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";