From 77a007e04e6b82eaee3c3f00ba96d8aea97c0c36 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Fri, 10 Oct 2014 20:02:41 +0200 Subject: [PATCH] Fixed expand pool functionality. Signed-off-by: Niclas Berglind --- .../omv/module/admin/storage/zfs/Overview.js | 68 +++++++++++++------ gui/rpc/zfs.inc | 16 ++--- src/Utils.php | 27 -------- 3 files changed, 55 insertions(+), 56 deletions(-) diff --git a/gui/js/omv/module/admin/storage/zfs/Overview.js b/gui/js/omv/module/admin/storage/zfs/Overview.js index 42f6a4f..07f86af 100644 --- a/gui/js/omv/module/admin/storage/zfs/Overview.js +++ b/gui/js/omv/module/admin/storage/zfs/Overview.js @@ -306,29 +306,58 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { readOnly: true, value: me.name },{ - xtype: "textfield", - name: "pool_type", - fieldLabel: _("Pool type"), + xtype: "combo", + name: "vdevtype", + fieldLabel: _("Vdev type"), + queryMode: "local", + store: Ext.create("Ext.data.ArrayStore", { + fields: [ "value", "text" ], + data: [ + [ "basic", _("Basic") ], + [ "mirror", _("Mirror") ], + [ "raidz1", _("RAID-Z1") ], + [ "raidz2", _("RAID-Z2") ], + [ "raidz3", _("RAID-Z3") ] + ] + }), + displayField: "text", + valueField: "value", allowBlank: false, - readOnly: true, - value: me.pool_type + editable: false, + triggerAction: "all", + value: "raidz1", + listeners: { + scope: me, + change: function(combo, value) { + var devicesField = this.findField("devices"); + switch(value) { + case "basic": + devicesField.minSelections = 1; + break; + case "mirror": + devicesField.minSelections = 2; + break; + case "raidz1": + devicesField.minSelections = 3; + break; + case "raidz2": + devicesField.minSelections = 4; + case "raidz3": + devicesField.minSelections = 5; + break; + default: + devicesField.minSelections = 2; + break; + } + devicesField.validate(); + } + } },{ xtype: "checkboxgridfield", name: "devices", fieldLabel: _("Devices"), valueField: "devicefile", - listeners: { - scope: me, - change: function(e, eOpts) { - var deviceField = this.findField("devices"); - if (me.pool_type == "Basic") { - deviceField.minSelections = 1; - } else { - deviceField.minSelections = me.nr_disks; - deviceField.maxSelections = me.nr_disks; - } - } - }, + minSelections: 3, // Min. number of devices for RAIDZ-1 useStringValue: true, height: 130, store: Ext.create("OMV.data.Store", { @@ -357,7 +386,7 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { }), gridConfig: { stateful: true, - stateId: "04942d40-4ee3-11e4-916c-0800200c9a66", + stateId: "05c60750-5074-11e4-916c-0800200c9a66", columns: [{ text: _("Device"), sortable: true, @@ -844,9 +873,6 @@ Ext.define("OMV.module.admin.storage.zfs.Overview", { Ext.create("OMV.module.admin.storage.zfs.ExpandPool", { title: _("Expand Pool"), name: record.get("path"), - type: record.get("type"), - pool_type: record.get("pool_type"), - nr_disks: record.get("nr_disks"), listeners: { scope: me, submit: function() { diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index 75b5c23..e72038e 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -533,27 +533,27 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $this->validateMethodParams($params, '{ "type":"object", "properties":{ - "pool_type":{"type":"string","enum":["Basic","Mirror",' . - '"Raidz1","Raidz2","Raidz3"]}, + "vdevtype":{"type":"string","enum":["basic","mirror",' . + '"raidz1","raidz2","raidz3"]}, "name":{"type":"string"}, "devices":{"type":"string"} } }'); $pool = new OMVModuleZFSZpool($params['name']); - switch ($params['pool_type']) { - case "Basic": + switch ($params['vdevtype']) { + case "basic": $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSPLAIN; break; - case "Mirror": + case "mirror": $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSMIRROR; break; - case "Raidz1": + case "raidz1": $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1; break; - case "Raidz2": + case "raidz2": $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2; break; - case "Raidz3": + case "raidz3": $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3; break; default: diff --git a/src/Utils.php b/src/Utils.php index 3c3f806..58bdc7b 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -230,27 +230,6 @@ class OMVModuleZFSUtil { $tmp['used'] = $pool->getAttribute("allocated"); $tmp['available'] = $pool->getAttribute("free"); $tmp['mountpoint'] = $pool->getMountPoint(); - $vdevs = $pool->getVdevs(); - $vdev_type = $vdevs[0]->getType(); - switch ($vdev_type) { - case OMVModuleZFSVdevType::OMVMODULEZFSMIRROR: - $pool_type = "Mirror"; - break; - case OMVModuleZFSVdevType::OMVMODULEZFSPLAIN: - $pool_type = "Basic"; - break; - case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1: - $pool_type = "Raidz1"; - break; - case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2: - $pool_type = "Raidz2"; - break; - case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3: - $pool_type = "Raidz3"; - break; - } - $tmp['pool_type'] = $pool_type; - $tmp['nr_disks'] = count($vdevs[0]->getDisks()); array_push($objects,$tmp); } else { //This is a Filesystem @@ -276,8 +255,6 @@ class OMVModuleZFSUtil { $available = $ds->getProperty("available"); $tmp['available'] = $available['value']; $tmp['mountpoint'] = $ds->getMountPoint(); - $tmp['pool_type'] = "n/a"; - $tmp['nr_disks'] = "n/a"; array_push($objects,$tmp); } break; @@ -296,8 +273,6 @@ class OMVModuleZFSUtil { $tmp['used'] = "n/a"; $tmp['available'] = "n/a"; $tmp['mountpoint'] = "n/a"; - $tmp['pool_type'] = "n/a"; - $tmp['nr_disks'] = "n/a"; array_push($objects,$tmp); break; @@ -316,8 +291,6 @@ class OMVModuleZFSUtil { $tmp['used'] = "n/a"; $tmp['available'] = "n/a"; $tmp['mountpoint'] = "n/a"; - $tmp['pool_type'] = "n/a"; - $tmp['nr_disks'] = "n/a"; array_push($objects,$tmp); break; -- 2.39.2