Code

Updated LVM handling for FAI partitions.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Aug 2009 07:56:50 +0000 (07:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Aug 2009 07:56:50 +0000 (07:56 +0000)
- Allow to remove multiple physical partitions.
- Allow user defined partition names (cn).
- Updated FAIpartitionTable class, do not act on POST in save_object while
  we are in sub dialogs.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13976 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc
gosa-plugins/fai/admin/fai/class_faiPartition.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
gosa-plugins/fai/admin/fai/faiDiskEntry.tpl
gosa-plugins/fai/admin/fai/faiPartition.tpl
gosa-plugins/fai/admin/fai/faiPartitionTable.tpl

index a3819d5cece1bb74199064ece9796d43f90417a7..3e3f8cc2aa1bfa70413d8d140bdccbf0e90126b1 100644 (file)
@@ -175,12 +175,22 @@ class faiDiskEntry extends plugin
     $s_entry    = "";
     $display    = "";
 
-    // Remove partition
+    // Add partition to lvm compilation.
     if(isset($_POST['addLvmPartition']) && isset($_POST['lvmPartitionAdd'])){
-      $name = $_POST['lvmPartitionAdd'];
+      $name = get_post('lvmPartitionAdd');
       $this->lvmDevices[$name] = $name;
     }
 
+    // Remove partition from lvm compilation.
+    if(isset($_POST['delLvmPartition']) && isset($_POST['physicalPartition'])){
+      $names = $_POST['physicalPartition'];
+      foreach($names as $name){
+        if(isset($this->lvmDevices[$name])){
+          unset($this->lvmDevices[$name]);
+        }
+      }
+    }
+
     /* Check all Posts if there is something usefull for us,
      * For example : Delete is posted as Delete_1 
      * The number specifies the index we want to delete
@@ -365,9 +375,14 @@ class faiDiskEntry extends plugin
   {
     if(!isset($part['FAIpartitionNr']) || $part['FAIpartitionNr'] == "undefined"){
       $part['FAIpartitionNr'] = count($this->partitions) + 1;
+    }
+
+    /* Update the disk cn -       
+     * Do NOT touch the partition 'cn' in case of lvm devices. 
+     */
+    if($this->FAIdiskType == "disk"){
       $part['cn'] = $this->DISKcn.$part['FAIpartitionNr'];
     }
-    $part['cn'] = $this->DISKcn.$part['FAIpartitionNr'];
     $this->partitions[$part['FAIpartitionNr']] = $part;
   }
 
@@ -404,10 +419,13 @@ class faiDiskEntry extends plugin
       $action =array(
           "string" => "<input type='image' src='images/lists/edit.png' name='EditPartition_".$key."'>".
                       "<input type='image' src='images/lists/trash.png' name='RemovePartition_".$key."'>",
-          "attach" => "style='width:40px;'");
+          "attach" => "style='width:40px; border-right: 0px;'");
 
-      $fields = array($number,$type,$mntp,$size,$fstype, $opt,$fsopt,$flags,$action);
+      if($this->FAIdiskType == "lvm"){ 
+        $fields = array($type,$mntp,$size,$fstype, $opt,$fsopt,$flags,$action);
+      }else{
+        $fields = array($number,$type,$mntp,$size,$fstype, $opt,$fsopt,$flags,$action);
+      }
       $divlist->AddEntry($fields);
     }
     return($divlist->DrawList());    
@@ -422,7 +440,10 @@ class faiDiskEntry extends plugin
     /* Attach partitions */
     foreach($this->partitions as $key=>$val) {
       $this->partitions[$key]['FAIpartitionNr']=$key;
-      $this->partitions[$key]['cn'] = $this->DISKcn.$key;
+
+      if($this->FAIdiskType == "disk"){
+        $this->partitions[$key]['cn'] = $this->DISKcn.$key;
+      }
     }
 
     /* Attach deleted */
index 4e8ef7eb12794a49cef746a664b44535cf976f63..296f83abd538d130afb90dce3468032be4189a7e 100644 (file)
@@ -63,6 +63,8 @@ class faiPartition extends plugin
         }
       } 
     } 
+
+    print_a($object);
  
     // Load attributes from existing partition 
     if($object){
@@ -294,6 +296,11 @@ class faiPartition extends plugin
         }
       }
 
+      // Allow user defined partition names for lvm disks.
+      if($this->FAIdiskType == "lvm" && isset($_POST['cn'])){
+        $this->cn = get_post('cn');
+      }
+
       // Remove partition
       if(isset($_POST['delPhysicalPartition']) && isset($_POST['physicalPartition'])){
         unset($this->raidDevices[$_POST['physicalPartition']]); 
@@ -404,7 +411,7 @@ class faiPartition extends plugin
     if($this->FAIfsType == "swap"){
       $ret['FAImountPoint'] = "swap";
     }
-  
     return($ret);
   }
 }
index 492d3c882d545ffbfdbd19ae3843056f005102af..4caa07c09d8c025fc930c6402cd242d6e7735a89 100644 (file)
@@ -466,14 +466,14 @@ class faiPartitionTable extends plugin
    */
   function save_object()
   {
-    if (preg_match("/freeze/", $this->FAIstate)) return;
-    plugin::save_object();
-    foreach($this->attributes as $attrs){
-      if(isset($_POST[$attrs])){
-        $this->$attrs = $_POST[$attrs];
+    if(isset($_POST['FAIpartitionTablePosted'])){
+      if (preg_match("/freeze/", $this->FAIstate)) return;
+      plugin::save_object();
+      foreach($this->attributes as $attrs){
+        if(isset($_POST[$attrs])){
+          $this->$attrs = $_POST[$attrs];
+        }
       }
-    }
-    if(isset($_POST['faiPartitionTable'])){
       if(!count($this->disks)){
         if(isset($_POST['mode'])){
           $this->FAIpartitionMethod = "setup-storage";
index 7e25562fae4a05e226ff773ba5449279dae6dde5..1481fd8e04476490cadf4d2f8e424a0523ab480c 100644 (file)
@@ -71,7 +71,7 @@
       <h2>{t}Combined physical partitions{/t}</h2>
 
       <select style='font-family: monospace; width: 100%;' 
-        name='physicalPartition' size=5
+        name='physicalPartition[]' size=5 multiple
         {html_options options=$plist}
       </select>
       <br>
index 5ca713cdc3bea78ffed7da5aba34e751653b68c7..cc4bd9f2255d5c95bf4949e1684606cb20ce2e3c 100644 (file)
@@ -6,7 +6,7 @@
 {if $FAIdiskType == "lvm"}
     <td>{t}Name{/t}</td>
     <td width="35%">
-      <input name="FAIpartitionType" value="{$FAIpartitionType}">
+      <input name="cn" value="{$cn}">
     </td>
 {else}
     <td>{t}Type{/t}</td>
index 4e976aec0f71120559d9f9e32bcb70f67eeca726..7ac1c6058c4168011ae030c4c31956eb73a49d61 100644 (file)
@@ -55,7 +55,7 @@
                </td>
        </tr>
 </table>
-<input type='hidden' name='faiPartitionTable' value='1'>
+<input type='hidden' name='FAIpartitionTablePosted' value='1'>
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page