]> git.datanom.net - omvzfs.git/blobdiff - src/Utils.php
Fix parted command to run in scripted mode.
[omvzfs.git] / src / Utils.php
index 3c3f8069cc291bcb83a56306eed5d1d66a7c9036..43a83b1c86828e54329f27cd66be24c4d44ee881 100644 (file)
@@ -11,6 +11,16 @@ require_once("Zpool.php");
  */
 class OMVModuleZFSUtil {
 
+       /**
+        * Sets a GPT label on a disk to prevent the zpool command from generating
+        * errors.
+        *
+        */
+       public static function setGPTLabel($disk) {
+               $cmd = "parted -s " . $disk . " mklabel gpt 2>&1";
+               OMVModuleZFSUtil::exec($cmd,$out,$res);
+       }
+
        /**
         * Manages relocation of ZFS filesystem mountpoints in the OMV backend.
         * Needed when the user changes mountpoint of a filesystem in the GUI.
@@ -226,31 +236,11 @@ class OMVModuleZFSUtil {
                                                'expanded'=>$expanded,
                                                'path'=>$path);
                                        $pool = new OMVModuleZFSZpool($path);
+                                       $tmp['origin'] = "n/a";
                                        $tmp['size'] = $pool->getSize();
                                        $tmp['used'] = $pool->getAttribute("allocated");
                                        $tmp['available'] = $pool->getAttribute("free");
                                        $tmp['mountpoint'] = $pool->getMountPoint();
-                                       $vdevs = $pool->getVdevs();
-                                       $vdev_type = $vdevs[0]->getType();
-                                       switch ($vdev_type) {
-                                       case OMVModuleZFSVdevType::OMVMODULEZFSMIRROR:
-                                               $pool_type = "Mirror";
-                                               break;
-                                       case OMVModuleZFSVdevType::OMVMODULEZFSPLAIN:
-                                               $pool_type = "Basic";
-                                               break;
-                                       case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1:
-                                               $pool_type = "Raidz1";
-                                               break;
-                                       case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2:
-                                               $pool_type = "Raidz2";
-                                               break;
-                                       case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3:
-                                               $pool_type = "Raidz3";
-                                               break;
-                                       }
-                                       $tmp['pool_type'] = $pool_type;
-                                       $tmp['nr_disks'] = count($vdevs[0]->getDisks());
                                        array_push($objects,$tmp);
                                } else {
                                        //This is a Filesystem
@@ -264,20 +254,18 @@ class OMVModuleZFSUtil {
                                        $ds =  new OMVModuleZFSDataset($path);
                                        if ($ds->isClone()) {
                                                //This is a cloned Filesystem
-                                               $tmp['type'] = "Clone";
                                                $tmp['origin'] = $ds->getOrigin();
                                        } else {
                                                //This is a standard Filesystem.
-                                               $tmp['type']= ucfirst($type);
+                                               $tmp['origin'] = "n/a";
                                        }
+                                       $tmp['type']= ucfirst($type);
                                        $tmp['size'] = "n/a";
                                        $used = $ds->getProperty("used");
                                        $tmp['used'] = $used['value'];
                                        $available = $ds->getProperty("available");
                                        $tmp['available'] = $available['value'];
                                        $tmp['mountpoint'] = $ds->getMountPoint();
-                                       $tmp['pool_type'] = "n/a";
-                                       $tmp['nr_disks'] = "n/a";
                                        array_push($objects,$tmp);
                                }
                                break;
@@ -291,13 +279,19 @@ class OMVModuleZFSUtil {
                                        'icon'=>"images/save.png",
                                        'path'=>$path,
                                        'expanded'=>$expanded);
-                               $vol = new OMVModuleZFSZvol();
+                               $vol = new OMVModuleZFSZvol($path);
+                               if ($vol->isClone()) {
+                                       //This is a cloned Volume
+                                       $tmp['origin'] = $vol->getOrigin();
+                               } else {
+                                       //This is a standard Volume
+                                       $tmp['origin'] = "n/a";
+                               }
+                               $tmp['type']= ucfirst($type);
                                $tmp['size'] = $vol->getSize();
                                $tmp['used'] = "n/a";
                                $tmp['available'] = "n/a";
                                $tmp['mountpoint'] = "n/a";
-                               $tmp['pool_type'] = "n/a";
-                               $tmp['nr_disks'] = "n/a";
                                array_push($objects,$tmp);
                                break;
 
@@ -312,12 +306,11 @@ class OMVModuleZFSUtil {
                                        'icon'=>'images/zfs_snap.png',
                                        'path'=>$path,
                                        'expanded'=>$expanded);
+                               $tmp['origin'] = "n/a";
                                $tmp['size'] = "n/a";
                                $tmp['used'] = "n/a";
                                $tmp['available'] = "n/a";
                                $tmp['mountpoint'] = "n/a";
-                               $tmp['pool_type'] = "n/a";
-                               $tmp['nr_disks'] = "n/a";
                                array_push($objects,$tmp);
                                break;
 
This page took 0.034147 seconds and 5 git commands to generate.