]> git.datanom.net - omvzfs.git/blob - src/Dataset.php
Started implementation of Dataset class
[omvzfs.git] / src / Dataset.php
1 <?php
2 require_once("Exception.php");
3
4 /**
5 * XXX detailed description
6 *
7 * @author XXX
8 * @version XXX
9 * @copyright XXX
10 */
11 class OMVModuleZFSDataset {
12 // Attributes
13 /**
14 * Name of Dataset
15 *
16 * @var string $name
17 * @access private
18 */
19 private $name;
20
21 /**
22 * Size of Dataset
23 *
24 * @var int $size
25 * @access private
26 */
27 private $size;
28
29 /**
30 * Mountpoint of the Dataset
31 *
32 * @var string $mountPoint
33 * @access private
34 */
35 private $mountPoint;
36
37 /**
38 * List of features assigned to the Dataset
39 *
40 * @var array $features
41 * @access private
42 */
43 private $features;
44
45 // Associations
46 // Operations
47
48 /**
49 * Constructor
50 *
51 * @param string $name Name of the new Dataset
52 * @param array $features An array of features to set when creating the Dataset
53 *
54 */
55 public function __construct($name, array $features = null) {
56 $cmd = "zfs create ";
57 if (isset($features)) {
58 $cmd .= "-o " . implode(",", $features) . " ";
59 }
60 $cmd .= $name . " 2>&1";
61 exec($cmd,$out,$res);
62 if ($res == 1) {
63 throw new OMVModuleZFSException(implode("\n", $out));
64 }
65 unset($res);
66 $this->name = $name;
67 if (isset($features)) {
68 $this->features = $features;
69 foreach ($features as $feature) {
70 if (preg_match('/^mountpoint\=(.*)$/', $feature, $res)) {
71 $this->mountPoint = $res[1];
72 continue;
73 }
74 }
75 } else {
76 $this->features = array();
77 $this->mountPoint = "/" . $name;
78 }
79 }
80
81 /**
82 * Return name of the Dataset
83 *
84 * @return string $name
85 * @access public
86 */
87 public function getName() {
88 return $this->name;
89 }
90
91 /**
92 * Get the size of the Dataset
93 *
94 * @return int $size
95 * @access public
96 */
97 public function getSize() {
98 return $this->size;
99 }
100
101
102 /**
103 * Get the mountpoint of the Dataset
104 *
105 * @return string $mountPoint
106 * @access public
107 */
108 public function getMountPoint() {
109 return $this->mountPoint;
110 }
111
112 /**
113 * Get an array of features associated with the Dataset
114 *
115 * @return array $features
116 * @access public
117 */
118 public function getFeatures() {
119 return $this->features;
120 }
121
122 /**
123 * XXX
124 *
125 * @param array XXX
126 * @return void XXX
127 * @access public
128 */
129 public function setFeatures($list) {
130 trigger_error('Not Implemented!', E_USER_WARNING);
131 }
132
133 }
134
135 ?>
This page took 0.151516 seconds and 6 git commands to generate.