From 47e63d33372ed4f7924466ba066fc2a42e1b7c41 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Fri, 10 Oct 2014 20:02:42 +0200 Subject: [PATCH] Made it possible to force create Vdevs. Signed-off-by: Niclas Berglind --- gui/js/omv/module/admin/storage/zfs/Overview.js | 11 +++++++++++ gui/rpc/zfs.inc | 8 ++++++-- src/Zpool.php | 6 +++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gui/js/omv/module/admin/storage/zfs/Overview.js b/gui/js/omv/module/admin/storage/zfs/Overview.js index 07f86af..4731124 100644 --- a/gui/js/omv/module/admin/storage/zfs/Overview.js +++ b/gui/js/omv/module/admin/storage/zfs/Overview.js @@ -95,6 +95,7 @@ Ext.define("OMV.module.admin.storage.zfs.AddPool", { break; case "raidz2": devicesField.minSelections = 4; + break; case "raidz3": devicesField.minSelections = 5; break; @@ -342,6 +343,7 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { break; case "raidz2": devicesField.minSelections = 4; + break; case "raidz3": devicesField.minSelections = 5; break; @@ -415,6 +417,15 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { flex: 1 }] } + },{ + xtype: "checkbox", + name: "force", + fieldLabel: _("Force creation"), + checked: false, + plugins: [{ + ptype: "fieldinfo", + text: _("Forces the creation of the Vdev even if errors are reported. Use with extreme caution!") + }] }]; } }); diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index e72038e..fda53b0 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -536,7 +536,8 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { "vdevtype":{"type":"string","enum":["basic","mirror",' . '"raidz1","raidz2","raidz3"]}, "name":{"type":"string"}, - "devices":{"type":"string"} + "devices":{"type":"string"}, + "force":{"type":"boolean"} } }'); $pool = new OMVModuleZFSZpool($params['name']); @@ -560,6 +561,9 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { throw new OMVModuleZFSException("Incorrect pool type specified"); break; } + if ($params['force']) { + $opts .= "-f "; + } //Use /dev/disk/by-path as deafult when creating new pools as suggested in ZoL FAQ. $disks = preg_split("/[,;]/", $params['devices']); if (file_exists("/dev/disk/by-path/")) { @@ -570,7 +574,7 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $disks = $tmp_disks; } $vdev[] = new OMVModuleZFSVdev($params['name'], $pooltype, $disks); - $pool->addVdev($vdev); + $pool->addVdev($vdev, $opts); //Ugly fix to solve the problem of blkid not displaying info on newly created pools $pool->export(); $pool->import($pool->getName()); diff --git a/src/Zpool.php b/src/Zpool.php index 87e5f0c..56ec8c6 100644 --- a/src/Zpool.php +++ b/src/Zpool.php @@ -192,11 +192,11 @@ class OMVModuleZFSZpool extends OMVModuleAbstract { * @throws OMVModuleZFSException * @access public */ - public function addVdev(array $vdevs) { - $cmd = "zpool add " . $this->name . " " . $this->getCommandString($vdevs); + public function addVdev(array $vdevs, $opts= "") { + $cmd = "zpool add " . $this->name . " " . $opts . $this->getCommandString($vdevs) . " 2>&1"; OMVUtil::exec($cmd, $output, $result); if ($result) - throw new OMVModuleZFSException($output); + throw new OMVModuleZFSException(implode("\n", $output)); else $this->vdevs = array_merge($this->vdevs, $vdevs); $this->size = $this->getAttribute("size"); -- 2.39.2