]> git.datanom.net - omvzfs.git/commitdiff
Made it possible to force create Vdevs.
authorNiclas Berglind <nb@kjam.se>
Fri, 10 Oct 2014 18:02:42 +0000 (20:02 +0200)
committerMichael Rasmussen <mir@datanom.net>
Sat, 11 Oct 2014 22:12:01 +0000 (00:12 +0200)
Signed-off-by: Niclas Berglind <nb@kjam.se>
gui/js/omv/module/admin/storage/zfs/Overview.js
gui/rpc/zfs.inc
src/Zpool.php

index 07f86af59545dae3f9b90cc84155aa50494d66d6..4731124a7016385e636441a1f111fefa79fae95f 100644 (file)
@@ -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!")
+                       }]
                }];
        }
 });
index e72038ec1f2a16ab16a3f22587a9a272e26ac2ba..fda53b0209dcf00f43f6d0e09f35dddce28b35dd 100644 (file)
@@ -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());
index 87e5f0cb4637e88badb4eab36aa32e394e896469..56ec8c64d4426e98d239710d5e3d8b70448c24d5 100644 (file)
@@ -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");
This page took 0.038964 seconds and 5 git commands to generate.