From: hickert Date: Fri, 7 Aug 2009 08:25:52 +0000 (+0000) Subject: Updated FAI partition handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ed7abf6f202cac0b77cd81a2a08c974854015153;p=gosa.git Updated FAI partition handling -Check disk names, to avoid using names twice. -Updated old style partition saving. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13994 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index 18882694d..d40bb8215 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -172,13 +172,13 @@ class faiPartitionTable extends plugin /* New Listhandling */ if (!preg_match("/freeze/i", $this->FAIstate)){ foreach($_POST as $name => $value){ - if(preg_match("/^edit_/",$name)){ + if(preg_match("/^edit_[^_]*_/",$name)){ $s_entry = preg_replace("/^edit_/","",$name); $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); $s_action = "edit"; break; } - if(preg_match("/^delete_/",$name)){ + if(preg_match("/^delete_[^_]*_/",$name)){ $s_entry = preg_replace("/^delete_/","",$name); $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); $s_action = "remove"; @@ -274,23 +274,18 @@ class faiPartitionTable extends plugin $dn = "new"; } + $type ="old"; if(isset($this->disks[$s_entry]['FAIdiskType'])){ - switch($this->disks[$s_entry]['FAIdiskType']){ - case 'raid': - case 'lvm': - case 'disk': - $this->dialog = new faiDiskEntry( - $this->config,$this->dn,$this,$this->disks[$s_entry], - $this->disks[$s_entry]['FAIdiskType']); - break; - case 'old': - $this->dialog = new faiPartitionTableEntry( - $this->config,$this->dn,$this->getUsedDiskNames(),$this->disks[$s_entry]); - break; - } + $type = $this->disks[$s_entry]['FAIdiskType']; + } + if(in_array($type,array('raid','lvm','disk'))){ + $this->dialog = new faiDiskEntry( + $this->config,$this->dn,$this,$this->disks[$s_entry], + $this->disks[$s_entry]['FAIdiskType']); + }else{ $this->dialog = new faiPartitionTableEntry( - $this->config,$this->dn,$this->getUsedDiskNames(),array()); + $this->config,$this->dn,$this,$this->disks[$s_entry]); } if($this->dialog){ $this->dialog->set_acl_base($this->acl_base_for_current_object($dn)); @@ -450,7 +445,11 @@ class faiPartitionTable extends plugin function getUsedDiskNames() { - return(array()); + $ret = array(); + foreach($this->disks as $disk){ + $ret[] = $disk['cn']; + } + return($ret); } @@ -572,6 +571,7 @@ class faiPartitionTable extends plugin foreach(array("description","FAIdiskType","FAIdiskOption","FAIlvmDevice") as $attr){ if($disk['status'] == "new"){ + if(isset($disk_attrs[$attr])) unset($disk_attrs[$attr]); if(isset($disk[$attr]) && !empty($disk[$attr])){ $disk_attrs[$attr] = $disk[$attr]; } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc index d8a4f5bae..360e45fbd 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc @@ -16,15 +16,17 @@ class faiPartitionTableEntry extends plugin var $old_cn = ""; var $status = "new"; var $deletePartitions = array(); - + var $parent = null; var $FAIstate = ""; - function faiPartitionTableEntry (&$config, $dn= NULL,$usedDiskNames=array(),$disk=false) + function faiPartitionTableEntry (&$config, $dn= NULL,&$parent,$disk=false) { plugin::plugin ($config, $dn); $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); + $this->parent = $parent; + /* Default status is new */ $this->status = "new"; @@ -374,6 +376,10 @@ class faiPartitionTableEntry extends plugin if(preg_match("/[^a-z0-9_\-]/i",$d)){ $message[] = msgPool::invalid(_("Name"),$d,"/[a-z0-9_\-]/i"); } + + if($this->old_cn != $this->DISKcn && in_array($this->DISKcn,$this->parent->getUsedDiskNames())){ + $message[] = msgPool::duplicated(_("Name")); + } /* check every partition. * if there is an invalid value defined, append an errorstr to message