]> 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 e72038ec1f2a16ab16a3f22587a9a272e26ac2ba..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);
@@ -126,16 +129,26 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                          "type":"object",
                          "properties":{
                                  "type":{"type":"string","enum":["filesystem","snapshot",' .
-                                       '"volume"]},
+                                       '"volume","clone"]},
                                  "path":{"type":"string"},
                                  "name":{"type":"string"},
-                                 "size":{"type":"string"}
+                                 "size":{"type":"string"},
+                                 "clonename":{"type":"string"},
+                                 "mountpoint":{"type":"string"}
                          }
                  }');
                switch ($params['type']) {
+               case "clone":
+                       $tmp = new OMVModuleZFSSnapshot($params['path']);
+                       $tmp->clonesnap($params['clonename']);
+                       break;
                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'];
@@ -159,7 +172,7 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                          "type":"object",
                          "properties":{
                                  "type":{"type":"string","enum":["Filesystem","Snapshot",' .
-                                       '"Volume","Clone","Pool"]},
+                                       '"Volume","Pool"]},
                                  "name":{"type":"string"}
                          }
                  }');
@@ -171,10 +184,6 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        $tmp = new OMVModuleZFSDataset($name);
                        $tmp->destroy();
                        break;
-               case "Clone":
-                       $tmp = new OMVModuleZFSDataset($name);
-                       $tmp->destroy();
-                       break;
                case "Snapshot":
                        $tmp = new OMVModuleZFSSnapshot($name);
                        $tmp->destroy();
@@ -217,7 +226,6 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                $name = $params['name'];
                switch ($params['type']) {
                case "Filesystem":
-               case "Clone":
                        $tmp = new OMVModuleZFSDataset($name);
                        break;
                case "Snapshot":
@@ -252,7 +260,7 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        "type":"object",
                                "properties":{
                                        "type":{"type":"string","enum":["Filesystem","Snapshot",' .
-                                               '"Volume","Clone","Pool"]},
+                                               '"Volume","Pool"]},
                                        "name":{"type":"string"},
                                        "properties":{"type":"array","items":{
                                                "type":"object",
@@ -264,7 +272,6 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                global $xmlConfig;
                switch ($params['type']) {
                case "Filesystem":
-               case "Clone":
                        $tmp = new OMVModuleZFSDataset($params['name']);
                        break;
                case "Snapshot":
@@ -298,7 +305,7 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                          "type":"object",
                          "properties":{
                                  "type":{"type":"string","enum":["Filesystem","Snapshot",' .
-                                       '"Volume","Clone","Pool"]},
+                                       '"Volume","Pool"]},
                                  "name":{"type":"string"},
                                  "property":{"type":"string"}
                          }
@@ -316,7 +323,6 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        $this->updateBgProcStatus($bgStatusFilename, "outputfilename", $bgOutputFilename);
                        switch ($params['type']) {
                        case "Filesystem":
-                       case "Clone":
                                $tmp = new OMVModuleZFSDataset($params['name']);
                                break;
                        case "Snapshot":
@@ -368,7 +374,7 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                          "type":"object",
                          "properties":{
                                  "name":{"type":"string"},
-                                 "type":{"type":"string","enum":["Filesystem","Clone"]},
+                                 "type":{"type":"string","enum":["Filesystem"]},
                                  "sharename":{'.$GLOBALS['OMV_JSONSCHEMA_SHARENAME'].'},
                                  "comment":{"type":"string"},
                                  "mode":{"type":"string","enum":["700","750","755",'.
@@ -391,9 +397,6 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                case "Filesystem":
                        $tmp = new OMVModuleZFSDataset($params['name']);
                        break;
-               case "Clone":
-                       $tmp = new OMVModuleZFSDataset($params['name']);
-                       break;
                default:
                        throw new OMVModuleZFSException("Illegal type provided: " . $params['type']);
                        break;
@@ -516,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");
@@ -536,7 +549,9 @@ 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"},
+                                 "diskpath":{"type":"boolean"}
                          }
                }');
                $pool = new OMVModuleZFSZpool($params['name']);
@@ -560,17 +575,22 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        throw new OMVModuleZFSException("Incorrect pool type specified");
                        break;
                }
-               //Use /dev/disk/by-path as deafult when creating new pools as suggested in ZoL FAQ.
+               if ($params['force']) {
+                       $opts .= "-f ";
+               }
                $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);
+               $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());
This page took 0.040474 seconds and 5 git commands to generate.