Code

Updated License handling for hosts
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 28 Sep 2009 13:41:58 +0000 (13:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 28 Sep 2009 13:41:58 +0000 (13:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14375 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc

index d2b0817ed53b2f35d00c836adbf9c417e3dc8886..60ba6d6f8e5587dba1e99536f81806a98b9875d4 100644 (file)
@@ -88,6 +88,9 @@ class licenseUsageByHost extends plugin
         return;
       }
       $this->availableLicenses = array();
+
+      echo "We require Licenses here not Pools";
+
       foreach($res as $pool){
         $this->availableLicenses[] = $pool['cn'][0];
       }
@@ -204,15 +207,15 @@ class licenseUsageByHost extends plugin
     $del = array_diff($this->init_reservedLicenses, $this->reservedLicenses);
     $add = array_diff($this->reservedLicenses, $this->init_reservedLicenses);
 
-    foreach($del as $pool){
-      $this->si->removeLicenseFromHost($pool, $this->cn);
+    foreach($del as $license){
+      $this->si->removeLicenseReservationFromHost($license, $this->cn);
       if($this->si->is_error()){
         msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
       }
     }
 
-    foreach($add as $pool){
-      $this->si->addLicenseToHost($pool, $this->cn);
+    foreach($add as $license){
+      $this->si->reserverLicenseForHost($license, $this->cn);
       if($this->si->is_error()){
         msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
       }
index 7efb01c4b29f9ca7ba08149fc492f3c9bcb27bc7..45a5bce36a520b9ce4620f6eebdc1794e9829186 100644 (file)
@@ -18,7 +18,6 @@ class opsiLicenceHandler extends opsi  {
   {
     $data= array();
     $res = $this->send_data("gosa_opsi_getLicensePools_listOfHashes",$this->target,$data,TRUE);
-    
     $items  = array();
     if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
       $items = $res['XML'][0]['RESULT'][0]['HIT'];
@@ -303,6 +302,41 @@ class opsiLicenceHandler extends opsi  {
   }
 
 
+  /* @brief   Reserve a software license to a host
+   * @param   softwareLicenseId 
+   * @param   hostId Something like client_1.intranet.mydomain.de
+   */
+  function reserverLicenseForHost($softwareLicenseId,$hostId)
+  {
+    $data= array();
+    $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+    $data['hostId'] = htmlentities($hostId);
+    $res = $this->send_data("gosa_opsi_boundHostToLicense",$this->target,$data,TRUE);
+    if(isset($res['XML'][0]['ANSWER_OPSI_BOUNDHOSTTOLICENSE'])){
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+
+
+  /* 
+   * @brief   Remove software licnese reservation for a host.
+   * @param   softwareLicenseId
+   * @param   hostid Something like client_1.intranet.mydomain.de
+   */
+  function removeLicenseReservationFromHost($softwareLicenseId,$hostId)
+  {
+    $data= array();
+    $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+    $data['hostId'] = htmlentities($hostId);
+    $res = $this->send_data("gosa_opsi_unboundHostFromLicense",$this->target,$data,TRUE);
+    if(isset($res['XML'][0]['ANSWER_OPSI_UNBOUNDHOSTFROMLICENSE'])){
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+
+
   /* 
    * @brief   Unassign a software license from a host.
    * @param   hostid Something like client_1.intranet.mydomain.de
@@ -320,6 +354,7 @@ class opsiLicenceHandler extends opsi  {
     return(FALSE);
   }
 
+
   /* 
    * @brief   Removes a single license from a license pool
    *          Attention, the software license has to exists