]>
Commit | Line | Data |
---|---|---|
cf4e471d MR |
1 | <?php |
2 | require_once('openmediavault/object.inc'); | |
3 | require_once('openmediavault/module.inc'); | |
4 | require_once("Exception.php"); | |
5 | ||
6 | /** | |
7 | * Class containing information about the pool | |
8 | * | |
9 | * @author Michael Rasmussen | |
10 | * @version 0.1 | |
11 | * @copyright Michael Rasmussen <mir@datanom.net> | |
12 | */ | |
13 | class OMVModuleZFS extends OMVModuleAbstract | |
14 | implements OMVINotifyListener { | |
15 | ||
16 | private $pools; | |
17 | ||
18 | public function __construct() { | |
19 | $this->pools = array(); | |
20 | $this->updatePools(); | |
21 | } | |
22 | ||
23 | public function getName() { | |
24 | return "zfs"; | |
25 | } | |
26 | ||
27 | public function bindListeners(OMVNotifyDispatcher $dispatcher) { | |
28 | // Update service if configuration has been modified | |
29 | $dispatcher->addListener( | |
30 | OMV_NOTIFY_MODIFY, | |
31 | "org.openmediavault.services.nfs", | |
32 | array($this, "onUpdateNFSService")); | |
33 | $dispatcher->addListener( | |
34 | OMV_NOTIFY_CREATE, | |
35 | "org.openmediavault.services.nfs.shares.share", | |
36 | array($this, "onCreateNFSShare")); | |
37 | $dispatcher->addListener( | |
38 | OMV_NOTIFY_DELETE, | |
39 | "org.openmediavault.services.nfs.shares.share", | |
40 | array($this, "onDeleteNFSShare")); | |
41 | $dispatcher->addListener( | |
42 | OMV_NOTIFY_MODIFY, | |
43 | "org.openmediavault.services.nfs.shares.share", | |
44 | array($this, "onUpdateNFSShare")); | |
45 | } | |
46 | ||
47 | /** | |
48 | * XXX | |
49 | * org.openmediavault.services.nfs | |
50 | * | |
51 | * @param string event | |
52 | * @access public | |
53 | */ | |
54 | public function onUpdateNFSService($args) { | |
55 | $this->debug(sprintf("onUpdateNFSService args=%s", var_export($args, true))); | |
56 | } | |
57 | ||
58 | /** | |
59 | * XXX | |
60 | * org.openmediavault.services.nfs.shares.share | |
61 | * | |
62 | * @param string event | |
63 | * @access public | |
64 | */ | |
65 | public function onCreateNFSShare($args) { | |
66 | $this->debug(sprintf("onCreateNFSShare args=%s", var_export($args, true))); | |
67 | } | |
68 | ||
69 | /** | |
70 | * XXX | |
71 | * org.openmediavault.services.nfs.shares.share | |
72 | * | |
73 | * @param string event | |
74 | * @access public | |
75 | */ | |
76 | public function onDeleteNFSShare($args) { | |
77 | $this->debug(sprintf("onDeleteNFSShare args=%s", var_export($args, true))); | |
78 | } | |
79 | ||
80 | /** | |
81 | * XXX | |
82 | * org.openmediavault.services.nfs.shares.share | |
83 | * | |
84 | * @param string event | |
85 | * @access public | |
86 | */ | |
87 | public function onUpdateNFSShare($args) { | |
88 | $this->debug(sprintf("onUpdateNFSShare args=%s", var_export($args, true))); | |
89 | } | |
90 | ||
91 | /** | |
92 | * Helper function to execute a command and throw an exception on error | |
93 | * (requires stderr redirected to stdout for proper exception message). | |
94 | * | |
95 | * @param string $cmd Command to execute | |
96 | * @param array &$out If provided will contain output in an array | |
97 | * @param int &$res If provided will contain Exit status of the command | |
98 | * @return string Last line of output when executing the command | |
99 | * @throws OMVModuleZFSException | |
100 | * @access public | |
101 | */ | |
102 | private function exec($cmd, &$out = null, &$res = null) { | |
103 | $tmp = OMVUtil::exec($cmd, $out, $res); | |
104 | if ($res) { | |
105 | throw new OMVModuleZFSException(implode("\n", $out)); | |
106 | } | |
107 | return $tmp; | |
108 | } | |
109 | ||
110 | private function updatePools() { | |
111 | ||
112 | } | |
113 | } | |
114 | ||
115 | // Register module. | |
116 | $moduleMgr = &OMVModuleMgr::getInstance(); | |
117 | $moduleMgr->registerModule(new OMVModuleZFS()); | |
118 | ?> |