]>
git.datanom.net - omvzfs.git/blob - src/Snapshot.php
2 require_once("Exception.php");
3 require_once("openmediavault/util.inc");
6 * XXX detailed description
12 class OMVModuleZFSSnapshot
{
15 * Name of the Snapshot
23 * Properties associated with the Snaphost
25 * @var array $properties
34 * Constructor. If the Snapshot already exists in the system the object will be updated with all
35 * associated properties from commandline.
37 * @param string $name Name of the new Snapshot
41 public function __construct($name) {
43 $qname = preg_quote($name, '/');
44 $cmd = "zfs list -H -t snapshot";
45 $this->exec($cmd, $out, $res);
46 foreach ($out as $line) {
47 if (preg_match('/^' . $qname . '\t.*$/', $line)) {
48 print("Name found!!!\n");
49 $this->updateAllProperties();
56 * Return name of the Snapshot
58 * @return string Nameof the Snapshot
61 public function getName() {
68 * @return list<Feature> XXX
71 public function getFeatures() {
72 trigger_error('Not Implemented!', E_USER_WARNING
);
78 * @param $list<Feature> XXX
82 public function setFeatures($list) {
83 trigger_error('Not Implemented!', E_USER_WARNING
);
87 * Get all Snapshot properties from commandline and update object properties attribute
92 private function updateAllProperties() {
93 $cmd = "zfs get -H all " . $this->name
;
94 $this->exec($cmd,$out,$res);
95 unset($this->properties
);
96 foreach ($out as $line) {
97 $tmpary = preg_split('/\t+/', $line);
98 $this->properties
["$tmpary[1]"] = array("value" => $tmpary[2], "source" => $tmpary[3]);
103 * Helper function to execute a command and throw an exception on error
104 * (requires stderr redirected to stdout for proper exception message).
106 * @param string $cmd Command to execute
107 * @param array &$out If provided will contain output in an array
108 * @param int &$res If provided will contain Exit status of the command
109 * @return string Last line of output when executing the command
110 * @throws OMVModuleZFSException
113 private function exec($cmd, &$out = null, &$res = null) {
114 $tmp = OMVUtil
::exec($cmd, $out, $res);
116 throw new OMVModuleZFSException(implode("\n", $out));
This page took 0.152886 seconds and 6 git commands to generate.