From 4e7d4caf486e731d7de4e5171a819fdc9fe1f2dd Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Wed, 12 Mar 2014 20:34:16 +0100 Subject: [PATCH] Started work on Zvol class. Signed-off-by: Niclas Berglind --- src/Zvol.php | 174 ++++++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 77 deletions(-) diff --git a/src/Zvol.php b/src/Zvol.php index 286d6ab..5c07ebb 100644 --- a/src/Zvol.php +++ b/src/Zvol.php @@ -8,91 +8,111 @@ * @copyright XXX */ class OMVModuleZFSZvol { - // Attributes - /** - * XXX - * - * @var string $name - * @access private - */ - private $_name; + // Attributes + + /** + * Name of Zvol + * + * @var string $name + * @access private + */ + private $name; - /** - * XXX - * - * @var int $size - * @access private - */ - private $_size; + /** + * Size of Zvol + * + * @var int $size + * @access private + */ + private $size; - /** - * XXX - * - * @var string $mountPoint - * @access private - */ - private $_mountPoint; + /** + * Mountpoint of the Zvol + * + * @var string $mountPoint + * @access private + */ + private $mountPoint; - /** - * XXX - * - * @var list $features - * @access private - */ - private $_features; + /** + * Array with properties assigned to the Zvol + * + * @var array $properties + * @access private + */ + private $properties; - // Associations - // Operations - /** - * XXX - * - * @return string XXX - * @access public - */ - public function getName() { - trigger_error('Not Implemented!', E_USER_WARNING); - } + // Associations + // Operations + /** + * XXX + * + * @return string XXX + * @access public + */ + public function getName() { + trigger_error('Not Implemented!', E_USER_WARNING); + } - /** - * XXX - * - * @return int XXX - * @access public - */ - public function getSize() { - trigger_error('Not Implemented!', E_USER_WARNING); - } + /** + * XXX + * + * @return int XXX + * @access public + */ + public function getSize() { + trigger_error('Not Implemented!', E_USER_WARNING); + } - /** - * XXX - * - * @return string XXX - * @access public - */ - public function getMountPoint() { - trigger_error('Not Implemented!', E_USER_WARNING); - } + /** + * XXX + * + * @return string XXX + * @access public + */ + public function getMountPoint() { + trigger_error('Not Implemented!', E_USER_WARNING); + } - /** - * XXX - * - * @return list XXX - * @access public - */ - public function getFeatures() { - trigger_error('Not Implemented!', E_USER_WARNING); - } + /** + * XXX + * + * @return list XXX + * @access public + */ + public function getProperties() { + trigger_error('Not Implemented!', E_USER_WARNING); + } - /** - * XXX - * - * @param $list XXX - * @return void XXX - * @access public - */ - public function setFeatures($list) { - trigger_error('Not Implemented!', E_USER_WARNING); - } + /** + * XXX + * + * @param $list XXX + * @return void XXX + * @access public + */ + public function setProperties($properties) { + trigger_error('Not Implemented!', E_USER_WARNING); + } + + /** + * Helper function to execute a command and throw an exception on error + * (requires stderr redirected to stdout for proper exception message). + * + * @param string $cmd Command to execute + * @param array &$out If provided will contain output in an array + * @param int &$res If provided will contain Exit status of the command + * @return string Last line of output when executing the command + * @throws OMVModuleZFSException + * @access private + */ + private function exec($cmd, &$out = null, &$res = null) { + $tmp = OMVUtil::exec($cmd, $out, $res); + if ($res) { + throw new OMVModuleZFSException(implode("\n", $out)); + } + return $tmp; + } } -- 2.39.2