Code

Added opsi classses.
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsi.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2008  Fabian Hickert
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation, either version 3 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
22 /*! \brief  This is the opsi base class, it handles 
23   .          gosa daemon requests and prepares data for opsi plugins.
24  */
25 class opsi extends gosaSupportDaemon 
26 {
27   private $config = NULL;
29   /*! \brief            Create opsi object.
30     @param
31     @return             
32    */
33   public function __construct($config)
34   {
35     $this->config = $config;
36     gosaSupportDaemon::__construct($config);
37     $this->target = "00:01:6c:9d:b9:fa";
38   }
40   /******************
41     Opsi handling 
42    ******************/
44   function get_hosts_for_system_management()
45   {
46     $res = $this->list_clients();
48     $data = array();
49     foreach($res as $entry){
50       $data[] = array(
51         "dn"          => "opsi:=".$entry['NAME'].",".get_ou("winstations").$this->config->current['BASE'],
52         "objectClass" => array("gosa_opsi_client"),
53         "cn"          => array(0 => $entry['NAME']),
54         "description" => array(0 => $entry['DESCRIPTION']),
55         "macAddress"  => array(0 => $entry['MAC']),
56         "opsi_notes"  => array(0 => $entry['NOTES']));
57         
58     }
59   
60     return($data);
61   }
64   /******************
65     SI Communication functions
66    ******************/
69   /*! \brief            Returns a list of netboot products.
70     @param
71     @return             
72    */
73   public function get_netboot_products($host = "")
74   {
75     $data = array();
77     /* Append host attribute to query data 
78      */
79     if(!empty($host)){
80       $data['hostId'] = trim($host);
81     }
83     $res    = $this->send_data("gosa_opsi_get_netboot_products",$this->target,$data,TRUE);
84     $items  = array();
85     if($res['XML']['ITEM']['PRODUCTID']){
86     foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
87         $items[$name]['NAME'] = $name;
88         $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
89       }
90     }
91     return($items);
92   }
95   /*! \brief            Returns a list of all local products.
96     @param
97     @return             
98    */
99   public function get_local_products($host = "")
100   {
101     $data = array();
103     /* Append host attribute to query data 
104      */
105     if(!empty($host)){
106       $data['hostId'] = trim($host);
107     }
109     $res    = $this->send_data("gosa_opsi_get_local_products",$this->target,$data,TRUE);
110     $items  = array();
111     if($res['XML']['ITEM']['PRODUCTID']){
112     foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
113         $items[$name]['NAME'] = $name;
114         $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
115       }
116     }
117     return($items);
118   }
121   /*! \brief            Returns a list of all product properties. \ 
122     .           Additionally you can specify the host parameter to \
123     .           get host specific product properties
124     @param
125     @return             
126    */
127   public function get_product_properties()
128   {
129     /*  <xml> 
130         <header>gosa_opsi_get_product_properties</header> 
131         <source>GOSA</source> 
132         <target>GOSA</target> 
133         <productId>firefox</productId>
134         </xml>
135         <xml> 
136         <header>gosa_opsi_get_product_properties</header> 
137         <source>GOSA</source> 
138         <target>GOSA</target> 
139         <productId>firefox</productId> 
140         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
141         </xml>
142      */
143     
144   }
147   /*! \brief            Set product properties, globally or per host. 
148     @param
149     @return             
150    */
151   public function set_product_properties()
152   {
153     /*  <xml> 
154         <header>gosa_opsi_set_product_properties</header> 
155         <source>GOSA</source> 
156         <target>00:01:6c:9d:b9:fa</target> 
157         <productId>firefox</productId> 
158         <item>
159         <name>askbeforeinst</name>
160         <value>false</value>
161         </item>
162         </xml>
163         <xml> 
164         <header>gosa_opsi_set_product_properties</header> 
165         <source>GOSA</source> 
166         <target>00:01:6c:9d:b9:fa</target> 
167         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
168         <productId>firefox</productId> 
169         <item> 
170         <name>askbeforeinst</name> 
171         <value>false</value> 
172         </item> 
173         </xml> 
174      */
175   }
178   /*! \brief            Returns the clients hardware setup.
179     @param
180     @return             
181    */
182   public function get_client_hardware()
183   {
184     /*  <xml> 
185         <header>gosa_opsi_get_client_hardware</header> 
186         <source>GOSA</source> 
187         <target>GOSA</target> 
188         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
189         </xml> 
190      */
191   }
194   /*! \brief            Returns the clients software setup.
195     @param
196     @return             
197    */
198   public function get_client_software()
199   {
200     /*  <xml> 
201         <header>gosa_opsi_get_client_software</header> 
202         <source>GOSA</source> 
203         <target>GOSA</target> 
204         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
205         </xml> i
206      */
207   }
210   /*! \brief            Returns a list of all opsi clients.
211     @param
212     @return             
213    */
214   public function list_clients()
215   {
216     $data   = array();
217     $res    = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE);
218     $items  = array();
219     if(isset($res['XML']['ITEM'])){
220       foreach($res['XML']['ITEM'] as $type => $val){
221         foreach($val as $key => $value){
222           $items[$key][$type] = $value;
223         }
224       }
225     }
226     return($items);
227   }
230   /*! \brief            Deletes the given opsi client.
231     @param
232     @return             
233    */
234   public function del_client()
235   {
236     /*  <xml> 
237         <header>gosa_opsi_del_client</header> 
238         <source>GOSA</source> 
239         <target>00:01:6c:9d:b9:fa</target> 
240         <hostId>limux-cl-2.intranet.gonicus.de</hostId>
241         </xml>
242      */
243   }
246   /*! \brief            Triggers install/reinstall of an opsi client.
247     @param
248     @return             
249    */
250   public function job_opsi_install_client()
251   {
252     /*  <xml> 
253         <header>job_opsi_install_client</header> 
254         <source>GOSA</source> 
255         <target>00:01:6c:9d:b9:fa</target> 
256         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
257         <macaddress>00:11:25:4b:8c:e5</macaddress> 
258         </xml>
259      */
260   }
263   /*! \brief            Adds a new opsi client.
264     @param
265     @return             
266    */
267   public function add_client()
268   {
269     /*  <xml> 
270         <header>gosa_opsi_add_client</header> 
271         <source>GOSA</source> 
272         <target>00:01:6c:9d:b9:fa</target> 
273         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
274         <macaddress>00:11:25:4b:8c:e5</macaddress> 
275         <description>Test halt</description> 
276         <ip>1.2.3.4</ip> 
277         <notes>Im a note</notes> 
278         </xml>
279      */
280   }
283   /*! \brief            Adds a given product to a client.
284     @param
285     @return             
286    */
287   public function add_product_to_client()
288   {
289     /*  <xml> 
290         <header>gosa_opsi_add_product_to_client</header> 
291         <source>GOSA</source> 
292         <target>00:01:6c:9d:b9:fa</target> 
293         <macaddress>00:11:25:4b:8c:e5</macaddress> 
294         <hostId>limux-cl-2.intranet.gonicus.de</hostId> 
295         <productId>winxppro</productId> 
296         </xml>
297      */
298   }
301   /*! \brief      Removes a given product from a client.
302     @param
303     @return
304    */
305   public function del_product_from_client()
306   {
307     /* <xml> 
308        <header>gosa_opsi_del_product_from_client</header> 
309        <source>GOSA</source> 
310        <target>00:01:6c:9d:b9:fa</target> 
311        <hostId>limux-cl-1.intranet.gonicus.de</hostId> 
312        <macaddress>00:11:25:4b:8c:e5</macaddress> 
313        <productId>softprod</productId>  
314        </xml>
315      */
316   }
318 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
319 ?>