Code

Updated of opsi stuff
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Aug 2008 13:19:00 +0000 (13:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Aug 2008 13:19:00 +0000 (13:19 +0000)
-Some changes to implement actions, later.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12276 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsi/class_opsi.inc
gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc

index 290f39157f27aa3eabf60a3173d44810954d7594..ec2c51a05c7807910e1c619bf04231d6612a6fb6 100644 (file)
@@ -90,6 +90,18 @@ class opsi extends gosaSupportDaemon
   }
 
 
+  /*! \brief  Trigger an event like wake or install for a specific hostId. 
+   */
+  public function send_action($type,$hostId)
+  {
+    switch($type){
+      case 'install'  :  $this->job_opsi_install_client($hostId); break;
+      case 'wake'     :  $this->job_opsi_wake_client($hostId); break;
+      default         :  trigger_error('Unknown type '.$type.'.');
+    }
+  }
+
+
   /******************
     SI Communication functions
    ******************/
@@ -415,11 +427,26 @@ class opsi extends gosaSupportDaemon
     }
 
     /* Query SI server */
-    $res    = $this->send_data("job_opsi_install_client",$this->target,$data,TRUE);
-    if(isset($res['XML'][0]['ITEM'])){
-      return($res['XML'][0]['ITEM']);
+    $this->send_data("job_opsi_install_client",$this->target,$data,TRUE);
+  }
+
+
+  /*! \brief           Triggers install/reinstall of an opsi client.
+    @param
+    @return            
+   */
+  public function job_opsi_wake_client($hostId)
+  {
+    $data = array("hostId" => $hostId);
+
+    /* Check parameter */ 
+    if(empty($hostId)){
+      trigger_error("No valid host id given, check parameter 1.");
+      return;
     }
-    return(array());
+
+    /* Query SI server */
+    $this->send_data("job_opsi_wake_client",$this->target,$data,TRUE);
   }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 98d4676fcd7243f7ca9b2f4abacfd59221b0a388..1e2f691e3912bcaf7bdc71d6d3de1746298acde8 100644 (file)
@@ -302,6 +302,18 @@ class opsigeneric extends plugin
         $this->hostId = get_post('hostId');
       }
 
+      /* Send actions like 'install' or 'wake' to the si server 
+       */
+      if(isset($_POST['opsi_action']) && isset($_POST['opsi_trigger_action']) && $this->parent_mode){
+        $action = $_POST['opsi_action'];
+        if(in_array($action,array("wake","install"))){
+          $this->opsi->send_action($action,$this->hostId);
+          if($this->opsi->is_error()){
+            msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+          }
+        }
+      }
+
       if(isset($_POST['opsi_netboot_product'])){
         $SNP = trim($_POST['opsi_netboot_product']);
         if(isset($this->a_availableNetbootProducts[$SNP])){
@@ -336,6 +348,13 @@ class opsigeneric extends plugin
     }
   }
 
+
+  function install_client()
+  {
+
+  }
+
+
   /* Return plugin informations for acl handling */
   static function plInfo()
   {