Code

We can now save volume groups.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Jul 2009 11:39:41 +0000 (11:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Jul 2009 11:39:41 +0000 (11:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13963 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/faiDiskEntry.tpl
gosa-plugins/fai/admin/fai/faiPartition.tpl

index 694045765ef5582d0f420b3cb9a742d7ede0f27c..9d5f8c943535e55920a8df92817a29a1e2094c34 100644 (file)
@@ -13,9 +13,9 @@ class faiDiskEntry extends plugin
   
   var $partitions           = array();
   var $UsedAttrs            = array("cn","description","FAIpartitionType",
-        "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize","FAIfsTuneOptions",
-        "FAIfsCreateOptions",
-        "FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption");
+      "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
+      "FAIfsTuneOptions", "FAIfsCreateOptions", "FAImountOptions",
+      "FAIfsOptions","FAIpartitionFlags","FAIdiskOption");
 
   var $is_edit              = false;
   var $old_cn               = "";
@@ -23,7 +23,6 @@ class faiDiskEntry extends plugin
   var $deletePartitions     = array();
   var $fstabkey             = "device";
   var $disklabel            = "msdos";
-
   var $FAIstate             = "";
   var $FAIdiskType          = "disk";
 
@@ -31,12 +30,10 @@ class faiDiskEntry extends plugin
   {
     plugin::plugin ($config, $dn);
 
-
     // Set default attributes 
     $this->parent = $parent;
     $this->FAIdiskType = $type;
     $this->status = "new";    
 
     // If disk is not empty, then we are going to edit 
     //  an existing disk, load disk info now. 
@@ -111,7 +108,9 @@ class faiDiskEntry extends plugin
           if (preg_match("/^bootable:/", $option)){
             $bootable = split(",", trim(preg_replace("/^bootable:/","",$option),","));
             foreach($bootable as $bootflag){
-              $this->partitions[$bootflag]['bootable'] = TRUE;  
+              if(isset($this->partitions[$bootflag])){
+                $this->partitions[$bootflag]['bootable'] = TRUE;  
+              }
             }
             continue;
           }
@@ -120,7 +119,9 @@ class faiDiskEntry extends plugin
           if (preg_match("/^resize:/", $option)){
             $resize = split(",", trim(preg_replace("/^resize:/","",$option),","));
             foreach($resize as $id){
-              $this->partitions[$id]['resize'] = TRUE;  
+              if(isset($this->partitions[$bootflag])){
+                $this->partitions[$id]['resize'] = TRUE;  
+              }
             }
             continue;
           }
@@ -129,8 +130,10 @@ class faiDiskEntry extends plugin
           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';  
+              if(isset($this->partitions[$bootflag])){
+                $this->partitions[$presflag]['preserve'] = TRUE;  
+                $this->partitions[$presflag]['preserveType'] = 'always';  
+              }
             }
             continue;
           }
@@ -139,8 +142,10 @@ class faiDiskEntry extends plugin
           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';  
+              if(isset($this->partitions[$bootflag])){
+                $this->partitions[$presflag]['preserve'] = TRUE;  
+                $this->partitions[$presflag]['preserveType'] = 'reinstall'; 
+              } 
             }
             continue;
           }
@@ -225,10 +230,12 @@ class faiDiskEntry extends plugin
     if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){
       $this->dialog->save_object();
       $attrs = $this->dialog->save();
-      if(isset($attrs['FAIpartitionNr'])){
+      if(isset($attrs['FAIpartitionNr']) && $attrs['FAIpartitionNr'] != ""){
         $this->partitions[$attrs['FAIpartitionNr']] = $attrs;
       }else{
-        $this->partitions[] = $attrs;
+        $attrs['FAIpartitionNr'] = count($this->partitions) + 1;
+        $attrs['cn'] = &$attrs['FAIpartitionNr'];
+        $this->partitions[$attrs['FAIpartitionNr']] = $attrs;
       }
       $this->dialog = null;
     }
index 72942a65d14017215293efe93711ec7b29772861..ced852af98433b793288bc7957509c42c218189e 100644 (file)
@@ -42,66 +42,71 @@ class faiPartition extends plugin
   {
 
     $this->parent = $parent;
+    $this->status = "new";
+   
+    // Load attributes from existing partition 
+    if($object){
 
-    foreach($this->attributes as $attr){
-      if(isset($object[$attr])){
-        $this->$attr = $object[$attr];
+      foreach($this->attributes as $attr){
+        if(isset($object[$attr])){
+          $this->$attr = $object[$attr];
+        }
       }
-    }
 
-    $this->status = $object['status'];
-    $this->FAIdiskType = $type;
-
-    if($type == "disk"){
-
-      /* Prepare size attribute 
-       * This attribute may represent a range, a fixed value 
-       *  or a percentage.
-       * fixed is just a number   * 500MB
-       * range                    * 500MB-1TB
-       * remaining                * -
-       */
-      // Fixed
-      if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
-        $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
-        $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
-        $this->FAIpartitionSizeType = "fixed";
-      }else
-
-      // Dynamic range
-      if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)-[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
-        $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\1",$this->FAIpartitionSize);
-        $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\2",$this->FAIpartitionSize);
-        $this->sizeStop = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
-        $this->sizeStop_Type = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
-        $this->FAIpartitionSizeType = "dynamic";
-      }else
-
-      // Dynamic range
-      if(preg_match("/^\-$/",$this->FAIpartitionSize)){
-        $this->FAIpartitionSizeType = "remaining";
+      $this->status = $object['status'];
+      $this->FAIdiskType = $type;
+
+      if($type == "disk"){
+
+        /* Prepare size attribute 
+         * This attribute may represent a range, a fixed value 
+         *  or a percentage.
+         * fixed is just a number   * 500MB
+         * range                    * 500MB-1TB
+         * remaining                * -
+         */
+        // Fixed
+        if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+          $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
+          $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
+          $this->FAIpartitionSizeType = "fixed";
+        }else
+
+        // Dynamic range
+        if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)-[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+          $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\1",$this->FAIpartitionSize);
+          $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\2",$this->FAIpartitionSize);
+          $this->sizeStop = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
+          $this->sizeStop_Type = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
+          $this->FAIpartitionSizeType = "dynamic";
+        }else
+
+        // Dynamic range
+        if(preg_match("/^\-$/",$this->FAIpartitionSize)){
+          $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);
-      foreach($usedDisks as $disk){
-        $name = preg_replace("/:.*$/","",$disk);
-        $spare = preg_match("/:spare/",$disk);
-        $missing = preg_match("/:missing/",$disk);
-        $this->raidDevices[$name] = 
-          array(
-              "name" => $name, 
-              "spare" => $spare, 
-              "missing" => $missing);
+        /* 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);
+        foreach($usedDisks as $disk){
+          $name = preg_replace("/:.*$/","",$disk);
+          $spare = preg_match("/:spare/",$disk);
+          $missing = preg_match("/:missing/",$disk);
+          $this->raidDevices[$name] = 
+            array(
+                "name" => $name, 
+                "spare" => $spare, 
+                "missing" => $missing);
+        }
       }
     }
   }
index 1dc9916a9b6399bffbfb1cc116d69e7ed4018c20..b1de5061ea52ab5c3cc893426d095630fa7701b8 100644 (file)
@@ -3,56 +3,62 @@
 <table style='width:100%' summary="">
        <tr>
                <td style='width:50%;border-right:1px solid #909090;'>
-                <table>
-                <tr>
-                <td>
-                        <LABEL for="DISKcn">
-                       {t}Name{/t}
-                       </LABEL>{$must}&nbsp;
-                </td><td>
+
+      <table>
+        <tr>
+          <td>
+            <LABEL for="DISKcn">{t}Name{/t}</LABEL>{$must}&nbsp;
+          </td>
+          <td>
 {render acl=$DISKcnACL}
-                       <input value="{$DISKcn}" size="45" maxlength="80" name="DISKcn" id="DISKcn">
+                             <input value="{$DISKcn}" size="45" maxlength="80" name="DISKcn" id="DISKcn">
 {/render}
-               </td>
-                </tr>
-                <tr>
-               <td><LABEL for="fstabkey">
-                       {t}FSTAB key{/t}
-                </td><td>
+               </td>
+        </tr>
+        <tr>
+                     <td>
+            <LABEL for="fstabkey">{t}FSTAB key{/t}</LABEL>
+          </td>
+          <td>
 {render acl=$DISKFAIdiskOptionACL}
-                        <select name="fstabkey" size="1">
-                           {html_options options=$fstabkeys selected=$fstabkey}
-                        </select>
+            <select name="fstabkey" size="1">
+               {html_options options=$fstabkeys selected=$fstabkey}
+            </select>
 {/render}
-               </td>
-                </tr>
-                </table>
-                </td>
+                     </td>
+        </tr>
+      </table>
+
+    </td>
                <td>
-                <table>
-                <tr>
-                <td>
-<LABEL for="DISKdescription">
-                       &nbsp;{t}Description{/t}
-                       </LABEL>&nbsp;
-                </td><td>
+
+      <table>
+        <tr>
+          <td>
+            <LABEL for="DISKdescription">&nbsp;{t}Description{/t}</LABEL>&nbsp;
+          </td>
+          <td>
 {render acl=$DISKdescriptionACL}
-                       <input value="{$DISKdescription}" size="45" maxlength="80" name="DISKdescription" id="DISKdescription">
+                             <input value="{$DISKdescription}" size="45" maxlength="80" 
+              name="DISKdescription" id="DISKdescription">
 {/render}
-               </td>
-                </tr>
-                <tr>
-               <td><LABEL for="disklabel">
-                       {t}Disk label{/t}
-                </td><td>
+                     </td>
+        </tr>
+        <tr>
+                     <td>
+            <LABEL for="disklabel">{t}Disk label{/t}</LABEL>
+          </td>
+          <td>
 {render acl=$DISKFAIdiskOptionACL}
-                        <select name="disklabel" size="1">
-                           {html_options options=$disklabels selected=$disklabel}
-                        </select>
+            <select name="disklabel" size="1">
+               {html_options options=$disklabels selected=$disklabel}
+            </select>
 {/render}
-               </td>
-                </tr>
-                </table>
+                     </td>
+        </tr>
+      </table>
+
+    </td>
        </tr>
 </table>
 <br>
index 34d78945b1fcdf4f5aad6eabfde4e7949ae588ec..1d33862d6ded4321d312072192899fe8ec402326 100644 (file)
@@ -22,7 +22,7 @@
     </td>
   </tr>
 
-{if $FAIdiskType == "disk"}
+{if $FAIdiskType == "disk" || $FAIdiskType == "lvm"}
 
   <tr>
     <td>{t}Size{/t}</td>
   </tr>
 {/if}
 
-{if $FAIdiskType == "raid"  || $FAIdiskType == "disk"}
-
   <tr>
     <td>
       {t}Filesystem{/t}
     </td>
   </tr>
 
-{/if}
-
-
-
   <!-- Table cell sizing  --> 
   <tr>
     <td colspan=2 style='width:50%;'></td>