summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5227eb5)
raw | patch | inline | side by side (parent: 5227eb5)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 25 Feb 2008 14:36:21 +0000 (14:36 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 25 Feb 2008 14:36:21 +0000 (14:36 +0000) |
mv function db_res_2_xml from GosaPackages.pm to db_res2xml in GosaSupportDaemon.pm
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9110 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9110 594d385d-05f5-0310-b6e9-bd551577e9d8
index d4297aac1f26d5f5158e2f7a69c0cee9b77e175e..cde2978231a52f3a18b92169d70dc86305d4e11d 100644 (file)
return $count;
}
+
+
+
1;
index 9161c2c805830dc1f497e63032f9a46e61d93151..b71485cfcfb806a09dfbf2424b13c10f8882e72d 100644 (file)
}
-sub db_res_2_xml {
- my ($db_res) = @_ ;
- my $xml = "<xml><header>answer</header><source>$server_address</source><target>GOSA</target>";
-
- my $len_db_res= keys %{$db_res};
- for( my $i= 1; $i<= $len_db_res; $i++ ) {
- $xml .= "\n<answer$i>";
- my $hash= $db_res->{$i};
- while ( my ($column_name, $column_value) = each %{$hash} ) {
- $xml .= "<$column_name>";
- my $xml_content;
- if( $column_name eq "xmlmessage" ) {
- $xml_content = &encode_base64($column_value);
- } else {
- $xml_content = $column_value;
- }
- $xml .= $xml_content;
- $xml .= "</$column_name>";
- }
- $xml .= "</answer$i>";
-
- }
-
- $xml .= "</xml>";
- return $xml;
-}
-
## CORE FUNCTIONS ############################################################
# execute db query
my $res_hash = $main::job_db->select_dbentry($sql_statement);
- my $out_xml = &db_res_2_xml($res_hash);
+ my $out_xml = &db_res2xml($res_hash);
my @out_msg_l = ( $out_xml );
return @out_msg_l;
}
index bcf0176dae6d27c7475eabae4360c507be9b3c01..6fecf1bb302f341162014517fc895737c755dab8 100644 (file)
"transform_msg2hash",
"get_time",
"build_msg",
+ "db_res2xml",
"get_where_statement",
"get_select_statement",
"get_update_statement",
}
+sub db_res2xml {
+ my ($db_res) = @_ ;
+ my $xml = "";
+
+ my $len_db_res= keys %{$db_res};
+ for( my $i= 1; $i<= $len_db_res; $i++ ) {
+ $xml .= "<answer$i>";
+ my $hash= $db_res->{$i};
+ while ( my ($column_name, $column_value) = each %{$hash} ) {
+ $xml .= "<$column_name>";
+ my $xml_content;
+ if( $column_name eq "xmlmessage" ) {
+ $xml_content = &encode_base64($column_value);
+ } else {
+ $xml_content = $column_value;
+ }
+ $xml .= $xml_content;
+ $xml .= "</$column_name>";
+ }
+ $xml .= "</answer$i>";
+
+ }
+
+ return $xml;
+}
+
+
sub get_where_statement {
my ($msg, $msg_hash) = @_;
my $error= 0;
index 100a75f8ae0d6c1ef6a3e09c8730e73dce5102be..ae10c2547661e0eff6e1b9dfe21392a617e6a471 100644 (file)
@ISA = qw(Exporter);
my @events = (
"get_events",
+ "get_login_usr_for_client",
+ "get_client_for_login_usr",
"gen_smb_hash",
"trigger_reload_ldap_config",
"ping",
"set_activated_for_installation",
"new_key_for_client",
"detect_hardware",
+ "get_login_usr",
+ "get_login_client",
"trigger_action_localboot",
"trigger_action_faireboot",
"trigger_action_reboot",
use strict;
use warnings;
use GOSA::GosaSupportDaemon;
+use Data::Dumper;
use Crypt::SmbHash;
use Net::ARP;
use Net::Ping;
}
+sub get_login_usr_for_client {
+ 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 $client = @{$msg_hash->{'client'}}[0];
+
+ $header =~ s/^gosa_//;
+
+ my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress='$client'";
+ my $res = $main::known_clients_db->select_dbentry($sql_statement);
+
+ my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
+ $out_msg .= &db_res2xml($res);
+ $out_msg .= "</xml>";
+
+ my @out_msg_l = ( $out_msg );
+ return @out_msg_l;
+}
+
+
+sub get_client_for_login_usr {
+ 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 $usr = @{$msg_hash->{'usr'}}[0];
+
+ my $sql_statement = "SELECT * FROM known_clients WHERE login LIKE '%$usr%'";
+ my $res = $main::known_clients_db->select_dbentry($sql_statement);
+
+ my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
+ $out_msg .= &db_res2xml($res);
+ $out_msg .= "</xml>";
+ my @out_msg_l = ( $out_msg );
+ return @out_msg_l;
+
+}
+
+
sub ping {
my ($msg, $msg_hash, $session_id) = @_ ;
my $source = @{$msg_hash->{source}}[0];
index debee10d9f2d6a0dcf305481fa17f8f3d5862afc..5fbe5f3148e4ecb84fb38bae4c842f2aaa09eb1f 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_detect_hardware</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_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+#$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>20130101000000</timestamp> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
# "trigger_action_rescan",
# "trigger_action_wake",
+# get_login_usr_for_client
+$data = "<xml> <header>gosa_get_login_usr_for_client</header> <target>GOSA</target> <source>GOSA</source> <client>00:01:6c:9d:b9:fa</client></xml>";
+# get_client_for_login_usr
+$data = "<xml> <header>gosa_get_client_for_login_usr</header> <target>GOSA</target> <source>GOSA</source> <usr>harald</usr></xml>";