Code

Added opsi classses.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Aug 2008 12:33:36 +0000 (12:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Aug 2008 12:33:36 +0000 (12:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12244 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsi/class_opsi.inc
gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc [new file with mode: 0644]
gosa-plugins/opsi/admin/opsi/opsi_tabs.inc [new file with mode: 0644]

index 4425391381b8298cf19d02bc94081baee1168b36..e41133b6d3209fd04d21972a3ca6b730dc791bbd 100644 (file)
 /*! \brief  This is the opsi base class, it handles 
   .          gosa daemon requests and prepares data for opsi plugins.
  */
-class opsi 
+class opsi extends gosaSupportDaemon 
 {
+  private $config = NULL;
+
+  /*! \brief           Create opsi object.
+    @param
+    @return            
+   */
+  public function __construct($config)
+  {
+    $this->config = $config;
+    gosaSupportDaemon::__construct($config);
+    $this->target = "00:01:6c:9d:b9:fa";
+  }
+
+  /******************
+    Opsi handling 
+   ******************/
+
+  function get_hosts_for_system_management()
+  {
+    $res = $this->list_clients();
+
+    $data = array();
+    foreach($res as $entry){
+      $data[] = array(
+        "dn"          => "opsi:=".$entry['NAME'].",".get_ou("winstations").$this->config->current['BASE'],
+        "objectClass" => array("gosa_opsi_client"),
+        "cn"          => array(0 => $entry['NAME']),
+        "description" => array(0 => $entry['DESCRIPTION']),
+        "macAddress"  => array(0 => $entry['MAC']),
+        "opsi_notes"  => array(0 => $entry['NOTES']));
+        
+    }
+  
+    return($data);
+  }
+
+
+  /******************
+    SI Communication functions
+   ******************/
 
 
   /*! \brief           Returns a list of netboot products.
     @param
     @return            
    */
-  public static function opsi_get_netboot_products()
+  public function get_netboot_products($host = "")
   {
-    /*  <xml>
-        <header>gosa_opsi_get_netboot_products</header> 
-        <source>GOSA</source> 
-        <target>00:01:6c:9d:b9:fa</target>
-        </xml> 
-        <xml> 
-        <header>gosa_opsi_get_netboot_products</header> 
-        <source>GOSA</source> 
-        <target>GOSA</target> 
-        <hostId>limux-cl-2.intranet.gonicus.de</hostId>
-        </xml> */
+    $data = array();
 
+    /* Append host attribute to query data 
+     */
+    if(!empty($host)){
+      $data['hostId'] = trim($host);
+    }
+
+    $res    = $this->send_data("gosa_opsi_get_netboot_products",$this->target,$data,TRUE);
+    $items  = array();
+    if($res['XML']['ITEM']['PRODUCTID']){
+    foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
+        $items[$name]['NAME'] = $name;
+        $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
+      }
+    }
+    return($items);
   }
 
 
@@ -51,20 +96,25 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_get_local_products()
+  public function get_local_products($host = "")
   {
-    /*  <xml> 
-        <header>gosa_opsi_get_local_products</header> 
-        <source>GOSA</source> 
-        <target>GOSA</target> 
-        </xml>
-        <xml> 
-        <header>gosa_opsi_get_local_products</header> 
-        <source>GOSA</source> 
-        <target>GOSA</target> 
-        <hostId>limux-cl-2.intranet.gonicus.de</hostId>
-        </xml> */
+    $data = array();
 
+    /* Append host attribute to query data 
+     */
+    if(!empty($host)){
+      $data['hostId'] = trim($host);
+    }
+
+    $res    = $this->send_data("gosa_opsi_get_local_products",$this->target,$data,TRUE);
+    $items  = array();
+    if($res['XML']['ITEM']['PRODUCTID']){
+    foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
+        $items[$name]['NAME'] = $name;
+        $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
+      }
+    }
+    return($items);
   }
 
 
@@ -74,7 +124,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_get_product_properties()
+  public function get_product_properties()
   {
     /*  <xml> 
         <header>gosa_opsi_get_product_properties</header> 
@@ -90,6 +140,7 @@ class opsi
         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
         </xml>
      */
+    
   }
 
 
@@ -97,7 +148,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_set_product_properties()
+  public function set_product_properties()
   {
     /*         <xml> 
         <header>gosa_opsi_set_product_properties</header> 
@@ -128,7 +179,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_get_client_hardware()
+  public function get_client_hardware()
   {
     /* <xml> 
         <header>gosa_opsi_get_client_hardware</header> 
@@ -144,7 +195,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_get_client_software()
+  public function get_client_software()
   {
     /*  <xml> 
         <header>gosa_opsi_get_client_software</header> 
@@ -160,14 +211,19 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_list_clients()
+  public function list_clients()
   {
-    /*  <xml> 
-        <header>gosa_opsi_list_clients</header> 
-        <source>GOSA</source> 
-        <target>00:01:6c:9d:b9:fa</target> 
-        </xml>
-     */
+    $data   = array();
+    $res    = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE);
+    $items  = array();
+    if(isset($res['XML']['ITEM'])){
+      foreach($res['XML']['ITEM'] as $type => $val){
+        foreach($val as $key => $value){
+          $items[$key][$type] = $value;
+        }
+      }
+    }
+    return($items);
   }
 
 
@@ -175,7 +231,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_del_client()
+  public function del_client()
   {
     /*  <xml> 
         <header>gosa_opsi_del_client</header> 
@@ -191,7 +247,7 @@ class opsi
     @param
     @return            
    */
-  public static function job_opsi_install_client()
+  public function job_opsi_install_client()
   {
     /*  <xml> 
         <header>job_opsi_install_client</header> 
@@ -208,7 +264,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_add_client()
+  public function add_client()
   {
     /*  <xml> 
         <header>gosa_opsi_add_client</header> 
@@ -228,7 +284,7 @@ class opsi
     @param
     @return            
    */
-  public static function gosa_opsi_add_product_to_client()
+  public function add_product_to_client()
   {
     /*  <xml> 
         <header>gosa_opsi_add_product_to_client</header> 
@@ -246,7 +302,7 @@ class opsi
     @param
     @return
    */
-  public static function gosa_opsi_del_product_from_client()
+  public function del_product_from_client()
   {
     /* <xml> 
        <header>gosa_opsi_del_product_from_client</header> 
@@ -259,6 +315,5 @@ class opsi
      */
   }
 }
-
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc b/gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc
new file mode 100644 (file)
index 0000000..7f0da68
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+class opsi_generic extends plugin
+{
+
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/opsi/admin/opsi/opsi_tabs.inc b/gosa-plugins/opsi/admin/opsi/opsi_tabs.inc
new file mode 100644 (file)
index 0000000..23145e4
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+class opsi_tabs extends tabs
+{
+
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>