]> git.datanom.net - omvzfs.git/blobdiff - gui/rpc/zfs.inc
Made it optional to use /dev/disk/by-path
[omvzfs.git] / gui / rpc / zfs.inc
index bbab27ca3824b961d5dc8136ab5cc2406dd5e62a..881372aebb6fbbe1578c3cee7dbb08a65db79a17 100644 (file)
@@ -45,7 +45,8 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                                  "force":{"type":"boolean"},
                                  "mountpoint":{"type":"string"},
                                  "name":{"type":"string"},
-                                 "devices":{"type":"string"}
+                                 "devices":{"type":"string"},
+                                 "diskpath":{"type":"boolean"}
                          }
                  }');
                switch ($params['pooltype']) {
@@ -77,14 +78,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        $opts .= "-m " . $params['mountpoint'] . " ";
                }
 
-               //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);
+               //Use /dev/disk/by-path as suggested in ZoL FAQ.
+               if ($params['diskpath']) {
+                       if (file_exists("/dev/disk/by-path/")) {
+                               $tmp_disks = array();
+                               foreach ($disks as $disk) {
+                                       $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk);
+                               }
+                               $disks = $tmp_disks;
                        }
-                       $disks = $tmp_disks;
                }
 
                $vdev = new OMVModuleZFSVdev($params['name'], $pooltype, $disks);
@@ -130,7 +133,8 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                                  "path":{"type":"string"},
                                  "name":{"type":"string"},
                                  "size":{"type":"string"},
-                                 "clonename":{"type":"string"}
+                                 "clonename":{"type":"string"},
+                                 "mountpoint":{"type":"string"}
                          }
                  }');
                switch ($params['type']) {
@@ -141,6 +145,10 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                case "filesystem":
                        $name = $params['path'] . "/" . $params['name'];
                        $tmp = new OMVModuleZFSDataset($name);
+                       if (strlen($params['mountpoint']) > 0) {
+                               $properties = array("mountpoint"=>$params['mountpoint']);
+                               $tmp->setProperties($properties);
+                       }
                        break;
                case "snapshot":
                        $name = $params['path'] . "@" . $params['name'];
@@ -511,8 +519,18 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        $cmd = "zfs get all {$params['name']}";
                        break;
                case "Pool":
-                       $output .= "Pool details (zpool get all):\n\r\n\r";
+                       $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");
@@ -532,7 +550,8 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                                        '"raidz1","raidz2","raidz3"]},
                                  "name":{"type":"string"},
                                  "devices":{"type":"string"},
-                                 "force":{"type":"boolean"}
+                                 "force":{"type":"boolean"},
+                                 "diskpath":{"type":"boolean"}
                          }
                }');
                $pool = new OMVModuleZFSZpool($params['name']);
@@ -559,14 +578,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                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);
+               //Use /dev/disk/by-path as suggested in ZoL FAQ.
+               if ($params['diskpath']) {
+                       if (file_exists("/dev/disk/by-path/")) {
+                               $tmp_disks = array();
+                               foreach ($disks as $disk) {
+                                       $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk);
+                               }
+                               $disks = $tmp_disks;
                        }
-                       $disks = $tmp_disks;
                }
                $vdev[] = new OMVModuleZFSVdev($params['name'], $pooltype, $disks);
                $pool->addVdev($vdev, $opts);
This page took 0.033099 seconds and 5 git commands to generate.