+ public function getObjectDetails($params, $context) {
+ $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+ // Validate the parameters of the RPC service method.
+ $this->validateMethodParams($params, '{
+ "type":"object",
+ "properties":{
+ "name":{"type":"string"},
+ "type":{"type":"string"}
+ }
+ }');
+ $output = "";
+ switch ($params['type']) {
+ case "Filesystem":
+ $output .= "Filesystem details (zfs get all):\n\r\n\r";
+ $cmd = "zfs get all {$params['name']}";
+ break;
+ case "Volume":
+ $output .= "Volume details (zfs get all):\n\r\n\r";
+ $cmd = "zfs get all {$params['name']}";
+ break;
+ case "Snapshot":
+ $output .= "Snapshot details (zfs get all):\n\r\n\r";
+ $cmd = "zfs get all {$params['name']}";
+ break;
+ case "Pool":
+ $output .= "Pool status (zpool status):\n\r\n\r";
+ $cmd = "zpool status {$params['name']}";
+ OMVModuleZFSUtil::exec($cmd,$out,$res);
+ $output .= implode("\n\r", $out);
+ unset($out);
+ $output .= "\n\r\n\rPool details (zpool get all):\n\r\n\r";
+ $cmd = "zpool get all {$params['name']}";
+ OMVModuleZFSUtil::exec($cmd,$out,$res);
+ $output .= implode("\n\r", $out);
+ unset($out);
+ $output .= "\n\r\n\rPool filesystem details (zfs get all):\n\r\n\r";
+ $cmd = "zfs get all {$params['name']}";
+ break;
+ default:
+ throw new OMVModuleZFSException("Incorrect type provided");
+ }
+ OMVModuleZFSUtil::exec($cmd,$out,$res);
+ $output .= implode("\n\r", $out);
+ return array("details" => $output);
+ }
+
+ public function expandPool($params, $context) {
+ $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+ // Validate the parameters of the RPC service method.
+ $this->validateMethodParams($params, '{
+ "type":"object",
+ "properties":{
+ "vdevtype":{"type":"string","enum":["basic","mirror",' .
+ '"raidz1","raidz2","raidz3"]},
+ "name":{"type":"string"},
+ "devices":{"type":"string"},
+ "force":{"type":"boolean"}
+ }
+ }');
+ $pool = new OMVModuleZFSZpool($params['name']);
+ switch ($params['vdevtype']) {
+ case "basic":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSPLAIN;
+ break;
+ case "mirror":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSMIRROR;
+ break;
+ case "raidz1":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1;
+ break;
+ case "raidz2":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2;
+ break;
+ case "raidz3":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3;
+ break;
+ default:
+ 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/")) {
+ $tmp_disks = array();
+ foreach ($disks as $disk) {
+ $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk);
+ }
+ $disks = $tmp_disks;
+ }
+ $vdev[] = new OMVModuleZFSVdev($params['name'], $pooltype, $disks);
+ $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());
+ }