summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5cc4897)
raw | patch | inline | side by side (parent: 5cc4897)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Aug 2009 09:35:54 +0000 (09:35 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Aug 2009 09:35:54 +0000 (09:35 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14138 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/server/events/opsi_com.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
index e1abfe770914666b18d67b481a3ae7f98f725e28..f1df5a4b436f363d0c8223928ea42039cf8b61b4 100644 (file)
"opsi_getLicensePool_hash",
"opsi_getSoftwareLicenseUsages_listOfHashes",
"opsi_getLicensePools_listOfHashes",
+ "opsi_getLicenseInformationForProduct",
"opsi_test",
);
@EXPORT = @events;
#
# @brief
#
-#sub opsi_getLicenses_list {
-# my ($msg, $msg_hash, $session_id) = @_;
-# my $header = @{$msg_hash->{'header'}}[0];
-# my $source = @{$msg_hash->{'source'}}[0];
-# my $hostId;
-# my $licensePoolId;
-# my $out_hash;
-#
-# # Check input sanity
-# if (&_check_xml_tag_is_ok ($msg_hash, 'hostId')) {
-# $hostId = @{$msg_hash->{'hostId'}}[0];
-# } else {
-# return ( &_give_feedback($msg, $msg_hash, $session_id, $_) );
-# }
-# if (&_check_xml_tag_is_ok ($msg_hash, 'licensePoolId')) {
-# $licensePoolId = @{$msg_hash->{'licensePoolId'}}[0];
-# } else {
-# return ( &_give_feedback($msg, $msg_hash, $session_id, $_) );
-# }
-#
-# # Fetch infos from Opsi server
-# my $callobj = {
-# method => 'getLicensePoolIds_list',
-# params => [ ],
-# id => 1,
-# };
-# my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-#
-# # Check Opsi error
-# my ($res_error, $res_error_str) = &check_opsi_res($res);
-# if ($res_error){
-# # Create error message
-# &main::daemon_log("$session_id ERROR: cannot get license pool ID list from Opsi server: ".$res_error_str, 1);
-# $out_hash = &main::create_xml_hash("error_$header", $main::server_address, $source, $res_error_str);
-#
-# } else {
-# # Create function result message
-# $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
-# map(&add_content2xml_hash($out_hash, "licensePoolIds", "$_"), @{$res->result});
-# }
-#
-# return ( &create_xml_string($out_hash) );
-#}
+sub opsi_getLicenseInformationForProduct {
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $productId;
+ my $out_hash;
+
+ # Check input sanity
+ if (&_check_xml_tag_is_ok ($msg_hash, 'productId')) {
+ $productId = @{$msg_hash->{'productId'}}[0];
+ } else {
+ return ( &_give_feedback($msg, $msg_hash, $session_id, $_) );
+ }
+
+ # Fetch infos from Opsi server
+ my $callobj = {
+ method => 'getLicensePoolId',
+ params => [ $productId ],
+ id => 1,
+ };
+ my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+
+ # Check Opsi error
+ my ($res_error, $res_error_str) = &check_opsi_res($res);
+ if ($res_error){
+ # Create error message
+ &main::daemon_log("$session_id ERROR: cannot get license pool for product '$productId' : ".$res_error_str, 1);
+ $out_hash = &main::create_xml_hash("error_$header", $main::server_address, $source, $res_error_str);
+ return ( &create_xml_string($out_hash) );
+ }
+
+ my $licensePoolId = $res->result;
+
+ # Fetch statistic information for given pool ID
+ my $callobj = {
+ method => 'getLicenseStatistics_hash',
+ params => [ ],
+ id => 1,
+ };
+ my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+
+ # Check Opsi error
+ my ($res_error, $res_error_str) = &check_opsi_res($res);
+ if ($res_error){
+ # Create error message
+ &main::daemon_log("$session_id ERROR: cannot get statistic informations for license pools : ".$res_error_str, 1);
+ $out_hash = &main::create_xml_hash("error_$header", $main::server_address, $source, $res_error_str);
+ return ( &create_xml_string($out_hash) );
+ }
+
+ # Create function result message
+ $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
+ &add_content2xml_hash($out_hash, "licensePoolId", $licensePoolId);
+ &add_content2xml_hash($out_hash, "licenses", $res->result->{$licensePoolId}->{'licenses'});
+ &add_content2xml_hash($out_hash, "usageCount", $res->result->{$licensePoolId}->{'usageCount'});
+ &add_content2xml_hash($out_hash, "maxInstallations", $res->result->{$licensePoolId}->{'maxInstallations'});
+ &add_content2xml_hash($out_hash, "remainingInstallations", $res->result->{$licensePoolId}->{'remainingInstallations'});
+ map(&add_content2xml_hash($out_hash, "usedBy", "$_"), @{ $res->result->{$licensePoolId}->{'usedBy'}});
+
+ return ( &create_xml_string($out_hash) );
+}
sub opsi_test {
my ($msg, $msg_hash, $session_id) = @_;
index 86784ed5ea7a167880601d418726dd3932a66951..4c16e6cef856412386e6bb204cf06035a89dd64a 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# Funktioniert noch nicht
#$data = "<xml><header>gosa_opsi_test</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>acroread</productId></xml>";
+ $data = "<xml><header>gosa_opsi_getLicenseInformationForProduct</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>acroread</productId></xml>";
+
#$data = "<xml><header>gosa_opsi_getLicensePools_listOfHashes</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
#$data = "<xml><header>gosa_opsi_getLicensePool_hash</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>Susi</licensePoolId></xml>";