summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df9483b)
raw | patch | inline | side by side (parent: df9483b)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Aug 2008 09:51:35 +0000 (09:51 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Aug 2008 09:51:35 +0000 (09:51 +0000) |
* bugfix: some WARNINGs are changed to ERRORs
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12242 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12242 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index f815130f14495db8883fdad8d6842b4f21d0973b..2e362facd328da98c6a5a7003786c429a1507141 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
&update_jobdb_status_for_send_msgs($answer, $error);
}
- # target of msg is a mac address
+ # Target of msg is a mac address
elsif( $answer_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) {
- daemon_log("$session_id INFO: target is mac address '$answer_target', looking for host in known_clients", 5);
+ daemon_log("$session_id INFO: target is mac address '$answer_target', looking for host in known_clients and foreign_clients", 5);
my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$answer_target'";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
my $found_ip_flag = 0;
&update_jobdb_status_for_send_msgs($answer, $error);
$found_ip_flag++ ;
}
+ if ($found_ip_flag == 0) {
+ my $sql = "SELECT * FROM $foreign_clients_tn WHERE macaddress LIKE '$answer_target'";
+ my $res = $foreign_clients_db->select_dbentry($sql);
+ while( my ($hit_num, $hit) = each %{ $res } ) {
+ my $host_name = $hit->{hostname};
+ my $reg_server = $hit->{regserver};
+ daemon_log("$session_id INFO: found host '$host_name' with mac '$answer_target', registered at '$reg_server'", 5);
+
+ # Fetch key for reg_server
+ my $reg_server_key;
+ my $sql = "SELECT * FROM $known_server_tn WHERE hostname='$reg_server'";
+ my $res = $known_server_db->select_dbentry($sql);
+ if (exists $res->{1}) {
+ $reg_server_key = $res->{1}->{'hostkey'};
+ } else {
+ daemon_log("$session_id ERROR: cannot find hostkey for '$host_name' in '$known_server_tn'", 1);
+ daemon_log("$session_id ERROR: unable to forward answer to correct registration server, processing is aborted!", 1);
+ $reg_server_key = undef;
+ }
+
+ # Send answer to server where client is registered
+ if (defined $reg_server_key) {
+ $answer =~ s/$answer_target/$host_name/g;
+ my $error = &send_msg_to_target($answer, $reg_server, $reg_server_key, $answer_header, $session_id);
+ &update_jobdb_status_for_send_msgs($answer, $error);
+ $found_ip_flag++ ;
+ }
+ }
+ }
if( $found_ip_flag == 0) {
daemon_log("$session_id WARNING: no host found in known_clients with mac address '$answer_target'", 3);
}
- # answer is for one specific host
+ # Answer is for one specific host
} else {
# get encrypt_key
my $encrypt_key = &get_encrypt_key($answer_target);
index c64264a1be58127c66af8db8ccaf988bf967719e..911e12121ed876d6a161fa4d8cace01bdf7dec53 100644 (file)
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'knownclienterror') {
&main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
- &main::daemon_log("$session_id WARNING: processing is aborted and message will not be forwarded");
+ &main::daemon_log("$session_id ERROR: processing is aborted and message will not be forwarded", 1);
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'noeventerror') {
- &main::daemon_log("$session_id WARNING: client '$target' is not registered for event '$header', processing is aborted", 1);
+ &main::daemon_log("$session_id ERROR: client '$target' is not registered for event '$header', processing is aborted", 1);
@out_msg_l = ();
}
push(@out_msg_l, $hardware_config_out);
}
+ # Send client ntp server
+
+
+
# notify registered client to all other server
my %mydata = ( 'client' => $source, 'macaddress' => $mac_address);
my $mymsg = &build_msg('new_foreign_client', $main::server_address, "KNOWN_SERVER", \%mydata);
}
+sub new_ntp_config {
+ my ($address, $session_id) = @_;
+ my $ntp_msg;
+
+ # Build LDAP connection
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
+ return;
+ }
+
+ # Perform search
+ my $ldap_res = $ldap_handle->search( base => $ldap_base,
+ scope => 'sub',
+ attrs => ['gotoNtpServer'],
+ filter => "(&(objectClass=GOhard)(macaddress=$address))");
+ if($ldap_res->code) {
+ &main::daemon_log("$session_id ".$ldap_res->error, 1);
+ return;
+ }
+
+ # Sanity check
+ if ($ldap_res->count != 1) {
+ &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ldap config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: gotoNtpServer".
+ "\n\tfilter: (&(objectClass=GOhard)(macaddress=$address))", 1);
+ return;
+ }
+
+ my $entry= $ldap_res->entry(0);
+ my $dn= $entry->dn;
+ my @ntp_servers= $entry->get_value("gotoNtpServer");
+
+ # If no ntp server is specified at host, just have a look at the object group of the host
+ # Perform object group search
+ if ((not @ntp_servers) || (@ntp_servers == 0)) {
+ my $ldap_res = $ldap_handle->search( base => $ldap_base,
+ scope => 'sub',
+ attrs => ['gotoNtpServer'],
+ filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
+ if($ldap_res->code) {
+ &main::daemon_log("$session_id ".$ldap_res->error, 1);
+ return;
+ }
+
+ # Sanity check
+ if ($ldap_res->count != 1) {
+ &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ldap config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: gotoNtpServer".
+ "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$dn))", 1);
+ return;
+ }
+
+ my $entry= $ldap_res->entry(0);
+ @ntp_servers= $entry->get_value("gotoNtpServer");
+ }
+
+ # Return if no ntp server specified
+ if ((not @ntp_servers) || (@ntp_servers == 0)) {
+ &main::daemon_log("$session_id WARNING: no ntp server specified for this host '$address'", 3);
+ return;
+ }
+
+ # Add each ntp server to 'ntp_config' message
+ my $ntp_msg_hash = &create_xml_hash("ntp_config", $server_address, $address);
+ foreach my $ntp_server (@ntp_servers) {
+ &add_content2xml_hash($ntp_msg_hash, "server", $ntp_server);
+ }
+
+ return &create_xml_string($ntp_msg_hash);
+}
+
+
#=== FUNCTION ================================================================
# NAME: new_ldap_config
# PARAMETERS: address - string - ip address and port of a host
index d50cdea1600645fa4ed259ffee29409123523ab4..66184387d0749ccb33d2f1feb63a054ab9c3c447 100644 (file)
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'knownclienterror') {
&main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
- &main::daemon_log("$session_id WARNING: processing is aborted and message will not be forwarded", 3);
+ &main::daemon_log("$session_id ERROR: processing is aborted and message will not be forwarded", 1);
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'noeventerror') {
- &main::daemon_log("$session_id WARNING: client '$target' is not registered for event '$header', processing is aborted", 3);
+ &main::daemon_log("$session_id ERROR: client '$target' is not registered for event '$header', processing is aborted", 1);
@out_msg_l = ();
}
index d429ffe7b28baa017e37b066c4e152055b9498d6..2f74dfd7678e3bf3a55a78bf68f878437453f840 100644 (file)
"get_login_usr_for_client",
"get_client_for_login_usr",
"gen_smb_hash",
+ "trigger_reload_ntp_config",
"trigger_reload_ldap_config",
"ping",
"network_completition",
}
+sub trigger_reload_ntp_config {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $target = @{$msg_hash->{target}}[0];
+
+ # Sanity check of macaddress
+ # TODO
+
+ my $macaddress = @{$msg_hash->{macaddress}}[0];
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+ my $out_msg = &ClientPackages::new_ntp_config($macaddress, $session_id);
+ my @out_msg_l = ( $out_msg );
+
+ return @out_msg_l;
+
+}
sub trigger_reload_ldap_config {
my ($msg, $msg_hash, $session_id) = @_ ;
index 65512c140acffd5a40be9a3d50fe36573b0509d0..772cc39f682456b75c2e11681e5d57c5b52088a7 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_opsi_get_netboot_products</header> <source>GOSA</source> <target>GOSA</target> </xml>";
# Get netboot product for specific host
- #$data = "<xml> <header>gosa_opsi_get_netboot_products</header> <source>GOSA</source> <target>GOSA</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId></xml>";
+ #$data = "<xml> <header>gosa_opsi_get_netboot_products</header> <source>GOSA</source> <target>GOSA</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
# Get all localboot products
#$data = "<xml> <header>gosa_opsi_get_local_products</header> <source>GOSA</source> <target>GOSA</target> </xml>";
# Get localboot product for specific host
- #$data = "<xml> <header>gosa_opsi_get_local_products</header> <source>GOSA</source> <target>GOSA</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId></xml>";
+ #$data = "<xml> <header>gosa_opsi_get_local_products</header> <source>GOSA</source> <target>GOSA</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
# Get product properties - global
#$data = "<xml> <header>gosa_opsi_get_product_properties</header> <source>GOSA</source> <target>GOSA</target> <productId>firefox</productId></xml>";
# Get product properties - per host
- #$data = "<xml> <header>gosa_opsi_get_product_properties</header> <source>GOSA</source> <target>GOSA</target> <productId>firefox</productId> <hostId>limux-cl-2.intranet.gonicus.de</hostId> </xml>";
+ #$data = "<xml> <header>gosa_opsi_get_product_properties</header> <source>GOSA</source> <target>GOSA</target> <productId>firefox</productId> <hostId>linux-cl-2.intranet.gonicus.de</hostId> </xml>";
# Set product properties - global
#$data = "<xml> <header>gosa_opsi_set_product_properties</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <productId>firefox</productId> <item><name>askbeforeinst</name><value>false</value></item></xml>";
# Set product properties - per host
- #$data = "<xml> <header>gosa_opsi_set_product_properties</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> <productId>firefox</productId> <item> <name>askbeforeinst</name> <value>false</value> </item> </xml>";
+ #$data = "<xml> <header>gosa_opsi_set_product_properties</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>firefox</productId> <item> <name>askbeforeinst</name> <value>false</value> </item> </xml>";
# Get hardware inventory
- #$data = "<xml> <header>gosa_opsi_get_client_hardware</header> <source>GOSA</source> <target>GOSA</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> </xml>";
+ #$data = "<xml> <header>gosa_opsi_get_client_hardware</header> <source>GOSA</source> <target>GOSA</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> </xml>";
# Get software inventory
- #$data = "<xml> <header>gosa_opsi_get_client_software</header> <source>GOSA</source> <target>GOSA</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> </xml>";
+ #$data = "<xml> <header>gosa_opsi_get_client_software</header> <source>GOSA</source> <target>GOSA</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> </xml>";
# List Opsi clients
#$data = "<xml> <header>gosa_opsi_list_clients</header> <source>GOSA</source> <target>GOSA</target> </xml>";
# Delete Opsi client
- #$data = "<xml> <header>gosa_opsi_del_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId></xml>";
+ #$data = "<xml> <header>gosa_opsi_del_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
# Install Opsi client
# Please do always use 'job_...' and never 'gosa_...' otherways the job will never appear in job queue
- $data = "<xml> <header>job_opsi_install_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> </xml>";
+ #$data = "<xml> <header>job_opsi_install_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> </xml>";
# Add Opsi client
- #$data = "<xml> <header>gosa_opsi_add_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <description>Test halt</description> <ip>1.2.3.4</ip> <notes>Im a note</notes> </xml>";
+ #$data = "<xml> <header>gosa_opsi_add_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <description>Test halt</description> <ip>1.2.3.4</ip> <notes>Im a note</notes> </xml>";
# Add product to Opsi client
- #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>limux-cl-2.intranet.gonicus.de</hostId> <productId>winxppro</productId> </xml>";
+ #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>winxppro</productId> </xml>";
# Delete product from Opsi client
- #$data = "<xml> <header>gosa_opsi_del_product_from_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-1.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <productId>softprod</productId> </xml>";
+ #$data = "<xml> <header>gosa_opsi_del_product_from_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-1.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <productId>softprod</productId> </xml>";
#########################
#$data = "<xml> <header>gosa_import_dak_key</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> </xml>";
#$data = "<xml> <header>gosa_remove_dak_key</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> </xml>";
+
+ ##############################
+ # NTP reload
+ $data = "<xml> <header>gosa_trigger_reload_ntp_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:11:25:4B:8C:E5</macaddress> </xml>";
+
$sock->write($data);
$answer = "nothing";
$answer = $sock->read();