From 1ce0527b971884a67052934463007c63e02fcae7 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 28 Sep 2009 13:41:58 +0000 Subject: [PATCH] Updated License handling for hosts git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14375 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../opsiLicenses/class_licenseUsageByHost.inc | 11 ++++-- .../opsiLicenses/class_opsiLicenseHandler.inc | 37 ++++++++++++++++++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc index d2b0817ed..60ba6d6f8 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc @@ -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); } diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc index 7efb01c4b..45a5bce36 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc @@ -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 -- 2.30.2