From e384d94bc4b27f27e31e1a571e93c8d435f7f64d Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 11 Jul 2008 14:53:51 +0000 Subject: [PATCH] Added more functionallity - does not work right now git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11613 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/opsi.pm | 127 +++++++++++++++++++++++++++++++--- 1 file changed, 118 insertions(+), 9 deletions(-) diff --git a/gosa-si/client/events/opsi.pm b/gosa-si/client/events/opsi.pm index f9d740e45..9e016e0c3 100644 --- a/gosa-si/client/events/opsi.pm +++ b/gosa-si/client/events/opsi.pm @@ -10,10 +10,9 @@ my @events = ( "opsi_get_client_software", "opsi_get_product_properties", "opsi_set_product_properties", - - #"opsi_list_clients", - # Clients auflisten. Rückgabe -> name, dsecription - #getClients_listOfHashes + "opsi_list_clients", + "opsi_del_client", + "opsi_install_client", #"opsi_add_client", # Client hinzufügen @@ -23,7 +22,7 @@ my @events = ( # -> Description # -> Notizen - #"opsi_del_client", + #"opsi_modify_client", #"opsi_add_product_to_client", # -> set product state auf "setup" @@ -36,9 +35,6 @@ my @events = ( # -> delete nur wenn eine "uninstall" methode existiert # -> set product state auf "none" - #"opsi_install_client", - # Setze alles was auf "installed" steht auf setup - ); @EXPORT = @events; @@ -284,7 +280,7 @@ sub opsi_get_product_properties { id => 1, }; - my $res = $client->call($opsi_url, $callobj); + $res = $client->call($opsi_url, $callobj); if (check_res($res)){ my $r= $res->result; @@ -430,6 +426,51 @@ sub opsi_get_client_hardware { } +sub opsi_list_clients { + my ($msg, $msg_hash) = @_; + my $header = @{$msg_hash->{'header'}}[0]; + my $source = @{$msg_hash->{'source'}}[0]; + my $target = @{$msg_hash->{'target'}}[0]; + my $session_id = @{$msg_hash->{'session_id'}}[0]; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + + # build return message with twisted target and source + my $out_hash = &main::create_xml_hash("answer_$header", $target, $source); + &add_content2xml_hash($out_hash, "session_id", $session_id); + + if (defined $forward_to_gosa) { + &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + } + + &add_content2xml_hash($out_hash, "xxx", ""); + my $xml_msg= &create_xml_string($out_hash); + + # JSON Query + my $callobj = { + method => 'getClients_listOfHashes', + params => [ ], + id => 1, + }; + + my $res = $client->call($opsi_url, $callobj); + if (check_res($res)){ + + foreach my $host (@{$res->result}){ + my $item= "".$host->{'hostId'}.""; + if (defined($host->{'description'})){ + $item.= "".xml_quote($host->{'description'}).""; + } + $item.= ""; + $xml_msg=~ s%%$item%; + } + + } + + $xml_msg=~ s/<\/xxx>//; + return $xml_msg; +} + + sub opsi_get_client_software { my ($msg, $msg_hash) = @_; my $header = @{$msg_hash->{'header'}}[0]; @@ -633,6 +674,74 @@ sub _opsi_get_client_status { } +sub opsi_del_client { + my ($msg, $msg_hash) = @_; + my $header = @{$msg_hash->{'header'}}[0]; + my $source = @{$msg_hash->{'source'}}[0]; + my $target = @{$msg_hash->{'target'}}[0]; + my $session_id = @{$msg_hash->{'session_id'}}[0]; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + my $hostId = @{$msg_hash->{'hostId'}}[0]; + + # build return message with twisted target and source + my $out_hash = &main::create_xml_hash("answer_$header", $target, $source); + &add_content2xml_hash($out_hash, "session_id", $session_id); + + if (defined $forward_to_gosa) { + &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + } + &add_content2xml_hash($out_hash, "hostId", "$hostId"); + + # JSON Query + my $callobj = { + method => 'deleteClient', + params => [ $hostId ], + id => 1, + }; + + my $res = $client->call($opsi_url, $callobj); + + my $xml_msg= &create_xml_string($out_hash); + return $xml_msg; +} + + +# Setze alles was auf "installed" steht auf setup +sub opsi_install_client { + my ($msg, $msg_hash) = @_; + my $header = @{$msg_hash->{'header'}}[0]; + my $source = @{$msg_hash->{'source'}}[0]; + my $target = @{$msg_hash->{'target'}}[0]; + my $session_id = @{$msg_hash->{'session_id'}}[0]; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + my $hostId = @{$msg_hash->{'hostId'}}[0]; + + # build return message with twisted target and source + my $out_hash = &main::create_xml_hash("answer_$header", $target, $source); + &add_content2xml_hash($out_hash, "session_id", $session_id); + + if (defined $forward_to_gosa) { + &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + } + &add_content2xml_hash($out_hash, "hostId", "$hostId"); + +# Schaue nach produkten für diesen Host +# Setze alle Produkte dieses Hosts auf "setup" + +# # JSON Query +# my $callobj = { +# method => 'deleteClient', +# params => [ $hostId ], +# id => 1, +# }; +# +# my $res = $client->call($opsi_url, $callobj); + + my $xml_msg= &create_xml_string($out_hash); + return $xml_msg; +} + + sub _set_action { my $product= shift; my $action = shift; -- 2.30.2