Code

Updated lvm partition handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Jul 2009 08:55:54 +0000 (08:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Jul 2009 08:55:54 +0000 (08:55 +0000)
-We can save now, but nothing is checked or validated right now.
-Volumes are missing completely right now.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13961 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/faiPartition.tpl

index 4a656e60cd87658f8ebdbed11e25e1d5a1bde21a..bacf5e123fe57e7273503856fe808d89ce0e300c 100644 (file)
@@ -30,7 +30,8 @@ class faiDiskEntry extends plugin
     $this->parent = $parent;
 
     $this->UsedAttrs  = array("cn","description","FAIpartitionType",
-        "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
+        "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize","FAIfsTuneOptions",
+        "FAIfsCreateOptions",
         "FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption");
 
     /* Set disk type */
@@ -106,7 +107,30 @@ class faiDiskEntry extends plugin
             foreach($bootable as $bootflag){
               $this->partitions[$bootflag]['bootable'] = TRUE;  
             }
-            break;
+            continue;
+          }
+          if (preg_match("/^resize:/", $option)){
+            $resize = split(",", trim(preg_replace("/^resize:/","",$option),","));
+            foreach($resize as $id){
+              $this->partitions[$id]['resize'] = TRUE;  
+            }
+            continue;
+          }
+          if (preg_match("/^preserve_always:/", $option)){
+            $preserve = split(",", trim(preg_replace("/^preserve_always:/","",$option),","));
+            foreach($preserve as $presflag){
+              $this->partitions[$presflag]['preserve'] = TRUE;  
+              $this->partitions[$presflag]['preserveType'] = 'always';  
+            }
+            continue;
+          }
+          if (preg_match("/^preserve_reinstall:/", $option)){
+            $preserve = split(",", trim(preg_replace("/^preserve_reinstall:/","",$option),","));
+            foreach($preserve as $presflag){
+              $this->partitions[$presflag]['preserve'] = TRUE;  
+              $this->partitions[$presflag]['preserveType'] = 'reinstall';  
+            }
+            continue;
           }
         }
       } else {
@@ -314,6 +338,51 @@ class faiDiskEntry extends plugin
       $tmp['rename']['from']  = $this->old_cn;
       $tmp['rename']['to']    = $this->DISKcn;
     }
+
+    // Build up disk options 
+    $bootable = "";
+    $resize = "";
+    $preserve_always = "";
+    $preserve_reinstall = "";
+
+    foreach($tmp['partitions'] as $id => $part){
+      if(isset($part['bootable']) && $part['bootable']){
+        $bootable .= $id.",";
+      }
+      if(isset($part['resize']) && $part['resize']){
+        $resize .= $id.",";
+      }
+      if(isset($part['preserve']) && $part['preserve']){
+        if($part['preserveType'] == "always"){
+          $preserve_always .= $id.",";
+        }else{
+          $preserve_reinstall .= $id.",";
+        }
+      }
+      $tmp['partitions'][$id]['status'] = $part['status'];
+
+      // Unset non valid attributes 
+      foreach(array("bootable","encrypted","preserve","preserveType","resize","FAIdiskType") as $attr){
+        if(isset($tmp['partitions'][$id][$attr])){
+          unset($tmp['partitions'][$id][$attr]);
+        }
+      }
+    }    
+
+    if(!empty($bootable)){
+      $tmp['FAIdiskOption'][] = "bootable:".trim($bootable,",");
+    }
+    if(!empty($resize)){
+      $tmp['FAIdiskOption'][] = "resize:".trim($resize,",");
+    }
+    if(!empty($preserve_always)){
+      $tmp['FAIdiskOption'][] = "preserve_always:".trim($preserve_always,",");
+    }
+    if(!empty($preserve_reinstall)){
+      $tmp['FAIdiskOption'][] = "preserve_reinstall:".trim($preserve_reinstall,",");
+    }
+
+    $tmp['status'] = $this->status;
     return($tmp);
   }
 
@@ -403,7 +472,9 @@ class faiDiskEntry extends plugin
       }
 
       foreach($this->UsedAttrs as $attrs){
-        $alreadyUsed[$attrs][$key] = $part[$attrs];
+        if(isset($part[$attrs])){
+          $alreadyUsed[$attrs][$key] = $part[$attrs];
+        }
       }      
     }
 
index c6c901e2d9e37ed8ed897bd177299f7e14a25db1..72942a65d14017215293efe93711ec7b29772861 100644 (file)
@@ -35,6 +35,7 @@ class faiPartition extends plugin
   var $preserveType = "always";
   var $encrypted = false;
 
+  var $status = "";
   var $raidDevices = array();
 
   function __construct($config, $object, $parent,$type)
@@ -48,6 +49,7 @@ class faiPartition extends plugin
       }
     }
 
+    $this->status = $object['status'];
     $this->FAIdiskType = $type;
 
     if($type == "disk"){
@@ -80,6 +82,14 @@ class faiPartition extends plugin
         $this->FAIpartitionSizeType = "remaining";
 
       }
+
+      /* Check for encrypted partitions
+       */
+      if(preg_match("/:encrypt$/",$this->FAImountPoint)){
+        $this->FAImountPoint = preg_replace("/:encrypt/","",$this->FAImountPoint);
+        $this->encrypted = TRUE;
+      }
+  
     }elseif($type == "raid"){
   
       $usedDisks = split(",",$this->FAIpartitionSize);
@@ -154,9 +164,6 @@ class faiPartition extends plugin
         "xfs" => _("Xfs"),
         "btrfs" => _("Btrfs"));
 
-        
-
     $smarty->assign("partitionTypes", $types);
     $smarty->assign("partitionSizeTypes", $partitionSizeTypes);
     $smarty->assign("FAIpartitionSizeType", $this->FAIpartitionSizeType);
@@ -288,6 +295,12 @@ class faiPartition extends plugin
           $ret['FAIpartitionSize'] = "-";break; 
         default: trigger_error("Unknown partition size!");
       }
+
+      // Add encryption flag to partition mount point
+      if($this->encrypted){
+        $ret['FAImountPoint'] .= ":encrypt";
+      }
+
     }elseif($this->FAIdiskType == "raid"){
       $ret['FAIpartitionSize'] = "";
       foreach($this->raidDevices as $device){
@@ -302,6 +315,7 @@ class faiPartition extends plugin
       }
       $ret['FAIpartitionSize'] = trim($ret['FAIpartitionSize'],",");
     }
+    $ret['status'] = $this->status;
     return($ret);
   }
 }
index 2890e2ead70ef1be1179aabf2510e2240802c8f4..8c0a4d533e6405a8fccbbd86093311ccc1143379 100644 (file)
@@ -8,7 +8,7 @@ class faiPartitionTable extends plugin
   var $objectclasses    = array("top","FAIclass","FAIpartitionTable");
 
   var $subAttributes      = array("cn","description");
-  var $subPartAttributes  = array("cn","FAIpartitionNr","FAIpartitionSize","FAImountPoint","FAIfsType","FAIpartitionType","FAImountOptions","FAIfsOptions","FAIpartitionFlags","description");
+  var $subPartAttributes  = array("cn","FAIpartitionNr","FAIpartitionSize","FAImountPoint","FAIfsType","FAIpartitionType","FAImountOptions","FAIfsOptions","FAIpartitionFlags","description","FAIfsCreateOptions","FAIfsTuneOptions");
 
   var $sub64coded = array();
   var $subBinary = array();
@@ -545,6 +545,9 @@ class faiPartitionTable extends plugin
       if(isset($disk['FAIdiskType'])){
         $disk_attrs['FAIdiskType']  =  $disk['FAIdiskType']; 
       }
+      if(isset($disk['FAIdiskOption'])){
+        $disk_attrs['FAIdiskOption']  =  $disk['FAIdiskOption']; 
+      }
 
       if(empty($disk_attrs['description']) && $disk['status'] == "edited"){
         $disk_attrs['description'] = array();
@@ -574,6 +577,7 @@ class faiPartitionTable extends plugin
       }
 
       if($disk['status']!="delete")
+
       /* Add all partitions */
       foreach($disk['partitions'] as $key => $partition){
         $partition_attrs = array();
index a6f8536e444711b2a8424af61aead6150d42acb2..34d78945b1fcdf4f5aad6eabfde4e7949ae588ec 100644 (file)
@@ -9,7 +9,7 @@
       <input name="FAIpartitionType" value="{$FAIpartitionType}">
     </td>
 {else}
-    <td>{t}Name{/t}</td>
+    <td>{t}Type{/t}</td>
     <td>
       <select name="FAIpartitionType" onChange='document.mainform.submit();'>
         {html_options options=$partitionTypes selected=$FAIpartitionType}
@@ -75,7 +75,7 @@
     </td>
     <td>
       <select name='preserveType'>
-        {html_options options=preserveType selected=$preserveType}
+        {html_options options=$preserveTypes selected=$preserveType}
       </select>
     </td>
   </tr>