Code

Better deletion of partition entries disk, and partitiontables
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Sep 2005 09:05:28 +0000 (09:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Sep 2005 09:05:28 +0000 (09:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1313 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/FAI/class_faiManagement.inc
plugins/admin/FAI/class_faiPartitionTable.inc
plugins/admin/FAI/class_faiPartitionTableEntry.inc

index 800964b6c5cb790d6d89840804dde7e78b3e64f0..2738653e8beae08d25da06f2072a036901939916 100644 (file)
@@ -330,7 +330,7 @@ class faiManagement extends plugin
 
 
                $action  = "<input type='image' src='images/edit.png'   alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit object")."'>";
-               $action .= "<input type='image' src='images/delete.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete object")."'>";
+               $action .= "<input type='image' src='images/editdelete.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete object")."'>";
 
                /* Attach objects */
                foreach($this->objects as $key => $value){
index 8d657ca60244e9efcec9fc1485ffb14f4c26b7eb..2775620876f4bd4b19b1730002435d872de53501 100644 (file)
@@ -37,6 +37,7 @@ class faiPartitionTable extends plugin
       $ldap->cd ($this->dn);
       $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*"));
       while($object = $ldap->fetch()){
+        $this->disks[$object['cn'][0]]['status']      = "edited";
         $this->disks[$object['cn'][0]]['dn']          = $object['dn'];
         $this->disks[$object['cn'][0]]['cn']          = $object['cn'][0];
         if(isset($object['description'][0])){
@@ -65,6 +66,7 @@ class faiPartitionTable extends plugin
           }
           /* Append fetched partitions
            */
+          $partition['status']="edited";
           $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; 
         }  
       }
@@ -76,13 +78,17 @@ class faiPartitionTable extends plugin
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
-  
     /* Add Disk to this Partitionset
      * This code adds a new HDD to the disks 
      * A new Dialog will be opened 
      */
     if(isset($_POST['AddDisk'])){
-      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn); 
+      $usedDiskNames =array();
+      foreach($this->disks as $key=>$disk){
+        $usedDiskNames[]= $key;
+      }
+      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); 
       $this->is_dialog = true;
     }
 
@@ -90,7 +96,13 @@ class faiPartitionTable extends plugin
      * Open dialog which allows us to edit the selected entry 
      */    
     if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){
-      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$this->disks[$_POST['disks']]); 
+      $usedDiskNames =array();
+      foreach($this->disks  as $key=>$disk){
+        if($key != $_POST['disks']){
+          $usedDiskNames[]= $key;
+        }
+      }
+      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]); 
       $this->is_dialog = true;
     }
 
@@ -113,6 +125,23 @@ class faiPartitionTable extends plugin
         }
       }else{
         $disk = $this->dialog->save();
+        if(isset($disk['rename'])){
+          if($this->disks[$disk['rename']['from']]['status']=="edited"){
+            $this->disks[$disk['rename']['from']]['status']="delete";
+          }else{
+            unset($this->disks[$disk['rename']['from']]);
+          }
+  
+          foreach($disk['partitions'] as $key => $val){
+            if($disk['partitions'][$key]['status']!="delete"){
+              $disk['partitions'][$key]['status']= "new";
+            }
+          }
+
+          $disk['status']="new";
+          $disk['cn']= $disk['rename']['to'];
+        }
+      
         $this->disks[$disk['cn']]=$disk; 
         unset($this->dialog);
         $this->dialog = NULL;
@@ -120,6 +149,28 @@ class faiPartitionTable extends plugin
       }
     }
 
+    /* Delete selected disk drive from list
+     * Assign delete status for all its partitions      
+     */
+    if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){
+      $disk = $_POST['disks'];
+      if($this->disks[$disk]['status']=="edited"){
+        $this->disks[$disk."-delete"]=$this->disks[$disk];
+        unset($this->disks[$disk]);
+        $disk = $disk."-delete";        
+        $this->disks[$disk]['status']="delete";
+        foreach($this->disks[$disk]['partitions'] as $name => $value ){
+          if($value['status']=="edited"){
+            $this->disks[$disk]['partitions'][$name]['status']="delete"; 
+          }else{
+            unset($this->disks[$disk]['partitions'][$name]);
+          }
+        }
+      }else{
+        unset($this->disks[$disk]);
+      }
+    }
+
     /* Display dialog if one is defined
      */
     if(isset($this->dialog)){
@@ -151,11 +202,18 @@ class faiPartitionTable extends plugin
      */
     $a_return = array();
     foreach($this->disks as $key => $disk){
-      $cnt = count( $disk['partitions']);
-      if(!empty($disk['description'])){
-        $a_return[$key]=  $disk['cn']." [".$disk['description']."] - "._("Number of Partitions")." :".$cnt;
-      }else{
-        $a_return[$key]=  $disk['cn']." - "._("Number of Partitions")." :".$cnt;
+      if($disk['status'] != "delete"){
+        $cnt=0;
+        foreach($disk['partitions'] as $val){
+          if($val['status']!="delete"){
+            $cnt ++;
+          }
+        }
+        if(!empty($disk['description'])){
+          $a_return[$key]=  $disk['cn']." [".$disk['description']."] - "._("Number of Partitions")." :".$cnt;
+        }else{
+          $a_return[$key]=  $disk['cn']." - "._("Number of Partitions")." :".$cnt;
+        }
       }
     }
     return($a_return);
@@ -203,6 +261,7 @@ class faiPartitionTable extends plugin
   /* Save to LDAP */
   function save()
   {
+
     plugin::save();
     /* Save current settings.
      * 1 : We must save the partition table, with its description and cn 
@@ -210,36 +269,63 @@ class faiPartitionTable extends plugin
      * 3 : Save partitions for each disk
      */  
 
-    /* remove old entry */ 
     $ldap = $this->config->get_ldap_link();
-    $ldap->cat($this->dn);
-    if($ldap->count()){
-      $ldap->cd ($this->dn);
-      $ldap->rmdir_recursive($this->dn);
+
+    if($this->new){
+      $ldap->cd($this->dn);
+      $ldap->create_missing_trees($this->dn);
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      show_ldap_error($ldap->get_error());
+    }else{
+      /* Add partition table to ldap
+       */
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);
       show_ldap_error($ldap->get_error());
     }
-
-    /* Add partition table to ldap
-     */
-    $ldap->cd($this->dn);
-    $ldap->create_missing_trees($this->dn);
-    $ldap->cd($this->dn);
-    $ldap->add($this->attrs);
-    show_ldap_error($ldap->get_error());
   
+  
+    /* Sort entries, because we must delete entries with status="delete" first */
+    $order = array();
+    foreach($this->disks as $key => $disk){
+      if($disk['status'] == "delete"){
+        $order[$key] = $disk;
+      }
+    }
+    foreach($this->disks as $key => $disk){
+      if($disk['status'] != "delete"){
+        $order[$key] = $disk;
+      }
+    }
+
     /* Append all disks to ldap */
-    foreach($this->disks as $cn=>$disk){
-      $disk_cn    = "cn=".$cn.",".$this->dn;
+    foreach($order as $cn=>$disk){
+      $disk_dn                    = "cn=".$disk['cn'].",".$this->dn;
       $disk_attrs['cn']           =  $disk['cn'];
       $disk_attrs['description']  =  $disk['description']; 
-      $disk_attrs['objectClass']=array("top","FAIclass","FAIpartitionDisk");
+      $disk_attrs['objectClass']  =  array("top","FAIclass","FAIpartitionDisk");
+  
+      if($disk['status'] == "delete"){
+        $ldap->cd($disk_dn);
+        $ldap->rmdir_recursive($disk_dn);
+      }elseif($disk['status']== "edited"){
+        $ldap->cd($disk_dn);
+        $ldap->modify($disk_attrs);
+      }elseif($disk['status']== "new"){
+        $ldap->cd($disk_dn);
+        $ldap->create_missing_trees($disk_dn);
+        $ldap->cd($disk_dn);
+        $ldap->add($disk_attrs);
+      }else{
+        print_red("unknown status while saving disks");
+      }
 
-      $ldap->cd($disk_cn);
-      $ldap->create_missing_trees($disk_cn);
-      $ldap->cd($disk_cn);
-      $ldap->add($disk_attrs);
-      show_ldap_error($ldap->get_error());
+      //print $disk_dn;
+      //print_a($disk_attrs);
 
+      show_ldap_error($ldap->get_error());
+      if($disk['status']!="delete")
       /* Add all partitions */
       foreach($disk['partitions'] as $key => $partition){
         $partition_attrs = array();
@@ -251,14 +337,29 @@ class faiPartitionTable extends plugin
           }
         }
 
-        $partition_dn                       = "cn=".$partition_attrs['cn'].",".$disk_cn;      
+        $partition_dn                       = "cn=".$partition_attrs['cn'].",".$disk_dn;      
         $partition_attrs['objectClass']     = array("top","FAIclass","FAIpartitionEntry");
+        
+        unset($partition_attrs['status']);
+        unset($partition_attrs['old_cn']);
+      
+        //print $partition_dn;
+        //print_a($partition);
+        //print_a($partition_attrs);
 
-        $ldap->cd($partition_dn);
-        $ldap->create_missing_trees($partition_dn);
-        $ldap->cd($partition_dn);
-        $ldap->add($partition_attrs);
-        show_ldap_error($ldap->get_error());
+        if(($partition['status'] == "delete")&&($disk['status']!="new")){
+          $ldap->cd($partition_dn);
+          $ldap->rmdir_recursive($partition_dn);
+        }elseif($partition['status'] == "new"){
+          $ldap->cd($partition_dn);
+          $ldap->create_missing_trees($partition_dn);
+          $ldap->cd($partition_dn);
+          $ldap->add($partition_attrs);
+        }elseif($partition['status'] == "edited"){
+          $ldap->cd($partition_dn);
+          $ldap->modify($partition_attrs);
+        } 
+      show_ldap_error($ldap->get_error());
       }
     }
     $this->handle_post_events("add");
index c652ee965f43b51bcd91a292ca5cd59d608c7326..c56e71d95cb1ac8d173a9c60dd41af571184aeea 100644 (file)
@@ -12,36 +12,74 @@ class faiPartitionTableEntry extends plugin
   var $attributes   = array("DISK_cn","DISK_description");
   var $objectclasses= array();
 
-  var $DISK_cn          = "";
-  var $DISK_description = "";
+  var $DISK_cn              = "";
+  var $DISK_description     = "";
   
   var $partitions           = array();
   var $UsedAttrs            = array();
   var $AvailableDiskNames   = array();
   var $is_edit              = false;
   var $old_cn               = "";
+  var $status               = "new";
+  var $deletePartitions     = array();
 
-  function faiPartitionTableEntry ($config, $dn= NULL,$disk=false)
+  function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false)
   {
     plugin::plugin ($config, $dn);
     $this->UsedAttrs  = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
                          "FAImountOptions","FAIfsOptions","FAIpartitionFlags");
 
+    /* Generate available disknames, to avoid duplicates in cn */
     $this->AvailableDiskNames = array();
     foreach(array("a","b","c","d","e","f","g","h") as $ts){
-      $this->AvailableDiskNames["hd".$ts]= "hd".$ts;
+      if(!in_array("hd".$ts,$usedDiskNames)){
+        $this->AvailableDiskNames["hd".$ts]= "hd".$ts;
+      }
     }
     
+    /* Default status is new */
+    $this->status = "new";    
+    /* We want to edit an entry */
     if($disk){
+
+      /* Set disk status */      
+      $this->status = $disk['status'];
+
+      /* Walk through partitions */
       foreach($disk['partitions'] as $name => $values){
-        foreach($this->UsedAttrs as $attr){
-          if(!isset($values[$attr])){
-             $disk['partitions'][$name][$attr]="";  
+
+        /* If a partition is already marked as delete, attach it to deletePartitions only. */
+        if($values['status'] == "delete"){
+          unset($disk['partitions'][$name]);
+          $this->deletePartitions[]=$values;
+        }else{
+
+          /* Set status, to know which partition must be deleted from ldap
+             new    : Neu partition entry // save
+             edited : Update partition entry in ldap
+             deleted: Remove partition from ldap
+           */
+    
+          /* If status is not new, set to edit mode. 
+           * New means that this partition currently wasn't saved to ldap.
+           */
+          if($disk['partitions'][$name]['status']!="new"){
+            $disk['partitions'][$name]['status']="edited";
+          }
+     
+          $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn'];
+          /* Assign empty attributes, if attribute is missing */
+          foreach($this->UsedAttrs as $attr){
+            if(!isset($values[$attr])){
+              $disk['partitions'][$name][$attr]="";  
+            }
           }
         }
       }
 
-
+      /* Set default attributes */
       $this->DISK_cn          = $disk['cn'];
       $this->DISK_description = $disk['description'];
       $this->partitions       = $disk['partitions'];
@@ -57,7 +95,7 @@ class faiPartitionTableEntry extends plugin
     $s_action   = "";
     $s_entry    = "";
     $display    = "";
-
+    
     /* Assign values 
      * And Checkbox selection
      */
@@ -87,15 +125,20 @@ class faiPartitionTableEntry extends plugin
      * with partitions order.
      */
     if($s_action == "remove"){
-      unset($this->partitions[$s_entry]);
+      if($this->partitions[$s_entry]['status'] == "edited"){
+        $this->deletePartitions[]= $this->partitions[$s_entry];
+        unset($this->partitions[$s_entry]);
+      }else{
+        unset($this->partitions[$s_entry]);
+      }
       $tmp= array();
       foreach($this->partitions as $part){
         $tmp[count($tmp)+1]=$part;
       }
       $this->partitions = $tmp;
-
     }
 
+
     /* To add a partitions we only append an empty 
      *  array to the already defined partitions.
      */
@@ -103,6 +146,8 @@ class faiPartitionTableEntry extends plugin
       foreach($this->UsedAttrs as $attr){
         $tmp[$attr]                = "";     
       }
+      $tmp["old_cn"]               = "";     
+      $tmp['status']="new";
       $this->partitions[count($this->partitions)+1]=$tmp;
     }
 
@@ -120,11 +165,11 @@ class faiPartitionTableEntry extends plugin
     /* The user can't change a diskname 
      *  if we are currently in edit mode for the specified disk 
      */
-    if($this->is_edit){
-      $smarty->assign("DISK_cnACL"," disabled ");
-    }else{
+//    if($this->is_edit){
+//      $smarty->assign("DISK_cnACL"," disabled ");
+//    }else{
       $smarty->assign("DISK_cnACL","");
-    }
+//    }
 
     /* Fetch template and show the result
      */
@@ -160,49 +205,50 @@ class faiPartitionTableEntry extends plugin
      * To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2
      */
     foreach($this->partitions as $key => $part){
+      if($part['status']!="delete"){
+        /* Generate Partition select box  
+         */
+        $PartitionType = "<select name='FAIpartitionType_".$key."'>";
+        foreach($PartitionTypes as $type){
+          if($part['FAIpartitionType'] == $type){
+            $PartitionType .="<option value='".$type."' selected >".$type."</option>";
+          }else{
+            $PartitionType .="<option value='".$type."'>".$type."</option>";
+          }
+        }        
+        $PartitionType.="</select>";   
 
-      /* Generate Partition select box  
-       */
-      $PartitionType = "<select name='FAIpartitionType_".$key."'>";
-      foreach($PartitionTypes as $type){
-        if($part['FAIpartitionType'] == $type){
-          $PartitionType .="<option value='".$type."' selected >".$type."</option>";
-        }else{
-          $PartitionType .="<option value='".$type."'>".$type."</option>";
-        }
-      }        
-      $PartitionType.="</select>";   
-
-      
-      /* Generate fsType select box  
-       */
-      $FAIfsType= "<select name='FAIfsType_".$key."'>";
-      foreach($FAIfsTypes as $type){
-        if($part['FAIfsType'] == $type){
-          $FAIfsType  .="<option value='".$type."' selected >".$type."</option>";
+
+        /* Generate fsType select box  
+         */
+        $FAIfsType= "<select name='FAIfsType_".$key."'>";
+        foreach($FAIfsTypes as $type){
+          if($part['FAIfsType'] == $type){
+            $FAIfsType  .="<option value='".$type."' selected >".$type."</option>";
+          }else{
+            $FAIfsType .="<option value='".$type."'>".$type."</option>";
+          }
+        }        
+        $FAIfsType.="</select>";   
+
+        $str .= "<tr>";
+        $str .= "<td>".($key)."</td>";
+        $str .= "<td><input name='cn_".$key."'                value='".$part['cn']."'               maxlength='8' style='width:80px;'></td>";
+        $str .= "<td><input name='description_".$key."'       value='".$part['description']."'      maxlength='8' style='width:80px;'></td>";
+        $str .= "<td>".$PartitionType."</td>";
+        $str .= "<td>".$FAIfsType."</td>";
+        $str .= "<td><input name='FAImountPoint_".$key."'     value='".$part['FAImountPoint']."'    ></td>";
+        $str .= "<td><input name='FAIpartitionSize_".$key."'  value='".$part['FAIpartitionSize']."' style='width:200px;'></td>";
+        $str .= "<td><input name='FAImountOptions_".$key."'   value='".$part['FAImountOptions']."'  style='width:100px;'></td>";
+        $str .= "<td><input name='FAIfsOptions_".$key."'      value='".$part['FAIfsOptions']."'     style='width:100px;'></td>";
+        if($part['FAIpartitionFlags']!=false){
+          $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked></td>";
         }else{
-          $FAIfsType .="<option value='".$type."'>".$type."</option>";
+          $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve'></td>";
         }
-      }        
-      $FAIfsType.="</select>";   
-   
-      $str .= "<tr>";
-      $str .= "<td>".($key)."</td>";
-      $str .= "<td><input name='cn_".$key."'                value='".$part['cn']."'               maxlength='8' style='width:80px;'></td>";
-      $str .= "<td><input name='description_".$key."'       value='".$part['description']."'      maxlength='8' style='width:80px;'></td>";
-      $str .= "<td>".$PartitionType."</td>";
-      $str .= "<td>".$FAIfsType."</td>";
-      $str .= "<td><input name='FAImountPoint_".$key."'     value='".$part['FAImountPoint']."'    ></td>";
-      $str .= "<td><input name='FAIpartitionSize_".$key."'  value='".$part['FAIpartitionSize']."' style='width:200px;'></td>";
-      $str .= "<td><input name='FAImountOptions_".$key."'   value='".$part['FAImountOptions']."'  style='width:100px;'></td>";
-      $str .= "<td><input name='FAIfsOptions_".$key."'      value='".$part['FAIfsOptions']."'     style='width:100px;'></td>";
-      if($part['FAIpartitionFlags']!=false){
-        $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked></td>";
-      }else{
-        $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve'></td>";
+        $str .= "<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."'></td>";
+        $str .= "</tr>";    
       }
-      $str .= "<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."'></td>";
-      $str .= "</tr>";    
     }
     $str.="</table>";
     return($str);
@@ -252,11 +298,27 @@ class faiPartitionTableEntry extends plugin
     /* check every partition.
      * if there is an invalid value defined, append an errorstr to message
      */
+
+    /* Array that contain every partitionname mountpoint etc already assigned */
+    $alreadyUsed    = array();
+    foreach($this->UsedAttrs as $attrs){
+      $alreadyUsed[$attrs] = array();
+    }      
+
     foreach($this->partitions as $key => $part){
+    
       if((empty($part['cn']))||(preg_match("/[^0-9a-z]/",$part['cn']))){
-        $message[]=sprintf(_("Please enter a valid name for partition %s." ),($key));
+        $message[]=sprintf(_("Please enter a valid name for partition %s."),($key));
+      }
+
+      if(in_array($part['cn'],$alreadyUsed['cn'])){
+        $message[]=sprintf(_("please enter a unique name for partition %s"),($key));
       }
     
+      if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){
+        $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key));
+      }
+
       if(empty($part['description'])){
         $message[]=sprintf(_("Please enter a valid description for partition %s." ),($key));
       }
@@ -265,6 +327,12 @@ class faiPartitionTableEntry extends plugin
         $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key));
       }
 
+      if($part['FAIfsType'] == "swap"){
+        if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){
+          $message[]=sprintf(_("Fils system type 'swap' is already used, change file system type for partition %s."),$key);
+        }
+      }
+
       $tmp = split("-",$part['FAIpartitionSize']);
       if(count($tmp)!=2){
         $message[]=sprintf(_("Please enter a range for partition size, 'from-to', for partition %s."),($key));
@@ -272,6 +340,11 @@ class faiPartitionTableEntry extends plugin
         $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); 
       }elseif($tmp[0]>=$tmp[1]){
         $message[]=sprintf(_("Please enter a valid range for partition %s."),($key));
+      }elseif($this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key)){
+        $message[]=$this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key);
+      }
+      foreach($this->UsedAttrs as $attrs){
+        $alreadyUsed[$attrs][$key] = $part[$attrs];
       }      
     }
 
@@ -291,7 +364,30 @@ class faiPartitionTableEntry extends plugin
 
     return ($message);
   }
-
+
+  /* This function checks the selected partition sizes 
+   * If a size setting overlap with another, it returns an error msg
+   */ 
+  function checkSize($current,$others,$ckey){
+    $tmp = split("-",$current);
+    $from = $tmp[0];
+    $to   = $tmp[1];
+    foreach($others as $key=> $other){
+      $tmp  = split("-",$other);
+      $oth_from = $tmp[0];
+      $oth_to   = $tmp[1];
+      /* surrounds another entry */
+      if( (($from <= $oth_from)&&($to >= $oth_to))||    // inside
+          (($from >= $oth_from)&&($to <= $oth_to))||    // outside
+          (($to >= $oth_from)&&($to <= $oth_to))  ||    // overlap at right
+          (($from >= $oth_from)&&($from <= $oth_to)) ){ // overlap left
+        $message =sprintf( _("Size settings for partition %s, overlap with size settings for partition %s."),$ckey,$key);
+        return($message);
+      }
+    }
+    return(false);
+  }
   
   function save()
   {
@@ -299,19 +395,47 @@ class faiPartitionTableEntry extends plugin
      * If the disk was edited and not a new one, we reset the name of the disk
      *  to keep the correct index.
      */
-  
-    if($this->is_edit){
-      $tmp['cn']          = $this->old_cn;
-    }else{
-      $tmp['cn']          = $this->DISK_cn;
+
+    /* Check partition rename
+    */
+    foreach($this->partitions as $key => $part){
+      if($part['cn'] != $part['old_cn']){
+        if($part['status'] == "edited"){
+
+          $tmp          = $part;
+          $tmp['status']= "delete";
+          $tmp['cn']    = $part['old_cn'];
+
+          $this->deletePartitions[] = $tmp;
+        }
+        $this->partitions[$key]['old_cn']=$part['cn'];
+        $this->partitions[$key]['status']="new";
+      }
     }
-  
+
+    $tmp = array();
+    $tmp['cn']          = $this->DISK_cn;
+    /* Attach partitions */ 
     foreach($this->partitions as $key=>$val) {
       $this->partitions[$key]['FAIpartitionNr']=$key;
     }
-  
+
+    /* Attach deleted */ 
+    foreach($this->deletePartitions as $key=>$val) {
+      $this->partitions[$key."-delete"]=$val;
+      $this->partitions[$key."-delete"]['status']="delete";
+    } 
     $tmp['description'] = $this->DISK_description;
     $tmp['partitions']  = $this->partitions;
+    $tmp['status']      = $this->status;
+
+    /* If hdd name has changed, tell partitionTable to rename it */
+    if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){
+      $tmp['rename']['from']  = $this->old_cn;    
+      $tmp['rename']['to']    = $this->DISK_cn;    
+    }
 
     return($tmp);
   }