From: rettenbe Date: Mon, 4 Aug 2008 15:34:45 +0000 (+0000) Subject: update: opsi server integration X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ea53736850828e3dc24174b43ddeb56201bc7140;p=gosa.git update: opsi server integration git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12145 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/opsi.pm b/gosa-si/client/events/opsi.pm index 82bf4f88d..0b5e91032 100644 --- a/gosa-si/client/events/opsi.pm +++ b/gosa-si/client/events/opsi.pm @@ -65,12 +65,13 @@ my %cfg_defaults = ( "password" => [\$opsi_password, "secret"], }, ); -&read_configfile($main::cfg_file, %cfg_defaults); +&GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults); # Assemble opsi URL my $opsi_url= "https://".$opsi_admin.":".$opsi_password."@".$opsi_server.":4447/rpc"; my $client = new JSON::RPC::Client; + sub check_res { my $res= shift; # TODO: We need to return the outhash!? @@ -92,28 +93,6 @@ sub check_res { } -sub read_configfile { - my ($cfg_file, %cfg_defaults) = @_; - my $cfg; - - if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { - if( -r $cfg_file ) { - $cfg = Config::IniFiles->new( -file => $cfg_file ); - } else { - &main::daemon_log("ERROR: opsi.pm couldn't read config file!", 1); - } - } else { - $cfg = Config::IniFiles->new() ; - } - foreach my $section (keys %cfg_defaults) { - foreach my $param (keys %{$cfg_defaults{ $section }}) { - my $pinfo = $cfg_defaults{ $section }{ $param }; - ${@$pinfo[0]} = $cfg->val( $section, $param, @$pinfo[1] ); - } - } -} - - sub get_events { return \@events; } diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index dc72ee5b1..cba9f5987 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -145,33 +145,6 @@ sub check_cmdline_param () { } -#=== FUNCTION ================================================================ -# NAME: read_configfile -# PARAMETERS: cfg_file - string - -# RETURNS: -# DESCRIPTION: -#=============================================================================== -sub read_configfile { - my ($cfg_file, %cfg_defaults) = @_ ; - my $cfg; - if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { - if( -r $cfg_file ) { - $cfg = Config::IniFiles->new( -file => $cfg_file ); - } else { - print STDERR "Couldn't read config file!"; - } - } else { - $cfg = Config::IniFiles->new() ; - } - foreach my $section (keys %cfg_defaults) { - foreach my $param (keys %{$cfg_defaults{ $section }}) { - my $pinfo = $cfg_defaults{ $section }{ $param }; - ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] ); - } - } -} - - #=== FUNCTION ================================================================ # NAME: check_pid # PARAMETERS: diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 1a79a5783..e273e9e0c 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -204,6 +204,10 @@ my @msgs_to_decrypt = qw(); my $max_children = 2; +# loop delay for job queue to look for opsi jobs +my $job_queue_opsi_delay = 2; + + %cfg_defaults = ( "general" => { "log-file" => [\$log_file, "/var/run/".$prg.".log"], @@ -854,7 +858,7 @@ sub get_local_ip_for_remote_ip { } } } else { - daemon_log("get_local_ip_for_remote_ip was called with a non-ip parameter: $remote_ip", 1); + daemon_log("0 WARNING: get_local_ip_for_remote_ip() was called with a non-ip parameter: '$remote_ip'", 1); } return $result; } @@ -1441,6 +1445,7 @@ sub session_start { $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay); $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay); $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay); + $kernel->delay_set('watch_for_opsi_jobs', $job_queue_opsi_delay); $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay); @@ -1467,6 +1472,69 @@ sub watch_for_done_jobs { } +sub watch_for_opsi_jobs { + my ($kernel) = @_[KERNEL]; + + my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((headertag='opsi_install_client') AND (status='processing'))"; + my $res = $job_db->select_dbentry( $sql_statement ); + + while (my ($id, $hit) = each %$res ) { + + # Ask OPSI for an update of the running jobs + my $hostId = $hit->{'plainname'}; + print STDERR "\n\n$hostId\n"; +# my $result= {}; +# +# # For hosts, only return the products that are or get installed +# my $callobj; +# $callobj = { +# method => 'getProductStates_hash', +# params => [ $hostId ], +# id => 1, +# }; +# +# my $hres = $client->call($opsi_url, $callobj); +# if (check_res($hres)){ +# my $htmp= $hres->result->{$hostId}; +# +# # check state != not_installed or action == setup -> load and add +# my $products= 0; +# my $installed= 0; +# my $error= 0; +# foreach my $product (@{$htmp}){ +# +# if ($product->{'installationStatus'} ne "not_installed" or +# $product->{'actionRequest'} eq "setup"){ +# +# # Increase number of products for this host +# $products++; +# +# if ($product->{'installationStatus'} eq "failed"){ +# $result->{$product->{'productId'}}= "error"; +# $error++; +# } +# if ($product->{'installationStatus'} eq "installed"){ +# $result->{$product->{'productId'}}= "installed"; +# $installed++; +# } +# if ($product->{'installationStatus'} eq "installing"){ +# $result->{$product->{'productId'}}= "installing"; +# } +# } +# } +# +# # Estimate "rough" progress +# $result->{'progress'}= int($installed * 100 / $products); +#} +# +#return $result; +# + } + + $kernel->delay_set('watch_for_opsi_jobs', $job_queue_opsi_delay); +} + + # if a job got an update or was modified anyway, send to all other si-server an update message # of this jobs sub watch_for_modified_jobs { @@ -1591,7 +1659,6 @@ sub watch_for_new_jobs { } - sub watch_for_new_messages { my ($kernel,$heap) = @_[KERNEL, HEAP]; my @coll_user_msg; # collection list of outgoing messages @@ -2531,6 +2598,7 @@ sub create_packages_list_db { close (CONFIG); + find(\&cleanup_and_extract, keys( %repo_dirs )); &main::strip_packages_list_statements(); unshift @packages_list_statements, "VACUUM"; @@ -2779,7 +2847,7 @@ sub cleanup_and_extract { if( -f "$dir/DEBIAN/templates" ) { - daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5); + daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 7); my $tmpl= ""; { @@ -3050,6 +3118,7 @@ POE::Session->create( watch_for_new_jobs => \&watch_for_new_jobs, watch_for_modified_jobs => \&watch_for_modified_jobs, watch_for_done_jobs => \&watch_for_done_jobs, + watch_for_opsi_jobs => \&watch_for_opsi_jobs, watch_for_old_known_clients => \&watch_for_old_known_clients, create_packages_list_db => \&run_create_packages_list_db, create_fai_server_db => \&run_create_fai_server_db, diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index f94db5dfe..ecc70afb1 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -114,14 +114,13 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_network_completition
GOSA GOSA localhost
"; - ######## + #################################################################### # Opsi testing # Get all netboot products #$data = "
gosa_opsi_get_netboot_products
GOSA 00:01:6c:9d:aa:16
"; # Get netboot product for specific host - # --> #$data = "
gosa_opsi_get_netboot_products
GOSA 00:01:6c:9d:aa:16 limux-cl-2.intranet.gonicus.de
"; # Get all localboot products @@ -155,7 +154,7 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_opsi_del_client
GOSA 00:01:6c:9d:aa:16 sdfgsg.intranet.gonicus.de
"; # Install Opsi client - $data = "
gosa_opsi_install_client
GOSA 00:01:6c:9d:aa:16 limux-cl-2.intranet.gonicus.de
"; + $data = "
gosa_opsi_install_client
GOSA 00:01:6c:9d:b9:fa limux-cl-2.intranet.gonicus.de 11:22:33:44:55:66
"; ######################### @@ -173,7 +172,7 @@ for($count = 1; $count <= $zahl; $count++) ######################## # DAK Debian Archive Kit - $data = "
gosa_get_dak_keyring
GOSA 00:01:6c:9d:b9:fa
"; + #$data = "
gosa_get_dak_keyring
GOSA 00:01:6c:9d:b9:fa
"; #$data = "
gosa_import_dak_key
GOSA 00:01:6c:9d:b9:fa
"; #$data = "
gosa_remove_dak_key
GOSA 00:01:6c:9d:b9:fa
";