]> git.datanom.net - omvzfs.git/commitdiff
Added function to get ZFS UUID by pool name
authorNiclas Berglind <nb@kjam.se>
Fri, 16 May 2014 20:02:05 +0000 (22:02 +0200)
committerMichael Rasmussen <mir@datanom.net>
Wed, 21 May 2014 21:49:42 +0000 (23:49 +0200)
Signed-off-by: Niclas Berglind <nb@kjam.se>
src/Utils.php

index 86d9205837c0c4e1c58ff223d18f1822369c6f69..13c89ed5ddbbc096139acd84220b5354b796bf63 100644 (file)
@@ -8,6 +8,25 @@ require_once("Dataset.php");
  */
 class OMVModuleZFSUtil {
 
+       /**
+        * Get UUID of ZFS pool by name
+        *
+        * @return string UUID of the pool
+        */
+       public static function getUUIDbyName($name) {
+               preg_match('/^([A-Za-z0-9]+)\/?.*$/', $name, $result);
+               $name = $result[1];
+               unset($result);
+               $cmd = "blkid -o full";
+               OMVModuleZFSUtil::exec($cmd, $out, $res);
+               foreach($out as $line) {
+                       if(preg_match('/^.*LABEL=\"' . $name . '\" UUID=\"([A-Za-z0-9]+)\".*TYPE=\"zfs_member\"$/', $line, $result)) {
+                               return($result[1]);
+                       }
+               }
+               return null;
+       }
+
        /**
         * Get an array with all ZFS objects
         *
@@ -26,7 +45,7 @@ class OMVModuleZFSUtil {
                        $subdirs = preg_split('/\//',$path);
                        $root = $subdirs[0];
                        $tmp = array();
-                       
+
                        switch ($type) {
                        case "filesystem":
                                if (strpos($path,'/') === false) {
This page took 0.031622 seconds and 5 git commands to generate.