Code

Added disk creation option
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 May 2011 09:05:47 +0000 (09:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 May 2011 09:05:47 +0000 (09:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20812 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 35ddb9c64cd2666a8500e70afdca1357ff9180b6..03597c8c6471abb2e85523fba2b0ef3cb6242089 100644 (file)
@@ -1,7 +1,10 @@
 
 <h3>{t}Type{/t}</h3>
 
+<input {if $selected_type==0} checked {/if} onClick="document.mainform.submit();"
+        type="radio" value="0" name="selected_type">{t}Disk{/t}<br>
 <input {if $selected_type==1} checked {/if} onClick="document.mainform.submit();"
+        {if !count($disks)} disabled {/if}
         type="radio" value="1" name="selected_type">{t}Physical partition{/t}<br>
 <input  {if count($freeRaidPartitions) != 2} disabled {/if}
         {if $selected_type==2} checked {/if} onClick="document.mainform.submit();"
@@ -10,6 +13,7 @@
         {if $selected_type==3} checked {/if} onClick="document.mainform.submit();"
         type="radio" value="3" name="selected_type">{t}LVM Volume group{/t}<br>
 <input {if $selected_type==4} checked {/if} onClick="document.mainform.submit();"
+        {if !count($volumeGroupList)} disabled {/if}
         type="radio" value="4" name="selected_type">{t}LVM Volume{/t}<br>
 
 <hr>
 
 {elseif $selected_type==1}
 
-    <h3>{t}Add Partition{/t}</h3>
-
-    <table>
-        <tr>
-            <td>{t}Mount point{/t}</td>
-            <td>
-                {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
-                    <input disabled type="text" name="p_mountPoint" value=" - ">
-                {else}
-                    <input type="text" name="p_mountPoint" value="{$p_mountPoint}">
-                {/if}
-            </td>
-        </tr>
-        <tr>
-            <td>{t}File system type{/t}</td>
-            <td>
-                <select name="p_fsType" onChange="document.mainform.submit();">
-                    {html_options options=$fsTypes selected=$p_fsType}
-                </select>
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Allowable drives{/t}</td>
-            <td>
-                {foreach from=$disks item=item key=key}
-                    <input type="radio" {if $p_used_disk == $item} checked {/if} 
-                        name="p_used_disk" value="{$item}">{$item}
-                {/foreach}
+    <table width="100%">
+        <tr>
+            <td style="width:50%">
+                <h3>{t}Add Partition{/t}</h3>
+                <table>
+                    <tr>
+                        <td>{t}Mount point{/t}</td>
+                        <td>
+                            {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
+                                <input disabled type="text" name="p_mountPoint" value=" - ">
+                            {else}
+                                <input type="text" name="p_mountPoint" value="{$p_mountPoint}">
+                            {/if}
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}File system type{/t}</td>
+                        <td>
+                            <select name="p_fsType" onChange="document.mainform.submit();">
+                                {html_options options=$fsTypes selected=$p_fsType}
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}Allowable drives{/t}</td>
+                        <td>
+                            <select name="p_used_disk">
+                                {html_options options=$disks selected=$p_used_disk}
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}Size{/t}</td>
+                        <td>
+                            <input name="p_size" value="{$p_size}">
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}Force to be primary partition{/t}</td>
+                        <td><input type="checkbox" name="p_forcePrimary" {if $p_forcePrimary_selected} checked {/if}></td>
+                    </tr>
+                    <tr>
+                        <td>{t}Encrypt{/t}</td>
+                        <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
+                    </tr>
+                </table>
+            </td>
+            <td class="left-border"></td>
+            <td>
+
+                <h3>{t}Additional size options{/t}</h3>
+                <table>
+                    <tr>
+                        <td><input type="radio" name="p_size_options" value="0" 
+                                onClick="document.mainform.submit();"
+                                {if $p_size_options==0} checked {/if}></td>
+                        <td>{t}Fixed size{/t}</td>
+                    </tr>
+                    <tr>
+                        <td><input type="radio" name="p_size_options" value="2" 
+                                onClick="document.mainform.submit();"
+                                {if $p_size_options==2} checked {/if}></td>
+                        <td>{t}Fill to maximum allowable size{/t}</td>
+                    </tr>
+                    <tr>
+                        <td><input type="radio" name="p_size_options" value="1" 
+                                onClick="document.mainform.submit();"
+                                {if $p_size_options==1} checked {/if}></td>
+                        <td>{t}Fill all space up to{/t} 
+                            <input {if $p_size_options != 1} disabled {/if}
+                                    id="size_max_value"
+                                    type="text" value="{$p_size_max_value}">&nbsp;{t}MB{/t}
+                        </td>
+                    </tr>
+                </table>
             </td>
         </tr>
-        <tr>
-            <td>{t}Size{/t}</td>
-            <td>
-                <input name="p_size" value="{$p_size}">
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Force to be primary partition{/t}</td>
-            <td><input type="checkbox" name="p_forcePrimary" {if $p_forcePrimary_selected} checked {/if}></td>
-        </tr>
-        <tr>
-            <td>{t}Encrypt{/t}</td>
-            <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
-        </tr>
     </table>
-
-    <hr>
-
-    <h3>{t}Additional size options{/t}</h3>
+{elseif $selected_type==0}
+    <h3>{t}Add disk{/t}</h3>
     <table>
         <tr>
-            <td><input type="radio" name="p_size_options" value="0" 
-                    onClick="document.mainform.submit();"
-                    {if $p_size_options==0} checked {/if}></td>
-            <td>{t}Fixed size{/t}</td>
-        </tr>
-        <tr>
-            <td><input type="radio" name="p_size_options" value="1" 
-                    onClick="document.mainform.submit();"
-                    {if $p_size_options==1} checked {/if}></td>
-            <td>{t}Fill all space up to{/t} 
-                <input {if $p_size_options != 1} disabled {/if}
-                        id="size_max_value"
-                        type="text" value="{$p_size_max_value}">&nbsp;{t}MB{/t}
+            <td>{t}Disk name{/t}</td>
+            <td>
+                <input type="text" name="d_name" value="{$d_name}">
             </td>
         </tr>
-        <tr>
-            <td><input type="radio" name="p_size_options" value="2" 
-                    onClick="document.mainform.submit();"
-                    {if $p_size_options==2} checked {/if}></td>
-            <td>{t}Fill to maximum allowable size{/t}</td>
-        </tr>
     </table>
 {/if}
 
index 95a324466f8fb161e5274ec441cfbcd8e2304be1..ce55f3564aed1b8647f599bd4f0ca6249ff0d80a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 
+define('DISK' , 0);
 define('PARTITION' , 1);
 define('RAID_DEVICE' , 2);
 define('VOLUME_GROUP' , 3);
@@ -12,7 +13,10 @@ class AddPartitionDialog
     public $disk = array();
     public $diskList = array();
     public $paritions = array();
-    public $selected_type = PARTITION;
+    public $selected_type = DISK;
+
+    // Disk properties
+    public $d_name = "";
 
     // LVM Volume group properties
     public $vg_name = "";
@@ -70,6 +74,9 @@ class AddPartitionDialog
     public $v_attributes = array("v_name", "v_group", "v_mountPoint", "v_fsType", 
             "v_size", "v_encrypt", "v_fsOptions");
 
+    // Disk  attributes
+    public $d_attributes = array("d_name");
+
     /*! \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.
@@ -111,6 +118,11 @@ class AddPartitionDialog
  
         // Select first disk as default.    
         $this->p_used_disk = key($this->diskList);
+
+        // Preselect partition creation if we've already created a disk 
+        if(count($this->disks)){
+            $this->selected_type = PARTITION;
+        }
     }
     
 
@@ -154,6 +166,10 @@ class AddPartitionDialog
                     $bool_attrs = array("v_encrypt");
                     break;
                 }
+            case DISK: {
+                    $attrs = $this->d_attributes;
+                    break;
+                }
         }
 
         // Assign properties to smarty.
@@ -211,6 +227,10 @@ class AddPartitionDialog
                     $bool_attrs = array("v_encrypt");
                     break;
                 }
+            case DISK: {
+                    $attrs = $this->d_attributes;
+                    break;
+                }
         }
 
         // Get posted string values 
@@ -233,7 +253,14 @@ class AddPartitionDialog
      */
     function save()
     {
-        if($this->selected_type == VOLUME_GROUP){
+        if($this->selected_type == DISK){
+            
+            // Get volume group properties
+            $name = $this->d_name;
+            $this->partitionObject->addDisk($name);
+            return($this->partitionObject->success());
+
+        }elseif($this->selected_type == VOLUME_GROUP){
             
             // Get volume group properties
             $devices = $this->vg_partitions;
@@ -377,7 +404,7 @@ class AddPartitionDialog
             }else{
             
                 // Add normal-physical partition
-                $target = $this->mountPoint;
+                $target = $this->p_mountPoint;
                 if($fsType == "swap"){
                     $target = "swap";
                 }
index b9f67910dddf542ee8816c6bb15976692af1f28c..c20cd2776684931ed319ba617e3d163b4da5b924 100644 (file)
@@ -21,18 +21,18 @@ class DevicePartition
         $rpc = $this->config->getRpcHandle();
         $this->object = $rpc->openObject('libinst.preseed.diskdefinition', '');
 
-        $this->object->addDisk('sda');
-        $this->object->addDisk('sdb');
-        $this->object->addDisk('sdc');
-        $this->object->addPartition('/kekse', 2333, NULL, FALSE, TRUE, FALSE, FALSE, 'ext3','ro,user,nosuid' , FALSE, NULL, 'sda');
-        $this->object->addPartition('/wurst', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
-        $this->object->addPartition('raid.00', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
-        $this->object->addPartition('raid.01', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
-        $this->object->addPartition('pv.00', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
-        $this->object->addPartition('pv.01', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
-        $this->object->addPartition('pv.02', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addDisk('sda');
+        #$this->object->addDisk('sdb');
+        #$this->object->addDisk('sdc');
+        #$this->object->addPartition('/kekse', 2333, NULL, FALSE, TRUE, FALSE, FALSE, 'ext3','ro,user,nosuid' , FALSE, NULL, 'sda');
+        #$this->object->addPartition('/wurst', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addPartition('raid.00', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addPartition('raid.01', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addPartition('pv.00', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addPartition('pv.01', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+        #$this->object->addPartition('pv.02', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
         #$this->object->addRaidDevice('pv.01', 'md0', '0','0', NULL, NULL, TRUE, FALSE, array('raid.00', 'raid.01'));
-        $this->object->addVolumeGroup('garnele', array('pv.00', 'pv.01'));
+        #$this->object->addVolumeGroup('garnele', array('pv.00', 'pv.01'));
         #$this->object->addVolume('/home', 'garnele_home', 'garnele', 2000);
 
         // Prepare lists