From: hickert Date: Fri, 22 Aug 2008 09:35:09 +0000 (+0000) Subject: Updated opsi X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4455a0e6f3a6741b7a8102480710e9dc6c490604;p=gosa.git Updated opsi -Fixed client creation. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12261 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi.inc b/gosa-plugins/opsi/admin/opsi/class_opsi.inc index e764de240..2e42a3abe 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsi.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsi.inc @@ -56,6 +56,7 @@ class opsi extends gosaSupportDaemon $this->target = "00:01:6c:9d:b9:fa"; } + /****************** Opsi handling ******************/ @@ -262,15 +263,21 @@ class opsi extends gosaSupportDaemon @param @return */ - public function get_client_hardware() + public function get_client_hardware($hostId) { - /* -
gosa_opsi_get_client_hardware
- GOSA - GOSA - limux-cl-2.intranet.gonicus.de -
- */ + $data = array("hostId" => $hostId); + + /* Check parameter */ + if(empty($hostId)){ + trigger_error("No valid host id given, check parameter 1."); + return; + } + + /* Query SI server */ + $res = $this->send_data("gosa_opsi_get_client_hardware",$this->target,$data,TRUE); + if(isset($res['XML']['ITEM'])){ + #print_a($res['XML']['ITEM']); + } } @@ -354,19 +361,28 @@ class opsi extends gosaSupportDaemon @param @return */ - public function add_client() + public function add_client($hostId,$ip,$macaddress,$notes,$description) { - /* -
gosa_opsi_add_client
- GOSA - 00:01:6c:9d:b9:fa - limux-cl-2.intranet.gonicus.de - 00:11:25:4b:8c:e5 - Test halt - 1.2.3.4 - Im a note -
- */ + $data = array("hostId" => $hostId,"ip" => $ip,"macaddress" => $macaddress); + + if(empty($hostId)){ + trigger_error("No valid host id given, check parameter 1."); + return; + } + if(empty($ip)){ + trigger_error("No valid ip address given, check parameter 2."); + return; + } + + /* Add optional attributes */ + foreach(array("notes","description") as $attr) { + if(!empty($$attr)){ + $data[$attr] = $$attr; + } + } + + /* Query SI server */ + $res = $this->send_data("gosa_opsi_add_client",$this->target,$data,TRUE); } diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc index a36c38846..5acbc597c 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc @@ -19,14 +19,16 @@ class opsigeneric extends plugin private $init_failed = FALSE; + private $parent_mode = TRUE; + public function __construct($config,$hostId) { $this->opsi = new opsi($config); $this->is_account =TRUE; - $this->initially_was_account = TRUE; /* Get hostId */ if($hostId != "new"){ + $this->initially_was_account = TRUE; $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId); } @@ -88,6 +90,15 @@ class opsigeneric extends plugin } } + public function check() + { + $messages = plugin::check(); + if(!preg_match("/\./",$this->hostId)){ + $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",_("The client name must contain a domain part (e.g. '.company.de').")); + } + return($messages); + } + public function execute() { if($this->init_failed){ @@ -98,13 +109,13 @@ class opsigeneric extends plugin return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); } - if(is_object($this->dialog)){ $this->dialog->save_object(); return($this->dialog->execute()); } $smarty = get_smarty(); + $smarty->assign("parent_mode", $this->parent_mode); $smarty->assign("init_failed",FALSE); $divSLP = new divSelectBox(); $divALP = new divSelectBox(); @@ -145,11 +156,11 @@ class opsigeneric extends plugin $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab)); } + ksort($this->a_availableNetbootProducts); + $smarty->assign("hostId", $this->hostId); $smarty->assign("divSLP", $divSLP->DrawList()); $smarty->assign("divALP", $divALP->DrawList()); $smarty->assign("SNP", $this->s_selectedNetbootProduct); - - ksort($this->a_availableNetbootProducts); $smarty->assign("ANP", $this->a_availableNetbootProducts); return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); } @@ -157,6 +168,17 @@ class opsigeneric extends plugin public function save() { + /* Check if this a new opsi client + -Do we have to create this client first? + */ + if(!$this->initially_was_account && $this->is_account){ + $res = $this->opsi->add_client($this->hostId,"0.0.0.0","00:00:00:00:00:00","Hallo","TZ"); + if($this->opsi->is_error()){ + msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); + return; + } + } + $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts); $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts); @@ -190,7 +212,7 @@ class opsigeneric extends plugin public function save_object() { - if(isset($_POST['reinit'])){ + if(isset($_POST['reinit']) && $this->init_failed){ $this->init(); } @@ -207,7 +229,11 @@ class opsigeneric extends plugin $this->dialog = NULL; } - if(isset($_POST['opsigeneric'])){ + if(isset($_POST['opsigeneric_posted'])){ + + if(isset($_POST['hostId']) && $this->parent_mode){ + $this->hostId = get_post('hostId'); + } if(isset($_POST['opsi_netboot_product'])){ $SNP = trim($_POST['opsi_netboot_product']); diff --git a/gosa-plugins/opsi/admin/opsi/generic.tpl b/gosa-plugins/opsi/admin/opsi/generic.tpl index 17b3b1ab9..1c2c5fddf 100644 --- a/gosa-plugins/opsi/admin/opsi/generic.tpl +++ b/gosa-plugins/opsi/admin/opsi/generic.tpl @@ -13,6 +13,12 @@ + {if $parent_mode} + + + + + {/if}
{t}Name{/t}
{t}Boot product{/t} @@ -35,5 +41,5 @@
- + {/if}