]>
git.datanom.net - omvzfs.git/blob - src/Dataset.php
2 require_once("Exception.php");
5 * XXX detailed description
11 class OMVModuleZFSDataset
{
21 * Mountpoint of the Dataset
23 * @var string $mountPoint
29 * List of features assigned to the Dataset
31 * @var array $features
42 * @param string $name Name of the new Dataset
43 * @param array $features An array of features (strings) in the form <key>=<value> to set when creating the Dataset
44 * @throws OMVModuleZFSException
47 public function __construct($name, array $features = null) {
49 if (isset($features)) {
50 foreach ($features as $feature) {
51 $cmd .= "-o " . $feature . " ";
54 $cmd .= $name . " 2>&1";
57 throw new OMVModuleZFSException(implode("\n", $out));
61 if (isset($features)) {
62 $this->features
= $features;
63 foreach ($features as $feature) {
64 if (preg_match('/^mountpoint\=(.*)$/', $feature, $res)) {
65 $this->mountPoint
= $res[1];
70 $this->features
= array();
71 $this->mountPoint
= "/" . $name;
76 * Return name of the Dataset
78 * @return string $name
81 public function getName() {
86 * Get the mountpoint of the Dataset
88 * @return string $mountPoint
91 public function getMountPoint() {
92 return $this->mountPoint
;
96 * Get an array of features associated with the Dataset
98 * @return array $features
101 public function getFeatures() {
102 return $this->features
;
106 * Sets a number of Dataset properties. If a property is already set it will be updated with the new value.
108 * @param array $features An array of strings in format <key>=<value>
112 public function setFeatures($features) {
113 foreach ($features as $newfeature) {
114 $cmd = "zfs set " . $newfeature . " " . $this->name
;
115 exec($cmd,$out,$res);
117 throw new OMVModuleZFSException(implode("\n", $out));
119 $tmp = explode("=", $newfeature);
120 $newfeaturek = $tmp[0];
122 for ($i=0; $i<count($this->features
); $i++
) {
123 $tmp = explode("=", $this->features
[$i]);
124 $oldfeaturek = $tmp[0];
125 if (strcmp($newfeaturek, $oldfeaturek) == 0) {
126 $this->features
[$i] = $newfeature;
132 array_push($this->features
, $newfeature);
138 * Destroy the Dataset.
141 public function destroy() {
142 $cmd = "zfs destroy " . $this->name
;
143 exec($cmd,$out,$res);
145 throw new OMVModuleZFSException(implode("\n", $out));
This page took 0.151705 seconds and 6 git commands to generate.