From da298adefb34e61b0e34924682885c5e68e10ad8 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Thu, 24 Sep 2009 13:34:46 +0000 Subject: [PATCH] add contract data to returned data of opsi_com.pm::getPool git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14341 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/server/events/opsi_com.pm | 45 ++++++++++++++++++++++++++++++- gosa-si/tests/client.php | 4 +-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/gosa-si/server/events/opsi_com.pm b/gosa-si/server/events/opsi_com.pm index 15b3a63a2..241856f47 100644 --- a/gosa-si/server/events/opsi_com.pm +++ b/gosa-si/server/events/opsi_com.pm @@ -2107,6 +2107,24 @@ sub opsi_getPool { } } + # Each softwareLicenseId has one licenseContractId, fetch contract details for each licenseContractId + my ($lContract_res, $lContract_err) = &_getLicenseContract_hash('licenseContractId'=>$license->{licenseContractId}); + if ($lContract_err){ + return &_giveErrorFeedback($msg_hash, "cannot get software license contract information from Opsi server: ".$licenses_res, $session_id); + } + + $license_hash->{$license->{'licenseContractId'}} = []; + my $licenseContract_hash = { 'conclusionDate' => [$lContract_res->{conclusionDate}], + 'notificationDate' => [$lContract_res->{notificationDate}], + 'notes' => [$lContract_res->{notes}], + 'exirationDate' => [$lContract_res->{expirationDate}], + 'partner' => [$lContract_res->{partner}], + }; + + push( @{$license_hash->{licenseContractData}}, $licenseContract_hash ); + +print STDERR Dumper $license_hash; + push( @{$res_hash->{hit}}, $license_hash ); } $out_hash->{licenses} = [$res_hash]; @@ -2164,7 +2182,6 @@ sub opsi_removeLicense { # @brief # @param # -#TODO sub opsi_getReservedLicenses { my ($msg, $msg_hash, $session_id) = @_; my $header = @{$msg_hash->{'header'}}[0]; @@ -2391,4 +2408,30 @@ sub _getLicensePoolId { return ($res->result, 0); } +sub _getLicenseContract_hash { + my %arg = ( + 'licenseContractId' => undef, + @_, + ); + + if (not defined $arg{licenseContractId} ) { + return ("function requires licenseContractId as parameter", 1); + } + + my $callobj = { + method => 'getLicenseContract_hash', + params => [ $arg{licenseContractId} ], + 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){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); } + + return ($res->result, 0); + +} + + 1; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 5b4833211..d8cf52ba8 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -45,11 +45,11 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_opsi_getSoftwareLicense_hash
GOSA00:01:6C:9D:B9:FAl_2009-09-22_09:51:11_0
"; - #$data = "
gosa_opsi_getPool
GOSA00:01:6C:9D:B9:FALicensePool
"; + $data = "
gosa_opsi_getPool
GOSA00:01:6C:9D:B9:FALicensePool
"; #$data = "
gosa_opsi_removeLicense
GOSA00:01:6C:9D:B9:FALicensePooll_2009-09-22_14:06:11
"; - $data = "
gosa_opsi_getReservedLicenses
GOSA00:01:6C:9D:B9:FAkrakenarme.intranet.gonicus.de
"; + #$data = "
gosa_opsi_getReservedLicenses
GOSA00:01:6C:9D:B9:FAkrakenarme.intranet.gonicus.de
"; ############################## -- 2.30.2