Code

add contract data to returned data of opsi_com.pm::getPool
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 24 Sep 2009 13:34:46 +0000 (13:34 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 24 Sep 2009 13:34:46 +0000 (13:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14341 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/server/events/opsi_com.pm
gosa-si/tests/client.php

index 15b3a63a22d1af5198d81a27feba56ce09508cd0..241856f474754854fe0425d033897dcfdad6a90a 100644 (file)
@@ -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;
index 5b4833211dd8c06d2288e47bc7c440e8c03ef1fb..d8cf52ba8dac47f31d394960192efaa89fff90e3 100755 (executable)
@@ -45,11 +45,11 @@ for($count = 1; $count <= $zahl; $count++)
 
        #$data = "<xml><header>gosa_opsi_getSoftwareLicense_hash</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>l_2009-09-22_09:51:11_0</softwareLicenseId></xml>";
 
-       #$data = "<xml><header>gosa_opsi_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
+       $data = "<xml><header>gosa_opsi_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
 
        #$data = "<xml><header>gosa_opsi_removeLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId><softwareLicenseId>l_2009-09-22_14:06:11</softwareLicenseId></xml>";
 
-       $data = "<xml><header>gosa_opsi_getReservedLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
+       #$data = "<xml><header>gosa_opsi_getReservedLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
 
 
        ##############################