From: Niclas Berglind Date: Sat, 13 Sep 2014 06:35:22 +0000 (+0200) Subject: Support force create pools. X-Git-Url: http://git.datanom.net/omvzfs.git/commitdiff_plain/7d6b772c83ecf6ff975233137172688da26568ab Support force create pools. Signed-off-by: Niclas Berglind --- diff --git a/gui/js/omv/module/admin/storage/zfs/Overview.js b/gui/js/omv/module/admin/storage/zfs/Overview.js index 6c7da08..22f74db 100644 --- a/gui/js/omv/module/admin/storage/zfs/Overview.js +++ b/gui/js/omv/module/admin/storage/zfs/Overview.js @@ -18,7 +18,7 @@ Ext.define("OMV.module.admin.storage.zfs.AddPool", { autoLoadData: false, hideResetButton: true, width: 550, - height: 260, + height: 350, getFormItems: function() { var me = this; @@ -52,22 +52,22 @@ Ext.define("OMV.module.admin.storage.zfs.AddPool", { change: function(combo, value) { var devicesField = this.findField("devices"); switch(value) { - case "basic": - devicesField.minSelections = 1; - break; - case "mirror": - devicesField.minSelections = 2; + case "basic": + devicesField.minSelections = 1; break; - case "raidz1": - devicesField.minSelections = 3; + case "mirror": + devicesField.minSelections = 2; break; - case "raidz2": - devicesField.minSelections = 4; - case "raidz3": - devicesField.minSelections = 5; + case "raidz1": + devicesField.minSelections = 3; break; - default: - devicesField.minSelections = 2; + case "raidz2": + devicesField.minSelections = 4; + case "raidz3": + devicesField.minSelections = 5; + break; + default: + devicesField.minSelections = 2; break; } devicesField.validate(); @@ -136,6 +136,12 @@ Ext.define("OMV.module.admin.storage.zfs.AddPool", { flex: 1 }] } + },{ + xtype: "checkbox", + name: "force", + fieldLabel: _("Force creation"), + checked: false, + boxLabel: _("Forces the creation of the pool even if errors are reported. Use with extreme caution!") }]; }, @@ -595,7 +601,7 @@ Ext.define("OMV.module.admin.storage.zfs.Overview", { me.callParent(arguments); }, - onAddButton: function() { + onAddButton: function() { var me = this; Ext.create("OMV.module.admin.storage.zfs.AddPool", { listeners: { diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index 28902ed..3bc3ec1 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -54,9 +54,14 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { throw new OMVModuleZFSException("Incorrect pool type specified"); break; } + //Check for user supplied options + $opts = ""; + if ($params['force']) { + $opts .= "-f "; + } $disks = preg_split("/[,;]/", $params['devices']); $vdev = new OMVModuleZFSVdev($params['name'], $pooltype, $disks); - $pool = new OMVModuleZFSZpool($vdev); + $pool = new OMVModuleZFSZpool($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 41fd052..0ef1515 100644 --- a/src/Zpool.php +++ b/src/Zpool.php @@ -122,7 +122,7 @@ class OMVModuleZFSZpool extends OMVModuleAbstract { * @throws OMVModuleZFSException */ - public function __construct($vdev) { + public function __construct($vdev, $opts = "") { $create_pool = true; if (is_array($vdev)) { @@ -144,7 +144,7 @@ class OMVModuleZFSZpool extends OMVModuleAbstract { $this->cache = null; $this->features = array(); if ($create_pool) { - $cmd = "zpool create $name $cmd 2>&1"; + $cmd = "zpool create $opts$name $cmd 2>&1"; OMVUtil::exec($cmd, $output, $result); if ($result)