+ public function getName() {
+ return "ZFS"; // RPC Service name. Same as in .js files
+ }
+
+ /* Initialize the RPC service. Different methods of the RPC service are declared here*/
+ public function initialize() {
+ $this->registerMethod("addPool");
+ $this->registerMethod("getObjectTree");
+ $this->registermethod("passParam");
+ $this->registermethod("addObject");
+ $this->registermethod("deleteObject");
+ $this->registermethod("getProperties");
+ $this->registermethod("setProperties");
+ $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;
+ break;
+ case "mirror":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSMIRROR;
+ break;
+ case "raidz1":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ1;
+ break;
+ case "raidz2":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ2;
+ break;
+ case "raidz3":
+ $pooltype = OMVModuleZFSVdevType::OMVMODULEZFSRAIDZ3;
+ break;
+ default:
+ throw new OMVModuleZFSException("Incorrect pool type specified");
+ break;
+ }
+ //Check for user supplied options
+ $opts = "";
+ if ($params['force']) {
+ $opts .= "-f ";
+ }
+ if (strlen($params['mountpoint']) > 0) {
+ $opts .= "-m " . $params['mountpoint'] . " ";
+ }