+ public function onUpdateNFSShare($args) {
+ $this->debug(sprintf("onUpdateNFSShare args=%s", var_export($args, true)));
+ }
+
+ /**
+ * Convert array of Vdev to command string
+ *
+ * @param array $vdevs
+ * @return string
+ * @throws OMVMODULEZFSException
+ */
+ private function getCommandString(array $vdevs) {
+ $adds = array();
+
+ foreach ($vdevs as $vdev) {
+ if (is_object($vdev) == false)
+ throw new OMVMODULEZFSException("Not object of class OMVModuleZFSVdev");
+ if (is_a($vdev, OMVModuleZFSVdev) == false)
+ throw new OMVMODULEZFSException("Object is not of class OMVModuleZFSVdev");
+ $type = $vdev->getType();
+ $command = "";
+
+ switch ($type) {
+ case OMVModuleZFSVdevType::OMVMODULEZFSPLAIN: break;
+ case OMVModuleZFSVdevType::OMVMODULEZFSMIRROR: $command = "mirror"; break;
+ case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1: $command = "raidz1"; break;
+ case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2: $command = "raidz2"; break;
+ case OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3: $command = "raidz3"; break;
+ default:
+ throw new OMVMODULEZFSException("Unknown Vdev type");
+ }
+ $disks = $vdev->getDisks();
+ $diskStr = "";
+ foreach($disks as $disk) {
+ $diskStr .= " $disk";
+ }
+
+ array_push ($adds, $command . $diskStr);
+ }
+
+ return join(" ", $adds);
+ }
+
+ /**
+ * Get an attribute from pool
+ *
+ * @param string $attribute
+ * @return string value
+ */
+ private function getAttribute($attribute) {
+ $cmd = "zpool list -H -o $attribute {$this->name}";
+ OMVUtil::exec($cmd, $output, $result);
+ if ($result) {
+ $cmd = "zfs list -H -o $attribute {$this->name}";
+ OMVUtil::exec($cmd, $output, $result);
+ if ($result)
+ return null;
+ }
+
+ return $output;
+ }
+
+ /**
+ * Get all attributes from pool
+ * @return array of attributes
+ */
+ private function getAllAttributes() {
+ $attrs = array();
+ $cmd = "zfs get -H all {$this->name}";
+
+ OMVUtil::exec($cmd, $output, $result);
+ if ($result)
+ throw new OMVModuleZFSException($output);
+ $res = preg_match_all("/$pool\s+(\w+)\s+([\w\d\.]+).*/", $output, $matches, PREG_SET_ORDER);
+ if ($res == false || $res == 0)
+ throw new OMVModuleZFSException("Error return by zpool get all: $output");
+ foreach ($matches as $match) {
+ $attrs[$match[1]] = $match[2];
+ }
+
+ return $attrs;
+ }
+
+ /**
+ * Remove a disk from array
+ *
+ * @param array $array
+ * @param string $disk
+ * @return array
+ */
+ private function removeDisk(array $array, $disk) {
+ $new_disks = array();
+
+ foreach ($array as $item) {
+ if (strcmp($item, $disk) != 0)
+ array_push ($new_disks, $item);
+ }
+
+ return $new_disks;