From: hickert Date: Mon, 25 Aug 2008 09:49:28 +0000 (+0000) Subject: Updated opsi X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=08e6950c34af4bf4136ba17df59876772a96df92;p=gosa.git Updated opsi - Added MAc, note and description option.. and checks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12267 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 9e5ea54a1..f878fcbaa 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsi.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsi.inc @@ -305,7 +305,7 @@ class opsi extends gosaSupportDaemon @param @return */ - public function list_clients() + public function list_clients( $hostId = "") { $data = array(); $res = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE); @@ -354,16 +354,37 @@ class opsi extends gosaSupportDaemon @param @return */ - public function add_client($hostId,$ip,$macaddress,$notes,$description) + public function add_client($hostId,$macaddress,$notes,$description) { - $data = array("hostId" => $hostId,"ip" => $ip,"macaddress" => $macaddress); + $data = array("hostId" => $hostId,"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."); + + /* 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); + } + + + /*! \brief Modify an opsi client. + @param + @return + */ + public function modify_client($hostId,$mac,$notes,$description) + { + $data = array("hostId" => $hostId,"mac" => $mac); + + if(empty($hostId)){ + trigger_error("No valid host id given, check parameter 1."); return; } @@ -375,7 +396,7 @@ class opsi extends gosaSupportDaemon } /* Query SI server */ - $res = $this->send_data("gosa_opsi_add_client",$this->target,$data,TRUE); + $res = $this->send_data("gosa_opsi_modify_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 fe3349c64..ea511b15a 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc @@ -21,6 +21,12 @@ class opsigeneric extends plugin private $parent_mode = TRUE; + public $mac = ""; + public $note = ""; + public $description = ""; + + public $attributes = array("mac","note","description"); + public function __construct($config,$hostId) { $this->opsi = new opsi($config); @@ -41,6 +47,19 @@ class opsigeneric extends plugin $err = FALSE; $this->init_failed = FALSE; + if($this->hostId != "new"){ + $list = $this->opsi->list_clients($this->hostId); + foreach($list as $entry){ + if($entry['NAME'][0]['VALUE'] == $this->hostId){ + foreach(array("description" => "DESCRIPTION","mac" => "MAC", "note" => "NOTES") as $des => $src){ + $this->$des = $entry[$src][0]['VALUE']; + } + + break; + } + } + } + /* Get product settings */ if(!$err){ $this->a_availableNetbootProducts = $this->opsi->get_netboot_products(); @@ -98,13 +117,15 @@ class opsigeneric extends plugin if(!preg_match("/\./",$this->hostId)){ $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",_("The client name must contain a domain part (e.g. '.company.de').")); } + if(!tests::is_mac($this->mac)){ + $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1"); + } return($messages); } public function execute() { if($this->init_failed){ - $smarty = get_smarty(); $smarty->assign("init_failed",TRUE); $smarty->assign("message",$this->opsi->get_error()); @@ -117,6 +138,11 @@ class opsigeneric extends plugin } $smarty = get_smarty(); + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("parent_mode", $this->parent_mode); $smarty->assign("init_failed",FALSE); $divSLP = new divSelectBox(); @@ -174,12 +200,17 @@ class opsigeneric extends plugin -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"); + $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description); if($this->opsi->is_error()){ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); return; } } + $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description); + 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); @@ -257,6 +288,8 @@ class opsigeneric extends plugin if(isset($_POST['opsigeneric_posted'])){ + plugin::save_object(); + if(isset($_POST['hostId']) && $this->parent_mode){ $this->hostId = get_post('hostId'); } diff --git a/gosa-plugins/opsi/admin/opsi/generic.tpl b/gosa-plugins/opsi/admin/opsi/generic.tpl index 1c2c5fddf..918c5f752 100644 --- a/gosa-plugins/opsi/admin/opsi/generic.tpl +++ b/gosa-plugins/opsi/admin/opsi/generic.tpl @@ -11,7 +11,7 @@ - + + + +
+ {if $parent_mode} @@ -19,6 +19,22 @@ {/if} + + + + + + + + +
{t}Description{/t}
{t}Notes{/t}
+
+ + + + +
{t}MAC address{/t}
{t}Boot product{/t} @@ -30,7 +46,12 @@
-
+
+

 

+

Installed products