]> git.datanom.net - omvzfs.git/blobdiff - gui/rpc/zfs.inc
Added columns to overview and implemented object details window.
[omvzfs.git] / gui / rpc / zfs.inc
index 91c7e19a4a68669508ae087d264c20142c2631aa..7a6b36410e58b4021a9fcc030a1f96163441f158 100644 (file)
@@ -30,10 +30,23 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                $this->registermethod("inherit");
                $this->registermethod("getSharedParams");
                $this->registermethod("createShare");
+               $this->registermethod("getObjectDetails");
        }
 
        public function addPool($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "pooltype":{"type":"string","enum":["basic","mirror",' .
+                                       '"raidz1","raidz2","raidz3"]},
+                                 "force":{"type":"boolean"},
+                                 "mountpoint":{"type":"string"},
+                                 "name":{"type":"string"},
+                                 "devices":{"type":"string"}
+                         }
+                 }');
                switch ($params['pooltype']) {
                case "basic":
                        $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSPLAIN;
@@ -94,11 +107,30 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function passParam($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "key":{"type":"string"},
+                                 "value":{"type":"string"}
+                         }
+                 }');
                return array($params['key'] => $params['value']);
        }
 
        public function addObject($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "type":{"type":"string","enum":["filesystem","snapshot",' .
+                                       '"volume"]},
+                                 "path":{"type":"string"},
+                                 "name":{"type":"string"},
+                                 "size":{"type":"string"}
+                         }
+                 }');
                switch ($params['type']) {
                case "filesystem":
                        $name = $params['path'] . "/" . $params['name'];
@@ -121,6 +153,15 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function deleteObject($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "type":{"type":"string","enum":["Filesystem","Snapshot",' .
+                                       '"Volume","Clone","Pool"]},
+                                 "name":{"type":"string"}
+                         }
+                 }');
                global $xmlConfig;
                $name = $params['name'];
                switch ($params['type']) {
@@ -161,6 +202,18 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function getProperties($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "type":{"type":"string"},
+                                 "name":{"type":"string"},
+                                 "start":{"type":"integer"},
+                                 "limit":{'.$GLOBALS['OMV_JSONSCHEMA_COUNTFIELD'].'},
+                                 "sortfield":{'.$GLOBALS['OMV_JSONSCHEMA_SORTFIELD'].'},
+                                 "sortdir":{'.$GLOBALS['OMV_JSONSCHEMA_SORTDIR'].'}
+                         }
+               }');
                $objects = array();
                $name = $params['name'];
                switch ($params['type']) {
@@ -195,6 +248,20 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function setProperties($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                       "type":"object",
+                               "properties":{
+                                       "type":{"type":"string","enum":["Filesystem","Snapshot",' .
+                                               '"Volume","Clone","Pool"]},
+                                       "name":{"type":"string"},
+                                       "properties":{"type":"array","items":{
+                                               "type":"object",
+                                               "properties":{  
+                                                       "property":{"type":"string"},
+                                                       "value":{"type":"string"}}}}
+                               }
+               }');
                $objects = array();
                switch ($params['type']) {
                case "Filesystem":
@@ -222,6 +289,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function inherit($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "type":{"type":"string","enum":["Filesystem","Snapshot",' .
+                                       '"Volume","Clone","Pool"]},
+                                 "name":{"type":"string"},
+                                 "property":{"type":"string"}
+                         }
+                 }');
                // Create a background process.
                $bgStatusFilename = $this->createBgProcStatus();
                $pid = $this->fork();
@@ -262,6 +339,14 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
 
        public function getSharedParams($params, $context) {
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "type":{"type":"string"},
+                                 "name":{"type":"string"}
+                         }
+                 }');
                $objects = array();
                $ds = new OMVModuleZFSDataset($params['name']);
                $mountpoint = $ds->getMountPoint();
@@ -274,6 +359,19 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
        public function createShare($params, $context) {
                global $xmlConfig;
                $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                         "type":"object",
+                         "properties":{
+                                 "name":{"type":"string"},
+                                 "type":{"type":"string","enum":["Filesystem","Clone"]},
+                                 "sharename":{'.$GLOBALS['OMV_JSONSCHEMA_SHARENAME'].'},
+                                 "comment":{"type":"string"},
+                                 "mode":{"type":"string","enum":["700","750","755",'.
+                                       '"770","775","777"],"optional":true},
+                                 "mountpoint":{"type":"string"}
+                         }
+                 }');
 
                //Get the UUID of the Pool
                $poolname = OMVModuleZFSUtil::getPoolname($params['name']);
@@ -363,6 +461,41 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                return $object;
        }
 
+       public function getObjectDetails($params, $context) {
+               $this->validateMethodContext($context, array("role" => OMV_ROLE_ADMINISTRATOR));
+               // Validate the parameters of the RPC service method.
+               $this->validateMethodParams($params, '{
+                       "type":"object",
+                               "properties":{
+                                       "name":{"type":"string"},
+                                               "type":{"type":"string"}
+                       }
+               }');
+               $output = "";
+               switch ($params['type']) {
+               case "Filesystem":
+                       $output .= "Filesystem details (zfs get all):\n\r\n\r";
+                       $cmd = "zfs get all {$params['name']}";
+                       break;
+               case "Volume":
+                       $output .= "Volume details (zfs get all):\n\r\n\r";
+                       $cmd = "zfs get all {$params['name']}";
+                       break;
+               case "Snapshot":
+                       $output .= "Snapshot details (zfs get all):\n\r\n\r";
+                       $cmd = "zfs get all {$params['name']}";
+                       break;
+               case "Pool":
+                       $output .= "Pool details (zpool get all):\n\r\n\r";
+                       $cmd = "zpool get all {$params['name']}";
+                       break;
+               default:
+                       throw new OMVModuleZFSException("Incorrect type provided");
+               }
+               OMVModuleZFSUtil::exec($cmd,$out,$res);
+               $output .= implode("\n\r", $out);
+               return array("details" => $output);
+       }
 }
 
 // Register the RPC service.
This page took 0.045661 seconds and 5 git commands to generate.