Code

Added error handling to Partition plugins
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 13 May 2011 13:46:17 +0000 (13:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 13 May 2011 13:46:17 +0000 (13:46 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20824 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 225239f66f03bdf2261a38ad92402252ba102c53..8a4f7f3743fbf0bbc849b204a02f27688613e290 100644 (file)
+{if $error}
 
-<h3>{t}Type{/t}</h3>
+    <p>
+    {$errorMsg}
+    </p>
+    <button type='submit' name='retry'>{t}Retry{/t}</button>
 
-<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) < 1} disabled {/if}
-        {if $selected_type==2} checked {/if} onClick="document.mainform.submit();"
-        type="radio" value="2" name="selected_type">{t}Raid device{/t}<br>
-<input  {if !count($freeLvmPartitions)} disabled {/if}
-        {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>
+    <div class="clear"></div>
 
-<hr>
+    <div class="plugin-actions">
+      <button type='submit' name='cancel_partition_add'>{msgPool type=cancelButton}</button>
+    </div>
 
-{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">
-                    {foreach from=$volumeGroupList item=item}
-                        <option value="{$item}"
-                            {if $item==$v_group} selected {/if}
-                            >{$item} {if isset($deviceUsage.vg[$item])} - ({$deviceUsage.vg[$item].size - $deviceUsage.vg[$item].usage} {t}MB{/t} {t}free{/t}){/if}</option>
-                    {/foreach}
-                </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>
+{else}
+
+    <h3>{t}Type{/t}</h3>
 
-{elseif $selected_type==3}
-    
-    <h3>{t}LVM Volume group{/t}</h3>
-    <table>
-        <tr>
-            <td>{t}Volume group name{/t}</td>
-            <td>
-                <input type="text" name="vg_name" value="{$vg_name}">
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Use LVM partitions{/t}</td>
-            <td>
-                {foreach from=$freeLvmPartitions item=item key=key}
-                    <input type="checkbox" name="vg_partition_{$key}" 
-                        {if in_array($item, $vg_partitions)} checked {/if}>&nbsp;{$item}
-                        {if isset($deviceUsage.part[$item])} &nbsp;&nbsp; {$deviceUsage.part[$item].size} {t}MB{/t}
-                        {elseif isset($deviceUsage.raid[$item])} &nbsp;&nbsp; {$deviceUsage.raid[$item].size} {t}MB{/t}{/if}    
-                        <br>
-                {/foreach}
-            </td>
-        </tr>
-    </table>
+    <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) < 1} disabled {/if}
+            {if $selected_type==2} checked {/if} onClick="document.mainform.submit();"
+            type="radio" value="2" name="selected_type">{t}Raid device{/t}<br>
+    <input  {if !count($freeLvmPartitions)} disabled {/if}
+            {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>
 
-{elseif $selected_type==2}
-    <h3>{t}Add raid device{/t}</h3>
+    <hr>
 
-    <table>
-        <tr>
-            <td>{t}Mount point{/t}</td>
-            <td>
-                {if $r_fsType == "swap" || $r_fsType == "pv"}
-                    <input disabled type="text" name="r_mountPoint" value=" - ">
-                {else}
-                    <input type="text" name="r_mountPoint" value="{$r_mountPoint}">
-                {/if}
-            </td>
-        </tr>
-        <tr>
-            <td>{t}File system type{/t}</td>
-            <td>
-                <select name="r_fsType" onChange="document.mainform.submit();">
-                    {html_options options=$fsTypes selected=$r_fsType}
-                </select>
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Raid level{/t}</td>
-            <td>
-                <select name="r_raidLevel">
-                    {html_options options=$raidLevelList selected=$r_raidLevel}
-                </select>
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Use raid partitions{/t}</td>
-            <td>
-                {foreach from=$freeRaidPartitions item=item key=key}
-                    <input type="checkbox" name="r_partition_{$key}" 
-                        {if in_array($item, $r_partitions)} checked {/if}>&nbsp;{$item}
-                        {if isset($deviceUsage.part[$item])} &nbsp;&nbsp;{$deviceUsage.part[$item].size} {t}MB{/t}
-                        {elseif isset($deviceUsage.raid[$item])} &nbsp;&nbsp;{$deviceUsage.raid[$item].size} {t}MB{/t}{/if}    
-                        <br>
-                {/foreach}
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Number of spares{/t}</td>
-            <td>
-                <input type="text" value="{$r_spares}" name="r_spares">
-            </td>
-        </tr>
-        <tr>
-            <td>{t}Encrypt{/t}</td>
-            <td><input type="checkbox" name="r_encrypt" {if $r_encrypt_selected} checked {/if}></td>
-        </tr>
-    </table>
+    {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">
+                        {foreach from=$volumeGroupList item=item}
+                            <option value="{$item}"
+                                {if $item==$v_group} selected {/if}
+                                >{$item} {if isset($deviceUsage.vg[$item])} - ({$deviceUsage.vg[$item].size - $deviceUsage.vg[$item].usage} {t}MB{/t} {t}free{/t}){/if}</option>
+                        {/foreach}
+                    </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}
+        
+        <h3>{t}LVM Volume group{/t}</h3>
+        <table>
+            <tr>
+                <td>{t}Volume group name{/t}</td>
+                <td>
+                    <input type="text" name="vg_name" value="{$vg_name}">
+                </td>
+            </tr>
+            <tr>
+                <td>{t}Use LVM partitions{/t}</td>
+                <td>
+                    {foreach from=$freeLvmPartitions item=item key=key}
+                        <input type="checkbox" name="vg_partition_{$key}" 
+                            {if in_array($item, $vg_partitions)} checked {/if}>&nbsp;{$item}
+                            {if isset($deviceUsage.part[$item])} &nbsp;&nbsp; {$deviceUsage.part[$item].size} {t}MB{/t}
+                            {elseif isset($deviceUsage.raid[$item])} &nbsp;&nbsp; {$deviceUsage.raid[$item].size} {t}MB{/t}{/if}    
+                            <br>
+                    {/foreach}
+                </td>
+            </tr>
+        </table>
+
+    {elseif $selected_type==2}
+        <h3>{t}Add raid device{/t}</h3>
+
+        <table>
+            <tr>
+                <td>{t}Mount point{/t}</td>
+                <td>
+                    {if $r_fsType == "swap" || $r_fsType == "pv"}
+                        <input disabled type="text" name="r_mountPoint" value=" - ">
+                    {else}
+                        <input type="text" name="r_mountPoint" value="{$r_mountPoint}">
+                    {/if}
+                </td>
+            </tr>
+            <tr>
+                <td>{t}File system type{/t}</td>
+                <td>
+                    <select name="r_fsType" onChange="document.mainform.submit();">
+                        {html_options options=$fsTypes selected=$r_fsType}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td>{t}Raid level{/t}</td>
+                <td>
+                    <select name="r_raidLevel">
+                        {html_options options=$raidLevelList selected=$r_raidLevel}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td>{t}Use raid partitions{/t}</td>
+                <td>
+                    {foreach from=$freeRaidPartitions item=item key=key}
+                        <input type="checkbox" name="r_partition_{$key}" 
+                            {if in_array($item, $r_partitions)} checked {/if}>&nbsp;{$item}
+                            {if isset($deviceUsage.part[$item])} &nbsp;&nbsp;{$deviceUsage.part[$item].size} {t}MB{/t}
+                            {elseif isset($deviceUsage.raid[$item])} &nbsp;&nbsp;{$deviceUsage.raid[$item].size} {t}MB{/t}{/if}    
+                            <br>
+                    {/foreach}
+                </td>
+            </tr>
+            <tr>
+                <td>{t}Number of spares{/t}</td>
+                <td>
+                    <input type="text" value="{$r_spares}" name="r_spares">
+                </td>
+            </tr>
+            <tr>
+                <td>{t}Encrypt{/t}</td>
+                <td><input type="checkbox" name="r_encrypt" {if $r_encrypt_selected} checked {/if}></td>
+            </tr>
+        </table>
 
-{elseif $selected_type==1}
+    {elseif $selected_type==1}
 
-    <table width="100%">
-        <tr>
-            <td style="width:50%">
-                <h3>{t}Add Partition{/t}</h3>
-                <table>
-                    <tr>
-                        <td>{t}Mount point{/t}</td>
-                        <td>
+        <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" onChange="document.mainform.submit();">
+                                {foreach from=$disks item=disk}
+                                    <option value="{$disk}"
+                                        {if $disk==$p_used_disk} selected {/if}
+                                        >{$disk} {if isset($deviceUsage.disk[$p_used_disk])} - ({$deviceUsage.disk[$p_used_disk].size - $deviceUsage.disk[$p_used_disk].usage} {t}MB{/t} {t}free{/t}){/if}</option>
+                                {/foreach}
+                                </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}Bootable{/t}</td>
+                            <td><input type="checkbox" name="p_bootable" {if $p_bootable_selected} checked {/if}></td>
+                        </tr>
+                        <tr>
+                            <td>{t}Encrypt{/t}</td>
                             {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
-                                <input disabled type="text" name="p_mountPoint" value=" - ">
+                                <td><input disabled type="checkbox" name="p_encrypt"></td>
                             {else}
-                                <input type="text" name="p_mountPoint" value="{$p_mountPoint}">
+                                <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
                             {/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" onChange="document.mainform.submit();">
-                            {foreach from=$disks item=disk}
-                                <option value="{$disk}"
-                                    {if $disk==$p_used_disk} selected {/if}
-                                    >{$disk} {if isset($deviceUsage.disk[$p_used_disk])} - ({$deviceUsage.disk[$p_used_disk].size - $deviceUsage.disk[$p_used_disk].usage} {t}MB{/t} {t}free{/t}){/if}</option>
-                            {/foreach}
-                            </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}Bootable{/t}</td>
-                        <td><input type="checkbox" name="p_bootable" {if $p_bootable_selected} checked {/if}></td>
-                    </tr>
-                    <tr>
-                        <td>{t}Encrypt{/t}</td>
-                        {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
-                            <td><input disabled type="checkbox" name="p_encrypt"></td>
-                        {else}
-                            <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
-                        {/if}
-                    </tr>
-                    <tr>
-                        <td>{t}Format{/t}</td>
-                        {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
-                            <td><input disabled type="checkbox" name="p_format"></td>
-                        {else}
-                            <td><input type="checkbox" name="p_format" {if $p_format_selected} checked {/if}></td>
-                        {/if}
-                    </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>
-    </table>
-{elseif $selected_type==0}
-    <h3>{t}Add disk{/t}</h3>
-    <table>
-        <tr>
-            <td>{t}Disk name{/t}</td>
-            <td>
-                <input type="text" name="d_name" value="{$d_name}">
-            </td>
-        </tr>
-    </table>
-{/if}
+                        </tr>
+                        <tr>
+                            <td>{t}Format{/t}</td>
+                            {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
+                                <td><input disabled type="checkbox" name="p_format"></td>
+                            {else}
+                                <td><input type="checkbox" name="p_format" {if $p_format_selected} checked {/if}></td>
+                            {/if}
+                        </tr>
+                    </table>
+                </td>
+                <td class="left-border"></td>
+                <td>
 
-<hr>
-<div class="clear"></div>
+                    <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>
+        </table>
+    {elseif $selected_type==0}
+        <h3>{t}Add disk{/t}</h3>
+        <table>
+            <tr>
+                <td>{t}Disk name{/t}</td>
+                <td>
+                    <input type="text" name="d_name" value="{$d_name}">
+                </td>
+            </tr>
+        </table>
+    {/if}
 
-<div class="plugin-actions">
-  <button type='submit' name='save_partition_add'>{msgPool type=addButton}</button>
-  <button type='submit' name='cancel_partition_add'>{msgPool type=cancelButton}</button>
-</div>
+    <hr>
+    <div class="clear"></div>
 
+    <div class="plugin-actions">
+      <button type='submit' name='save_partition_add'>{msgPool type=addButton}</button>
+      <button type='submit' name='cancel_partition_add'>{msgPool type=cancelButton}</button>
+    </div>
 
+{/if}
index c79aea9548f76c4bd97031add8350de127f749a4..6f1658178f6bfceb91475ffc995bbbc899e087ac 100644 (file)
@@ -14,6 +14,7 @@ class AddPartitionDialog
     public $diskList = array();
     public $paritions = array();
     public $selected_type = DISK;
+    public $errorMsg;
 
     // Disk properties
     public $d_name = "";
@@ -79,6 +80,8 @@ class AddPartitionDialog
     // Disk  attributes
     public $d_attributes = array("d_name");
 
+    public $initialized = FALSE;
+
     /*! \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.
@@ -88,31 +91,49 @@ class AddPartitionDialog
     {
         $this->partitionObject = &$partitionObject;
         $this->config = &$config;
+    }
+
+    function init()
+    {
+        // Load remote partition information
+        $map = array(
+                "fsTypes" => "getFsTypes",
+                "raidLevel" => "getRaidLevels",
+                "disks" => "getDisks",
+                "partitions" => "getPartitions",
+                "raidDevices" => "getRaidDevices",
+                "volumeGroups" => "getVolumeGroups",
+                "freeLvmPartitions" => "getUnassignedPhysicalVolumes",
+                "freeRaidPartitions" => "getUnassignedRaidPartitions");
+        foreach($map as $target => $func){
+            $this->$target = @$this->partitionObject->$func('causes an error');
+            if(!$this->partitionObject->success()){
+                $this->errorMsg = $this->partitionObject->getError();
+                return;
+            }
+        }
 
-        // Prepare filesystem types
-        $this->fsTypes = array();
+        // Prepare list of filesystem types
+        $this->fsTypeList = array();
         foreach($this->partitionObject->getFsTypes() as $type){
-            $this->fsTypes[$type] = $type;
+            $this->fsTypeList[$type] = $type;
         }
-        $this->fsTypes['pv'] = _('Physical volume (LVM)');
-        $this->fsTypes['raid'] = _('Software raid');
+        $this->fsTypeList['pv'] = _('Physical volume (LVM)');
+        $this->fsTypeList['raid'] = _('Software raid');
 
         // Prepare list of available raid level
         $this->raidLevelList = array();
-        foreach($this->partitionObject->getRaidLevels() as $lvl){
+        foreach($this->raidLevel as $lvl){
             $this->raidLevelList[$lvl] = sprintf(_("Raid %s"), $lvl);
         }
 
-        // Load values from backend
-        $this->disks = $this->partitionObject->getDisks();
-        $this->partitions = $this->partitionObject->getPartitions();
-        $this->raidDevices = $this->partitionObject->getRaidDevices();
-        $this->volumeGroups = $this->partitionObject->getVolumeGroups();
-        $this->freeLvmPartitions = $this->partitionObject->getUnassignedPhysicalVolumes();
-        $this->freeRaidPartitions = $this->partitionObject->getUnassignedRaidPartitions();
+        // Prepare list of volume groups
+        $this->volumeGroups = array();
         foreach($this->volumeGroups as $vg){
             $this->volumeGroupList[$vg['name']] = $vg['name'];
         }
+
+        // Prepare list of disks
         $this->diskList = array();
         foreach($this->disks as $disk){
             $this->diskList[$disk['device']] = $disk['device'];
@@ -125,6 +146,8 @@ class AddPartitionDialog
         if(count($this->disks)){
             $this->selected_type = PARTITION;
         }
+
+        $this->initialized = TRUE;
     }
     
 
@@ -134,6 +157,15 @@ class AddPartitionDialog
     function execute()
     {
         $smarty = get_smarty();
+
+        if(!$this->initialized){
+            $this->init();
+            if(!$this->initialized){
+                $smarty->assign("error", TRUE);        
+                $smarty->assign("errorMsg", $this->errorMsg);
+                return($smarty->fetch(get_template_path("goto/Device/AddPartitionDialog.tpl", TRUE)));
+            }
+        }
        
         // Assign base attributes 
         foreach($this->attributes as $attr){
@@ -141,7 +173,7 @@ class AddPartitionDialog
         }
 
         // Assign partition attributes.
-        $fsTypes = $this->fsTypes;
+        $fsTypes = $this->fsTypeList;
         $attrs = $bool_attrs = array();
         switch($this->selected_type){
             case PARTITION: {
@@ -189,6 +221,7 @@ class AddPartitionDialog
         $smarty->assign('disks', $this->diskList);
         $smarty->assign('volumeGroupList', $this->volumeGroupList);
         $smarty->assign('freeLvmPartitions', $this->freeLvmPartitions);
+        $smarty->assign("error", FALSE);
         return($smarty->fetch(get_template_path("goto/Device/AddPartitionDialog.tpl", TRUE)));
     }
 
@@ -261,7 +294,7 @@ class AddPartitionDialog
             
             // Get volume group properties
             $name = $this->d_name;
-            $this->partitionObject->addDisk($name);
+            @$this->partitionObject->addDisk($name);
 
             // Display potential errors
             if(!$this->partitionObject->success()){
@@ -275,7 +308,7 @@ class AddPartitionDialog
             // Get volume group properties
             $devices = $this->vg_partitions;
             $name = $this->vg_name;
-            $this->partitionObject->addVolumeGroup($name, $devices, $format=TRUE, $use_existing=FALSE, NULL);
+            @$this->partitionObject->addVolumeGroup($name, $devices, $format=TRUE, $use_existing=FALSE, NULL);
 
             // Display potential errors
             if(!$this->partitionObject->success()){
@@ -304,7 +337,7 @@ class AddPartitionDialog
                 $target = "swap";
             }
       
-            $this->partitionObject->addVolume($target, $name, $group, $size, $maxSize,
+            @$this->partitionObject->addVolume($target, $name, $group, $size, $maxSize,
                 $grow, $format, $use_existing, $fsType, $fsOptions);
 
             // Display potential errors
@@ -319,7 +352,7 @@ class AddPartitionDialog
             // Get raid device properties
             $devices = $this->r_partitions;
             $fsType = $this->r_fsType;
-            $raidLevel = $this->r_raidLevel;
+            $raidLevel = intval($this->r_raidLevel);
             $spares = $this->r_spares;
             $encrypt = $this->r_encrypt;
 
@@ -347,7 +380,7 @@ class AddPartitionDialog
                 $target = "swap";
             }
        
-            $this->partitionObject->addRaidDevice($target, $name, $raidLevel, $spares, $fsType,$fsOptions, 
+            @$this->partitionObject->addRaidDevice($target, $name, $raidLevel, $spares, $fsType,$fsOptions, 
                 TRUE, FALSE, $devices);
 
             // Display potential errors
@@ -409,7 +442,7 @@ class AddPartitionDialog
             }
 
             // Add partition to remote model
-            $this->partitionObject->addPartition($target,$size, $maxSize, $grow, $format, $boot, $primary,
+            @$this->partitionObject->addPartition($target,$size, $maxSize, $grow, $format, $boot, $primary,
                     $fsType, $fsOptions , $encrypt, $passphrase, $disk);
 
             // Display potential errors
index e87758df0403ef5b191fe09b4ac95080dea420e4..7e52149c119b31239d9a4f9fd8e84efbee7bf4c8 100644 (file)
@@ -159,7 +159,7 @@ class DevicePartition
     
             // Add raids
             foreach($raids as $id =>  $raid){
-                $str = "{$seps[1]}{$raidImg}&nbsp;{$raid['name']} ({$raid['level']})";
+                $str = "{$seps[1]}{$raidImg}&nbsp;{$raid['name']} ("._("Raid")."{$raid['level']})";
                 $delImg = image('images/lists/trash.png', "delete_raid_{$id}", _("Remove raid device"));
 
                 $devsStr = "";