]>
Commit | Line | Data |
---|---|---|
f891182f | 1 | <?php |
ba6cf545 | 2 | require_once("Exception.php"); |
f891182f MR |
3 | |
4 | /** | |
5 | * XXX detailed description | |
6 | * | |
7 | * @author XXX | |
8 | * @version XXX | |
9 | * @copyright XXX | |
10 | */ | |
63617ac2 | 11 | class OMVModuleZFSDataset { |
f891182f MR |
12 | // Attributes |
13 | /** | |
a4056e15 | 14 | * Name of Dataset |
f891182f MR |
15 | * |
16 | * @var string $name | |
17 | * @access private | |
18 | */ | |
a4056e15 | 19 | private $name; |
f891182f MR |
20 | |
21 | /** | |
ba6cf545 | 22 | * Size of Dataset |
f891182f MR |
23 | * |
24 | * @var int $size | |
25 | * @access private | |
26 | */ | |
ba6cf545 | 27 | private $size; |
f891182f MR |
28 | |
29 | /** | |
ba6cf545 | 30 | * Mountpoint of the Dataset |
f891182f MR |
31 | * |
32 | * @var string $mountPoint | |
33 | * @access private | |
34 | */ | |
ba6cf545 | 35 | private $mountPoint; |
f891182f MR |
36 | |
37 | /** | |
ba6cf545 | 38 | * List of features assigned to the Dataset |
f891182f MR |
39 | * |
40 | * @var array $features | |
41 | * @access private | |
42 | */ | |
ba6cf545 | 43 | private $features; |
f891182f | 44 | |
ba6cf545 NB |
45 | // Associations |
46 | // Operations | |
f891182f | 47 | |
ba6cf545 NB |
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 | } | |
f891182f | 80 | |
ba6cf545 NB |
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 | } | |
f891182f | 90 | |
ba6cf545 NB |
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 | } | |
f891182f | 100 | |
ba6cf545 NB |
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 | } | |
f891182f MR |
132 | |
133 | } | |
134 | ||
135 | ?> |