]>
git.datanom.net - omvzfs.git/blob - src/Dataset.php
2 require_once("Exception.php");
3 require_once("openmediavault/util.inc");
6 * XXX detailed description
12 class OMVModuleZFSDataset
{
22 * Mountpoint of the Dataset
24 * @var string $mountPoint
30 * List of properties assigned to the Dataset
32 * @var array $properties
43 * @param string $name Name of the new Dataset
44 * @param array $properties An array of properties (strings) in the form <key>=<value> to set when creating the Dataset
45 * @throws OMVModuleZFSException
48 public function __construct($name, array $properties = null) {
50 if (isset($properties)) {
51 foreach ($properties as $property) {
52 $cmd .= "-o " . $property . " ";
55 $cmd .= $name . " 2>&1";
56 OMVUtil
::exec($cmd,$out,$res);
58 throw new OMVModuleZFSException(implode("\n", $out));
62 if (isset($properties)) {
63 $this->properties
= $properties;
64 foreach ($properties as $property) {
65 if (preg_match('/^mountpoint\=(.*)$/', $property, $res)) {
66 $this->mountPoint
= $res[1];
71 $this->properties
= array();
72 $this->mountPoint
= "/" . $name;
77 * Return name of the Dataset
79 * @return string $name
82 public function getName() {
87 * Get the mountpoint of the Dataset
89 * @return string $mountPoint
92 public function getMountPoint() {
93 return $this->mountPoint
;
97 * Get an array of properties associated with the Dataset
99 * @return array $properties
102 public function getProperties() {
103 return $this->properties
;
107 * Sets a number of Dataset properties. If a property is already set it will be updated with the new value.
109 * @param array $properties An array of strings in format <key>=<value>
113 public function setProperties($properties) {
114 foreach ($properties as $newproperty) {
115 $cmd = "zfs set " . $newproperty . " " . $this->name
;
116 OMVUtil
::exec($cmd,$out,$res);
118 throw new OMVModuleZFSException(implode("\n", $out));
120 $tmp = explode("=", $newproperty);
121 $newpropertyk = $tmp[0];
123 for ($i=0; $i<count($this->properties
); $i++
) {
124 $tmp = explode("=", $this->properties
[$i]);
125 $oldpropertyk = $tmp[0];
126 if (strcmp($newpropertyk, $oldpropertyk) == 0) {
127 $this->properties
[$i] = $newproperty;
133 array_push($this->properties
, $newproperty);
139 * Destroy the Dataset.
142 public function destroy() {
143 $cmd = "zfs destroy " . $this->name
;
144 OMVUtil
::exec($cmd,$out,$res);
146 throw new OMVModuleZFSException(implode("\n", $out));
This page took 0.140498 seconds and 6 git commands to generate.