summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 691efd5)
raw | patch | inline | side by side (parent: 691efd5)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 2 Sep 2008 13:16:27 +0000 (13:16 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 2 Sep 2008 13:16:27 +0000 (13:16 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12344 594d385d-05f5-0310-b6e9-bd551577e9d8
index cfea9ed8a87b0d787efdd1b471af111fb5d2837b..fd9a608f46271283e8a89bb2382eefa9dbc6fed5 100644 (file)
&main::daemon_log("0 ERROR: ClientPackages - $log_line", 1);
}
}
+# build vice versa event_hash, event_name => module
+my $event2module_hash = {};
+while (my ($module, $mod_events) = each %$event_hash) {
+ while (my ($event_name, $nothing) = each %$mod_events) {
+ $event2module_hash->{$event_name} = $module;
+ }
+
+}
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
@out_msg_l = &here_i_am($msg, $msg_hash, $session_id)
} else {
# a event exists with the header as name
- if( exists $event_hash->{$header} ) {
- &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ if( exists $event2module_hash->{$header} ) {
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event2module_hash->{$header}."'", 5);
no strict 'refs';
- @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
+ @out_msg_l = &{$event2module_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
# if no event handler is implemented
} else {
index cd8550ba77505538dab8bbf6b30837af090092df..e5dae76e15fdcd8a4f9e44148199bdea34db3712 100644 (file)
}
}
+# build vice versa event_hash, event_name => module
+my $event2module_hash = {};
+while (my ($module, $mod_events) = each %$event_hash) {
+ while (my ($event_name, $nothing) = each %$mod_events) {
+ $event2module_hash->{$event_name} = $module;
+ }
+
+}
+
## FUNCTIONS #################################################################
my $target = @{$msg_hash->{'target'}}[0];
# check local installed events
- if( exists $event_hash->{$header} ) {
+ if( exists $event2module_hash->{$header} ) {
# a event exists with the header as name
- &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event2module_hash->{$header}."'", 5);
no strict 'refs';
- @out_msg_l = &{$event_hash->{$header}."::$header"}( $msg, $msg_hash, $session_id );
+ @out_msg_l = &{$event2module_hash->{$header}."::$header"}( $msg, $msg_hash, $session_id );
# check client registered events
} else {
index f71d8df84872dfa70be293363d7783334813d9d3..cf39ee461166615c790f6776a44d6da03e39b862 100644 (file)
"get_interfaces",
"get_mac_for_interface",
"get_local_ip_for_remote_ip",
+ "get_local_mac_for_remote_ip",
"is_local",
"run_as",
"inform_all_other_si_server",
}
+sub get_local_mac_for_remote_ip {
+ my $ip = shift;
+
+ my $local_ip = &get_local_ip_for_remote_ip($ip);
+ my $network_interface= &get_interface_for_ip($local_ip);
+ my $mac = &get_mac_for_interface($network_interface);
+
+ return $mac
+}
+
+
#=== FUNCTION ================================================================
# NAME: is_local
# PARAMETERS: Server Address
index a524713b50875e0884d3d3a6402cea0d2870e714..fc1a84d5981afc1e5e2dabab05a03146a612594b 100644 (file)
"send_user_msg",
"get_available_kernel",
"trigger_activate_new",
+ "get_hosts_with_module",
# "get_dak_keyring",
# "import_dak_key",
# "remove_dak_key",
# "get_dak_queue",
- "get_opsi_hosts",
);
@EXPORT = @events;
# return @out_msg_l;
#}
+## @method get_hosts_with_module
+# Reports all GOsa-si-server providing the given module.
+# @param msg - STRING - xml message with tag get_hosts_with_module
+# @param msg_hash - HASHREF - message information parsed into a hash
+# @param session_id - INTEGER - POE session id of the processing of this message
+# @return out_msg - STRING - feedback to GOsa in success and error case
+sub get_hosts_with_module {
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $header= @{$msg_hash->{'header'}}[0];
+ my $module_name = @{$msg_hash->{'module_name'}}[0];
+ my $out_hash = &create_xml_hash($header, $target, $source);
+
+ # Sanity check of module_name
+ if ((not exists $msg_hash->{'module_name'}) || (@{$msg_hash->{'module_name'}} != 1)) {
+ &add_content2xml_hash($out_hash, "error_string", "no module_name specified or module_name tag invalid");
+ &add_content2xml_hash($out_hash, "error", "module_name");
+ &main::daemon_log("$session_id ERROR: no module_name specified or module_name tag invalid: $msg", 1);
+ return (&create_xml_string($out_hash));
+ }
-sub get_opsi_hosts {
+ # Check localhost for module_name
+ if (exists %{@{$main::known_modules->{'GosaPackages'}}[2]}->{$module_name}) {
+ my ($remote_ip, $remote_port) = split(/:/, $source);
+ my $local_mac = &get_local_mac_for_remote_ip($remote_ip);
+ &add_content2xml_hash($out_hash, "host", $local_mac);
+ }
+ # Search for opsi hosts in server_db
+ my $sql = "SELECT * FROM $main::known_server_tn WHERE loaded_modules LIKE '%$module_name%'";
+ my $res = $main::known_server_db->select_dbentry($sql);
+ while (my ($hit_id, $hit_hash) = each %$res) {
+ &add_content2xml_hash($out_hash, "host", %$hit_hash->{'macaddress'});
+ }
+
+ return (&create_xml_string($out_hash));
}
+
# vim:ts=4:shiftwidth:expandtab
1;
index b5519ba20e1b95fe15eae0e8d791328fbeacecc7..85f80c0925dd05c16a8c9bd0c477006f3953d586 100644 (file)
}
+
## @method opsi_get_client_software
# Reports client software inventory.
# @param msg - STRING - xml message with tag hostId
index 2068b35f01ad675dd689c0f990bef9f40e561352..cc509f5062547b9c9a02614aef0e1b934981695d 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# 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>";
+ # List all si-server providing opsi
+ $data = "<xml> <header>gosa_get_hosts_with_module</header> <source>GOSA</source> <target>GOSA</target> <module_name>opsi_com</module_name> </xml>";
+
##################
# recreate fai dbs
#$data = "<xml> <header>gosa_recreate_fai_server_db</header> <target>GOSA</target> <source>GOSA</source></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>";
+ #$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>linux-cl-2.intranet.gonicus.de</hostId></xml>";