]> git.datanom.net - omvzfs.git/commitdiff
Added snapshots to Dataset class.
authorNiclas Berglind <nb@kjam.se>
Sat, 22 Mar 2014 13:14:31 +0000 (14:14 +0100)
committerMichael Rasmussen <mir@datanom.net>
Tue, 25 Mar 2014 00:05:53 +0000 (01:05 +0100)
Signed-off-by: Niclas Berglind <nb@kjam.se>
src/Dataset.php
src/Snapshot.php

index 8560f7495b25b8445c0b2faa0218505b8d195508..e1611416a73d8fd00102d3f958881eeae2878118 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 require_once("Exception.php");
 require_once("openmediavault/util.inc");
+require_once("Snapshot.php");
 
 /**
  * XXX detailed description
@@ -35,6 +36,14 @@ class OMVModuleZFSDataset {
      */
     private $properties;
 
+       /**
+        * Array with Snapshots associated to the Dataset
+        *
+        * @var         array $snapshots
+        * @access private
+        */
+       private $snapshots;
+
        // Associations
        // Operations
 
@@ -58,6 +67,14 @@ class OMVModuleZFSDataset {
                                continue;
                        }
                }
+               $qname = preg_quote($name . "@", '/');
+               $cmd = "zfs list -H -t snapshot";
+               $this->exec($cmd, $out, $res);
+               foreach ($out as $line) {
+                       if (preg_match('/^(' . $qname . '[^\s]+)\t.*$/', $line, $res)) {
+                               $this->snapshots[] = new OMVModuleZFSSnapshot($res[1]);
+                       }
+               }
        }
 
        /**
@@ -80,6 +97,16 @@ class OMVModuleZFSDataset {
                return $this->mountPoint;
        }
 
+       /**
+        * Get all Snapshots associated with the Dataset
+        *
+        * @return array $snapshots
+        * @access public
+        */
+       public function getSnapshots() {
+               return $this->snapshots;
+       }
+
        /**
         * Get a single property value associated with the Dataset
         *
index 6e3269863a1405a78be9c6a9356e8ff8853679e0..54411e283daf31adc6c015d1a5ddf82d11bb7c51 100644 (file)
@@ -45,7 +45,6 @@ class OMVModuleZFSSnapshot {
                $this->exec($cmd, $out, $res);
                foreach ($out as $line) {
                        if (preg_match('/^' . $qname . '\t.*$/', $line)) {
-                               print("Name found!!!\n");
                                $this->updateAllProperties();
                                continue;
                        }
This page took 0.034585 seconds and 5 git commands to generate.