Code

Updated FAI partition handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Aug 2009 08:25:52 +0000 (08:25 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Aug 2009 08:25:52 +0000 (08:25 +0000)
-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

gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc

index 18882694d134470bc81a8a824bb630bae5c1bbb5..d40bb8215330344e46dbcd65b9678da14fa1fba0 100644 (file)
@@ -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];
           }
index d8a4f5baec668c50408bbc566ef543d174c38422..360e45fbdb20fac9b309fd705686bf9346af52b3 100644 (file)
@@ -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