Code

Enabled saving of LVM Volumes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 11 May 2011 14:35:07 +0000 (14:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 11 May 2011 14:35:07 +0000 (14:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20809 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Device/AddPartitionDialog.tpl
gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc

index ba93e6436e748c648b7a89171edd93eea246cfae..4e6dc0132b6faf411ce2260dfc24a48a14e7f77f 100644 (file)
 {if $selected_type==4}
     
     <h3>{t}LVM Volume{/t}</h3>
+    <table>
+        <tr>
+            <td>{t}Volume name{/t}</td>
+            <td>
+                <input type="text" name="v_name" value="{$v_name}">
+            </td>
+        </tr>
+        <tr>
+            <td>{t}Volume group{/t}</td>
+            <td>
+                <select name="v_group">
+                    {html_options options=$volumeGroupList selected=$v_group}
+                </select>
+            </td>
+        </tr>
+        <tr>
+            <td>{t}Mount point{/t}</td>
+            <td>
+                {if $v_fsType == "swap"}
+                    <input disabled type="text" name="v_mountPoint" value=" - ">
+                {else}
+                    <input type="text" name="v_mountPoint" value="{$v_mountPoint}">
+                {/if}
+            </td>
+        </tr>
+        <tr>
+            <td>{t}File system type{/t}</td>
+            <td>
+                <select name="v_fsType" onChange="document.mainform.submit();">
+                    {html_options options=$fsTypes selected=$v_fsType}
+                </select>
+            </td>
+        </tr>
+        <tr>
+            <td>{t}Size{/t}</td>
+            <td>
+                <input name="v_size" value="{$v_size}">
+            </td>
+        </tr>
+        <tr>
+            <td>{t}Encrypt{/t}</td>
+            <td><input type="checkbox" name="v_encrypt" {if $v_encrypt_selected} checked {/if}></td>
+        </tr>
+    </table>
 
 {elseif $selected_type==3}
     
index 87d0bcdff3b06aa782b6f3c3007004f165ec53b8..fb86911a9f9b5cdbc5701fed88187a82eec4748c 100644 (file)
@@ -15,6 +15,7 @@ class AddPartitionDialog
     public $paritions = array();
     public $selected_type = PARTITION;
 
+
     // LVM Volume group properties
     public $vg_name = "";
     public $vg_extend = 32;
@@ -25,6 +26,16 @@ class AddPartitionDialog
     public $usedLvmPartitions = array();
     public $freeLvmPartitions = array();
 
+    // Volume properties 
+    public $v_name = "";
+    public $v_group = "";
+    public $v_mountPoint = "";
+    public $v_fsType = "ext3";
+    public $v_fsOptions = "";
+    public $v_size = 1000;
+    public $v_encrypt = FALSE;
+    public $volumeGroupList = array();
+
     // Raid device properties
     public $r_fsType = 'ext3';
     public $r_fsOptions = '';
@@ -63,6 +74,10 @@ class AddPartitionDialog
     // Volume group attributes
     public $vg_attributes = array("vg_name", "vg_partitions", "vg_extend");
 
+    // Volume  attributes
+    public $v_attributes = array("v_name", "v_group", "v_mountPoint", "v_fsType", 
+            "v_size", "v_encrypt", "v_fsOptions");
+
     /*! \brief  Constructs the Dialog and loads all required informations
      *          to be able to add partitions, raid devices, volumes groups ...
      *  @param  Config          The GOsa configuration object.
@@ -115,6 +130,7 @@ class AddPartitionDialog
             $this->usedRaidPartitions = array_merge($dev['devices'], $this->usedRaidPartitions);
         }
         foreach($this->volumeGroups as $vg){
+            $this->volumeGroupList[$vg['name']] = $vg['name'];
             $this->usedLvmPartitions = array_merge($vg['partitions'], $this->usedLvmPartitions);
         }
         foreach($this->partitions as $part){
@@ -166,6 +182,13 @@ class AddPartitionDialog
                     $attrs = $this->vg_attributes;
                     break;
                 }
+            case VOLUME: {
+                    $attrs = $this->v_attributes;
+                    unset($fsTypes['raid']);
+                    unset($fsTypes['pv']);
+                    $bool_attrs = array("v_encrypt");
+                    break;
+                }
         }
 
         // Assign properties to smarty.
@@ -180,6 +203,7 @@ class AddPartitionDialog
         $smarty->assign('freeRaidPartitions', $this->freeRaidPartitions);
         $smarty->assign('disks', $this->disks);
         $smarty->assign('physicalExtendList', $this->physicalExtendList);
+        $smarty->assign('volumeGroupList', $this->volumeGroupList);
         $smarty->assign('freeLvmPartitions', $this->freeLvmPartitions);
         return($smarty->fetch(get_template_path("goto/Device/AddPartitionDialog.tpl", TRUE)));
     }
@@ -200,7 +224,6 @@ class AddPartitionDialog
             case RAID_DEVICE: {
                     $attrs = $this->r_attributes;
                     $bool_attrs = array("r_encrypt");
-    
                     $this->r_partitions = array();
                     foreach($this->freeRaidPartitions as $key => $part){
                         if(isset($_POST['r_partition_'.$key])){
@@ -219,6 +242,11 @@ class AddPartitionDialog
                     }
                     break;
                 }
+            case VOLUME: {
+                    $attrs = $this->v_attributes;
+                    $bool_attrs = array("v_encrypt");
+                    break;
+                }
         }
 
         // Get posted string values 
@@ -243,13 +271,38 @@ class AddPartitionDialog
     {
         if($this->selected_type == VOLUME_GROUP){
             
-            // Get raid device properties
+            // Get volume group properties
             $devices = $this->vg_partitions;
             $extend = $this->vg_extend;
             $name = $this->vg_name;
             $this->partitionObject->addVolumeGroup($name, $devices, $format=TRUE, $use_existing=FALSE, $extend);
             return($this->partitionObject->success());
 
+        }elseif($this->selected_type == VOLUME){
+            
+            // Get volume properties
+            $name = $this->v_name;
+            $fsType = $this->v_fsType;
+            $fsOptions = $this->v_fsOptions;
+            $group = $this->v_group;
+            $target = $this->v_mountPoint;
+            $size = $this->v_size;
+            $encrypt = $this->v_encrypt;
+            
+            $maxSize = NULL;
+            $grow = FALSE;
+            $format = TRUE;
+            $use_existing = FALSE;
+
+            if($fsType == "swap"){
+                $target = "swap";
+            }
+      
+            $this->partitionObject->addVolume($target, $name, $group, $size, $maxSize,
+                $grow, $format, $use_existing, $fsType, $fsOptions);
+
+            return($this->partitionObject->success());
+
         }elseif($this->selected_type == RAID_DEVICE){
 
             // Get raid device properties