break;
case "raidz2":
devicesField.minSelections = 4;
+ break;
case "raidz3":
devicesField.minSelections = 5;
break;
break;
case "raidz2":
devicesField.minSelections = 4;
+ break;
case "raidz3":
devicesField.minSelections = 5;
break;
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!")
+ }]
}];
}
});
"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']);
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/")) {
$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());
* @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");