summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f9b968)
raw | patch | inline | side by side (parent: 2f9b968)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 24 Sep 2008 15:00:21 +0000 (15:00 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 24 Sep 2008 15:00:21 +0000 (15:00 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12545 594d385d-05f5-0310-b6e9-bd551577e9d8
index 44f1903c46aa2042ddfb44196aa85df58f73d3ad..f3c5de809f334809070114fc605bc34e896c62e9 100644 (file)
return;
}
+
=pod
=head1 NAME
index 2ac11a3c2a00dd0b83444c385456f03d1d1ce43d..3ed08e5348fcb79e2d8c0db7ea3a8fe35cbf6c81 100644 (file)
# "import_dak_key",
# "remove_dak_key",
# "get_dak_queue",
+ "set_last_system",
);
@EXPORT = @events;
return $out_msg;
}
+## @method set_last_system()
+# @details Message set ldap attributes 'gosaLastSystemLogin' and 'gosaLastSystem'
+# @param msg - STRING - xml message with tag 'last_system_login' and 'last_system'
+# @param msg_hash - HASHREF - message information parsed into a hash
+# @param session_id - INTEGER - POE session id of the processing of this message
+sub set_last_system {
+ 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 ($last_system, $last_system_login, $mac);
+
+ # Sanity check of needed parameter
+ if (not exists $msg_hash->{'last_system'}){
+ &main::daemon_log("$session_id ERROR: message does not contain needed xml tag 'last_system', message processing stopped!", 1);
+ &main::daemon_log($msg, 1);
+ return;
+ }
+ if (@{$msg_hash->{'last_system'}} != 1) {
+ &main::daemon_log("$session_id ERROR: xml tag 'last_system' has no content or exists more than one time, message processing stopped!");
+ &ymain::daemon_log($msg, 1);
+ return;
+ }
+ if (not exists $msg_hash->{'last_system_login'}){
+ &main::daemon_log("$session_id ERROR: message does not contain needed xml tag 'last_system_login', message processing stopped!", 1);
+ &main::daemon_log($msg, 1);
+ return;
+ }
+ if (@{$msg_hash->{'last_system_login'}} != 1) {
+ &main::daemon_log("$session_id ERROR: xml tag 'last_system_login' has no content or exists more than one time, message processing stopped!");
+ &ymain::daemon_log($msg, 1);
+ return;
+ }
+ if (not exists $msg_hash->{'mac_address'}){
+ &main::daemon_log("$session_id ERROR: message does not contain needed xml tag 'mac_address', message processing stopped!", 1);
+ &main::daemon_log($msg, 1);
+ return;
+ }
+ if (@{$msg_hash->{'mac_address'}} != 1) {
+ &main::daemon_log("$session_id ERROR: xml tag 'mac_address' has no content or exists more than one time, message processing stopped!");
+ &ymain::daemon_log($msg, 1);
+ return;
+ }
+
+ # Fetch needed parameter
+ my $mac = @{$msg_hash->{'mac_address'}}[0];
+ my $last_system = @{$msg_hash->{'last_system'}}[0];
+ my $last_system_login = @{$msg_hash->{'last_system_login'}}[0];
+
+ # Fetch ldap handle
+ my $ldap_handle = &main::get_ldap_handle();
+
+ # Search for an existing entry
+ my $ldap_mesg= $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ #filter => "(&(objectClass=GOhard)(|(macAddress=$mac)(dhcpHWaddress=$mac)))",
+ filter => "(&(objectClass=GOhard)(macAddress=$mac))",
+ );
+
+ # Sanity check of ldap resutl
+ if ($ldap_mesg->count == 0) {
+ &main::daemon_log("$session_id ERROR: no system with mac address '$mac' was found in base '".$main::ldap_base."', message processing stopped!", 1);
+ } else {
+
+ # Get the entry from LDAP
+ my $ldap_entry= $ldap_mesg->pop_entry();
+
+ # Set 'gosaLastSystem' and 'gosaLastSystemLogin'
+ if (defined($ldap_entry->get_value('gosaLastSystem'))) {
+ $ldap_entry->replace ( 'gosaLastSystem' => $last_system );
+ } else {
+ $ldap_entry->add( 'gosaLastSystem' => $last_system );
+ }
+ if (defined($ldap_entry->get_value('gosaLastSystemLogin'))) {
+ $ldap_entry->replace ( 'gosaLastSystemLogin' => $last_system_login );
+ } else {
+ $ldap_entry->add( 'gosaLastSystemLogin' => $last_system_login );
+ }
+ my $result = $ldap_entry->update($ldap_handle);
+ if ($result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: setting 'gosaLastSystem' and 'gosaLastSystemLogin' of system '$mac' failed: ".
+ $result->{'errorMessage'}, 1);
+ &main::daemon_log("$session_id ERROR: $msg", 1);
+
+ }
+ }
+
+ return;
+}
+
+
+
# vim:ts=4:shiftwidth:expandtab
1;
index 450a377f5cb340dbc9a191a8604140520793bf1d..fd1d52dbbcfbf21c19e2938e433e6cfe74aff3b0 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# trigger jobs at client
- $data = "<xml> <header>gosa_trigger_goto_settings_reload</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+ #$data = "<xml> <header>gosa_trigger_goto_settings_reload</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>gosa_detect_hardware</header> <target>10.89.1.31:20083</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>job_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp></xml>";
#$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
#$data = "<xml> <header>gosa_send_user_msg</header> <target>10.89.1.30:20081</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
#$data = "<xml> <header>gosa_send_user_msg</header> <target>10.89.1.30:20081</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <user>rettenbe</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
+
+ $data = "<xml> <header>gosa_set_last_system</header> <target>10.89.1.31:20082</target> <source>GOSA</source> <mac_address>00:01:6c:9d:b9:fa</mac_address> <last_system>1.2.3.4</last_system> <last_system_login>20081212000000</last_system_login> </xml>";
##################
# recreate fai dbs
index 71d76846423ff15e42dbf720d81079a7fbdaf689..3a19cf441d4e2ea3515733c917707a20c130bc0a 100755 (executable)
my $gosa_path = "/home/rettenbe/gonicus/Projekte/gosa/trunk/gosa-si/";
my %copies = (
- "gosa-si-server"=> "/usr/sbin/gosa-si-server",
- "gosa-si-client"=> "/usr/sbin/gosa-si-client",
+ "/usr/sbin/gosa-si-server" => "gosa-si-server",
+ "/usr/sbin/gosa-si-client" => "gosa-si-client",
- "modules/GosaPackages.pm" => "/usr/lib/gosa-si/modules/GosaPackages.pm",
- "modules/ClientPackages.pm" => "/usr/lib/gosa-si/modules/ClientPackages.pm",
- "modules/ServerPackages.pm" => "/usr/lib/gosa-si/modules/ServerPackages.pm",
- "modules/ArpHandler.pm" => "/usr/lib/gosa-si/modules/ArpHandler.pm",
-
- "modules/DBsqlite.pm" => "/usr/share/perl5/GOSA/DBsqlite.pm",
- "modules/DBmysql.pm" => "/usr/share/perl5/GOSA/DBmysql.pm",
- "modules/GosaSupportDaemon.pm" => "/usr/share/perl5/GOSA/GosaSupportDaemon.pm",
-
- "server/events/clMessages.pm" => "/usr/lib/gosa-si/server/ClientPackages/clMessages.pm",
- "server/events/siTriggered" => "/usr/lib/gosa-si/server/ClientPackages/siTriggered.pm",
-
- "server/events/databases.pm" => "/usr/lib/gosa-si/server/GosaPackages/databases.pm",
- "server/events/gosaTriggered.pm" => "/usr/lib/gosa-si/server/GosaPackages/gosaTriggered.pm",
- "server/events/logHandling.pm" => "/usr/lib/gosa-si/server/GosaPackages/logHandling.pm",
- "server/events/mailqueue_com.pm" => "/usr/lib/gosa-si/server/GosaPackages/mailqueue_com.pm",
- "server/events/opsi_com.pm" => "/usr/lib/gosa-si/server/GosaPackages/opsi_com.pm",
-
- "server/events/opsi_com.pm" => "/usr/lib/gosa-si/server/ServerPackages/opsi_com.pm",
- "server/events/databases.pm" => "/usr/lib/gosa-si/server/ServerPackages/databases.pm",
- "server/events/gosaTriggered.pm" => "/usr/lib/gosa-si/server/ServerPackages/gosaTriggered.pm",
- "server/events/logHandling.pm" => "/usr/lib/gosa-si/server/ServerPackages/logHandling.pm",
- "server/events/mailqueue_com.pm" => "/usr/lib/gosa-si/server/ServerPackages/mailqueue_com.pm",
- "server/events/server_server_com.pm" => "/usr/lib/gosa-si/server/ServerPackages/server_server_com.pm",
-
- "client/events/corefunctions.pm" => "/usr/lib/gosa-si/client/events/corefunctions.pm",
- "client/events/dak.pm" => "/usr/lib/gosa-si/client/events/dak.pm",
- "client/events/gosaTriggered.pm" => "/usr/lib/gosa-si/client/events/gosaTriggered.pm",
- "client/events/installation.pm" => "/usr/lib/gosa-si/client/events/installation.pm",
- "client/events/mailqueue.pm" => "/usr/lib/gosa-si/client/events/mailqueue.pm",
+ "/usr/lib/gosa-si/modules/GosaPackages.pm" => "modules/GosaPackages.pm",
+ "/usr/lib/gosa-si/modules/ClientPackages.pm" => "modules/ClientPackages.pm",
+ "/usr/lib/gosa-si/modules/ServerPackages.pm" => "modules/ServerPackages.pm",
+ "/usr/lib/gosa-si/modules/ArpHandler.pm" => "modules/ArpHandler.pm",
+
+ "/usr/share/perl5/GOSA/DBsqlite.pm" => "modules/DBsqlite.pm",
+ "/usr/share/perl5/GOSA/DBmysql.pm" => "modules/DBmysql.pm",
+ "/usr/share/perl5/GOSA/GosaSupportDaemon.pm" => "modules/GosaSupportDaemon.pm",
+
+ "/usr/lib/gosa-si/server/ClientPackages/clMessages.pm" => "server/events/clMessages.pm",
+ "/usr/lib/gosa-si/server/ClientPackages/siTriggered.pm" => "server/events/siTriggered.pm",
+
+ "/usr/lib/gosa-si/server/GosaPackages/databases.pm" => "server/events/databases.pm",
+ "/usr/lib/gosa-si/server/GosaPackages/gosaTriggered.pm" => "server/events/gosaTriggered.pm",
+ "/usr/lib/gosa-si/server/GosaPackages/logHandling.pm" => "server/events/logHandling.pm",
+ "/usr/lib/gosa-si/server/GosaPackages/mailqueue_com.pm" => "server/events/mailqueue_com.pm",
+ "/usr/lib/gosa-si/server/GosaPackages/opsi_com.pm" => "server/events/opsi_com.pm",
+
+ "/usr/lib/gosa-si/server/ServerPackages/opsi_com.pm" => "server/events/opsi_com.pm",
+ "/usr/lib/gosa-si/server/ServerPackages/databases.pm" => "server/events/databases.pm" ,
+ "/usr/lib/gosa-si/server/ServerPackages/gosaTriggered.pm" => "server/events/gosaTriggered.pm" ,
+ "/usr/lib/gosa-si/server/ServerPackages/logHandling.pm" => "server/events/logHandling.pm",
+ "/usr/lib/gosa-si/server/ServerPackages/mailqueue_com.pm" => "server/events/mailqueue_com.pm" ,
+ "/usr/lib/gosa-si/server/ServerPackages/server_server_com.pm" => "server/events/server_server_com.pm" ,
+
+ "/usr/lib/gosa-si/client/events/corefunctions.pm" => "client/events/corefunctions.pm",
+ "/usr/lib/gosa-si/client/events/dak.pm" => "client/events/dak.pm" ,
+ "/usr/lib/gosa-si/client/events/gosaTriggered.pm" => "client/events/gosaTriggered.pm",
+ "/usr/lib/gosa-si/client/events/installation.pm" => "client/events/installation.pm",
+ "/usr/lib/gosa-si/client/events/mailqueue.pm" => "client/events/mailqueue.pm",
);
-while( my($file_name, $new_file) = each %copies ) {
+while( my($new_file, $file_name) = each %copies ) {
#print STDERR "copy ../$file_name to $new_file\n";
#system("cp ../$file_name $new_file");