X-Git-Url: http://git.datanom.net/omvzfs.git/blobdiff_plain/e6fdbbae3c0aeb53b9877ba9983e26a7304c99b0..6e6b3eb901069df5b343b49638c73b050f46b57e:/src/Zvol.php diff --git a/src/Zvol.php b/src/Zvol.php index 496e360..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. * @@ -156,6 +170,31 @@ class OMVModuleZFSZvol { $this->size = $this->properties["volsize"]["value"]; } + /** + * Destroy the Zvol. + * + * @return void + * @access public + */ + public function destroy() { + $cmd = "zfs destroy " . $this->name; + $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).