summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce4c2c3)
raw | patch | inline | side by side (parent: ce4c2c3)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 15 Feb 2008 17:51:37 +0000 (17:51 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 15 Feb 2008 17:51:37 +0000 (17:51 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8940 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/corefunctions.pm | patch | blob | history | |
gosa-si/client/events/gosaTriggered.pm | [new file with mode: 0644] | patch | blob |
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/GosaPackages.pm | patch | blob | history | |
gosa-si/server/events/installation.pm | [deleted file] | patch | blob | history |
gosa-si/tests/client.php | patch | blob | history |
index d0126a28e1e45c20944d765885679d8f5ccede4e..80589e863fe2c5d9dcb1a189e4fdb24eceddc894 100644 (file)
package corefunctions;
use Exporter;
@ISA = qw(Exporter);
-my @events = qw(get_events registered new_ldap_config new_key generate_hw_digest detect_hardware reboot halt reinstall softupdate confirm_new_key);
+my @events = qw(get_events registered new_ldap_config new_key generate_hw_digest detect_hardware confirm_new_key ping import_events);
@EXPORT = @events;
use strict;
if( $error == 0 ) {
chomp($string);
-
- open(FILE, ">> $file");
+
+ if( not -f $file ) {
+ open (FILE, "$file");
+ close(FILE);
+ }
+ open(FILE, ">> $file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);;
print FILE $string."\n";
close(FILE);
}
}
-sub reboot {
- my ($msg, $msg_hash) = @_ ;
- &main::daemon_log("got reboot-msg: $msg", 5);
- return;
-}
-
-
-sub halt {
- my ($msg, $msg_hash) = @_ ;
-
- &main::daemon_log("got halt-msg: $msg", 5);
- return;
-}
-
-
-sub reinstall {
- my ($msg, $msg_hash) = @_ ;
- &main::daemon_log("got reinstall-msg: $msg", 5);
-
- return;
-}
-
-
-sub softupdate {
- my ($msg, $msg_hash) = @_ ;
- &main::daemon_log("got softupdate-msg: $msg", 5);
-
- return;
-}
-
-
sub registered {
my ($msg, $msg_hash) = @_ ;
}
-
1;
diff --git a/gosa-si/client/events/gosaTriggered.pm b/gosa-si/client/events/gosaTriggered.pm
--- /dev/null
@@ -0,0 +1,222 @@
+package gosaTriggered;
+use Exporter;
+@ISA = qw(Exporter);
+my @events = (
+ "get_events",
+ "trigger_action_localboot",
+ "trigger_action_halt",
+ "trigger_action_reboot",
+ "trigger_action_memcheck",
+ "trigger_action_reinstall",
+ "trigger_action_update",
+ "trigger_action_instant_update",
+ "trigger_action_sysinfo",
+ "trigger_action_rescan",
+ );
+@EXPORT = @events;
+
+use strict;
+use warnings;
+
+
+BEGIN {}
+
+END {}
+
+
+sub get_events { return \@events; }
+
+
+sub trigger_action_localboot {
+ my ($msg, $msg_hash) = @_;
+ my $timeout;
+
+ if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
+ $timeout = -1;
+ }
+ else {
+ $timeout = @{$msg_hash->{timeout}}[0];
+ }
+
+ # check logged in user
+ my $logged_in_user = 1;
+ if( $logged_in_user ) {
+ # TODO do something
+ }
+ else {
+ $timeout = 0;
+ }
+
+ # execute function
+ if( $timeout == 0 ) {
+ print STDERR ("shutdown -r +$timeout\n");
+ }
+ elsif( $timeout > 0 ) {
+ print STDERR ("shutdown -r +$timeout\n");
+ }
+ elsif( $timeout < 0 ) {
+ print STDERR "The administrator has sent a signal to reboot this workstation. It will reboot after you've logged out.\n";
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "trigger_action_localboot\n";
+ close(FILE);
+ }
+ else {
+ # TODO do something, error handling, logging
+ }
+
+ return;
+}
+
+
+sub trigger_action_reboot {
+ my ($msg, $msg_hash) = @_;
+ print STDERR "jetzt würde ich trigger_action_reboot ausführen\n";
+ return;
+}
+
+
+sub trigger_action_halt {
+ my ($msg, $msg_hash) = @_;
+ my $timeout;
+
+ if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
+ $timeout = -1;
+ }
+ else {
+ $timeout = @{$msg_hash->{timeout}}[0];
+ }
+
+ # check logged in user
+ my $logged_in_user = 1;
+ if( $logged_in_user ) {
+ # TODO do something
+ }
+ else {
+ $timeout = 0;
+ }
+
+ # execute function
+ if( $timeout == 0 ) {
+ print STDERR ("shutdown -h +$timeout\n");
+ }
+ elsif( $timeout > 0 ) {
+ print STDERR ("shutdown -h +$timeout\n");
+ }
+ elsif( $timeout < 0 ) {
+ print STDERR "The administrator has sent a signal to shutdown this workstation. It will shutdown after you've logged out.\n";
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "trigger_action_halt\n";
+ close(FILE);
+ }
+ else {
+ # TODO do something, error handling, logging
+ }
+
+ return;
+}
+
+
+# TODO
+sub trigger_action_memcheck {
+ my ($msg, $msg_hash) = @_ ;
+ print STDERR "\n\njetzt würde ich trigger_action_memcheck ausführen\n\n";
+ return;
+}
+
+
+sub trigger_action_reinstall {
+ my ($msg, $msg_hash) = @_;
+ my $timeout;
+
+ # check timeout
+ if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
+ $timeout = -1;
+ }
+ else {
+ $timeout = @{$msg_hash->{timeout}}[0];
+ }
+
+ # check logged in user
+ my $logged_in_user = 1;
+ if( $logged_in_user ) {
+ # TODO do something
+ }
+ else {
+ $timeout = 0;
+ }
+
+ # execute function
+ if( $timeout == 0 ) {
+ print STDERR ("shutdown -r +$timeout\n");
+ }
+ elsif( $timeout > 0 ) {
+ print STDERR ("shutdown -r +$timeout\n");
+
+ }
+ elsif( $timeout < 0 ) {
+ print STDERR "The administrator has sent a signal to reinstall this workstation. It will reinstall after you've logged out.\n";
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "trigger_action_reinstall\n";
+ close(FILE);
+ }
+ else {
+ # TODO do something, error handling, logging
+ }
+
+ return;
+}
+
+
+sub trigger_action_update {
+ my ($msg, $msg_hash) = @_;
+
+ # execute function
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "trigger_action_reinstall\n";
+ close(FILE);
+
+ # check logged in user
+ my $logged_in_user = 1;
+ if( $logged_in_user ) {
+ print STDERR "This system has been sent a signal for an update. The update will take place after you log out.\n";
+ }
+ else {
+ # not jet
+ #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" )
+ }
+
+ return;
+}
+
+
+sub trigger_action_instant_update {
+ my ($msg, $msg_hash) = @_;
+
+ # check logged in user
+ my $logged_in_user = 1;
+ if( $logged_in_user ) {
+ print STDERR "This system has been sent a signal for an update. The update will take place now.\n";
+ }
+
+ # not jet
+ #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" )
+
+ return;
+}
+
+
+# TODO
+sub trigger_action_sysinfo {
+ my ($msg, $msg_hash) = @_;
+ print STDERR "jetzt würde ich trigger_action_sysinfo ausführen\n";
+ return;
+}
+
+# TODO
+sub trigger_action_rescan{
+ my ($msg, $msg_hash) = @_;
+ print STDERR "jetzt würde ich trigger_action_rescan ausführen\n";
+ return;
+}
+
+1;
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 27de3ab341ee1a12ad2ad98bf5a3c441f7166097..cf4488c25231bbbaec239859f8a9dfc9c2bbd1f8 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
}
}
+
+ my @all_events = keys %$event_hash;
+ my $all_events_string = join(", ", @all_events);
+
+ daemon_log("INFO: imported events: $all_events_string", 5);
}
sub trigger_new_key {
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index e3849b442ae309a6a56b12b402b7fffab0883c0a..570906585df085ba9d7546697b33dac252526a7b 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
daemon_log("Incoming msg from '".$heap->{'remote_ip'}."'", 7);
daemon_log("\n$input", 8);
+ ####################
+ # check incoming msg
# msg is from a new client or gosa
($msg, $msg_hash, $module) = &input_from_unknown_host($input);
# msg is from a gosa-si-server or gosa-si-bus
index 7ea3e54f03d36dac9f938fbc98dfa571fddbed58..bc067c3372f5f0ec5ab041d37eeade76f8aca9df 100644 (file)
# decide wether msg is a core function or a event handler
if ( $header eq 'query_jobdb') {
- $out_msg = &query_jobdb
+ $out_msg = &query_jobdb
} elsif ($header eq 'delete_jobdb_entry') {
$out_msg = &delete_jobdb_entry
} elsif ($header eq 'clear_jobdb') {
- $out_msg = &clear_jobdb
+ $out_msg = &clear_jobdb
} elsif ($header eq 'update_status_jobdb_entry' ) {
- $out_msg = &update_status_jobdb_entry
+ $out_msg = &update_status_jobdb_entry
} elsif ($header eq 'count_jobdb' ) {
$out_msg = &count_jobdb
- } elsif ($header eq 'trigger_action_reboot' ) {
- print STDERR "trigger_action_reboot\n";
- print STDERR Dumper($msg);
} elsif ($header eq 'trigger_action_wake' ) {
- # Forward messages to all known servers as "trigger_wake"
- my $in_hash= &transform_msg2hash($msg);
- my %data = ( 'macAddress' => \@{$in_hash->{macAddress}} );
- $out_msg = &send_msg("trigger_wake", $server_address, "KNOWN_SERVER", \%data);
+ # Forward messages to all known servers as "trigger_wake"
+ my $in_hash= &transform_msg2hash($msg);
+ my %data = ( 'macAddress' => \@{$in_hash->{macAddress}} );
+ $out_msg = &send_msg("trigger_wake", $server_address, "KNOWN_SERVER", \%data);
} else {
# msg could not be assigned to core function
# maybe it is an eventa
diff --git a/gosa-si/server/events/installation.pm b/gosa-si/server/events/installation.pm
+++ /dev/null
@@ -1,93 +0,0 @@
-package installation;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = qw(get_events set_activated_for_installation reboot halt softupdate reinstall new_key_for_client detect_hardware);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-
-
-BEGIN {}
-
-END {}
-
-### Start ######################################################################
-
-#&main::read_configfile($main::cfg_file, %cfg_defaults);
-
-sub get_events {
- return \@events;
-}
-
-
-sub detect_hardware {
- my ($msg, $msg_hash) = @_ ;
- # just forward msg to client, but dont forget to split off 'gosa_' in header
- my $header = @{$msg_hash->{header}}[0];
- my $source = @{$msg_hash->{source}}[0];
- my $target = @{$msg_hash->{target}}[0];
-
- my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
- my $out_msg = &create_xml_string($out_hash);
-
- return $out_msg;
-}
-
-
-sub set_activated_for_installation {
- my ($msg, $msg_hash) = @_;
-
- my $header = @{$msg_hash->{header}}[0];
- my $source = @{$msg_hash->{source}}[0];
- my $target = @{$msg_hash->{target}}[0];
-
- my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
- my $out_msg = &create_xml_string($out_hash);
-
- return $out_msg;
-}
-
-sub reboot {
- my ($msg, $msg_hash) = @_;
- $msg =~ s/<header>gosa_reboot<\/header>/<header>reboot<\/header>/;
-
- return $msg;
-}
-
-
-sub halt {
- my ($msg, $msg_hash) = @_;
- $msg =~ s/<header>gosa_halt<\/header>/<header>halt<\/header>/;
-
- return $msg;
-}
-
-
-sub reinstall {
- my ($msg, $msg_hash) = @_;
- $msg =~ s/<header>gosa_reinstall<\/header>/<header>reinstall<\/header>/;
-
- return $msg;
-}
-
-
-sub softupdate {
- my ($msg, $msg_hash) = @_;
- $msg =~ s/<header>gosa_softupdate<\/header>/<header>softupdate<\/header>/;
-
- return $msg;
-}
-
-
-sub new_key_for_client {
- my ($msg, $msg_hash) = @_;
- $msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
-
- return $msg;
-}
-
-
-
-1;
index c0d3332d0344ffe11144fa77ed756dea1eda2ad9..98391deab9b9a3b268ca473b87e8a2e51b261295 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_halt</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</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>gosa_new_key_for_client</header> <target>00:0c:29:bd:7b:e7</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.12:1234</target> <source>10.89.1.31:20081</source> </xml>";
+#$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.12:1234</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
+#$data = "<xml> <header>gosa_import_events</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
+$data = "<xml> <header>gosa_trigger_action_localboot</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> <timeout>-1</timeout></xml>";
+
+
+
$sock->write($data);
$answer = "nothing";
$answer = $sock->read();