From 6e6b3eb901069df5b343b49638c73b050f46b57e Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Wed, 12 Mar 2014 20:46:46 +0100 Subject: [PATCH] Added inherit method together with support method to Zvol class. Signed-off-by: Niclas Berglind --- src/Zvol.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Zvol.php b/src/Zvol.php index c6fd20d..9ace6cf 100644 --- a/src/Zvol.php +++ b/src/Zvol.php @@ -135,6 +135,20 @@ class OMVModuleZFSZvol { } } + /** + * Get single Datset property from commandline and update object property attribute + * + * @param string $property Name of the property to update + * @return void + * @access private + */ + private function updateProperty($property) { + $cmd = "zfs get -H " . $property . " " . $this->name; + $this->exec($cmd,$out,$res); + $tmpary = preg_split('/\t+/', $out[0]); + $this->properties["$tmpary[1]"] = array("value" => $tmpary[2], "source" => $tmpary[3]); + } + /** * Create a Zvol on commandline. Optionally provide a number of properties to set. * @@ -167,6 +181,20 @@ class OMVModuleZFSZvol { $this->exec($cmd,$out,$res); } + /** + * Clears a previously set proporty and specifies that it should be + * inherited from it's parent. + * + * @param string $property Name of the property to inherit. + * @return void + * @access public + */ + public function inherit($property) { + $cmd = "zfs inherit " . $property . " " . $this->name . " 2>&1"; + $this->exec($cmd,$out,$res); + $this->updateProperty($property); + } + /** * Helper function to execute a command and throw an exception on error * (requires stderr redirected to stdout for proper exception message). -- 2.39.2