Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you want to add code yourself, you can use our PHP class to communicate with FreeNAS. The following methods are publicly documented for users of the module:

MethodParametersDescription
share_createNfs$pidEnable NFS share
share_createFtp$pidEnable FTP account
share_createCifs$pidEnable SMB share
share_createIscsi$pidEnable iSCSI device
share_deleteNfs$pidDisable NFS share
share_deleteFtp$pidDisable FTP account
share_deleteCifs$pidDisable SMB share
share_deleteIscsi$pidDisable iSCSI device
snapshot_createSnapshots$pid, $commentCreate Snapshot
snapshot_listSnapshots$pidList Snapshots (returns array)
snapshot_deleteSnapshot$snapshot_idDelete Snapshot
snapshot_rollbackSnapshot$snapshot_idRollback Snapshot
ipcontrol_removeIp$pid, $service, $ipRemove IP from ACL. $service must be iscsi, nfs or cifs
ipcontrol_addIP$pid, $service, $ipAdd IP tp ACL. $service must be iscsi, nfs or cifs
makeRequest$method
$apiEndoint
$params
$logFunction

get, post, put, delete
Endpoint from FreeNAS API, e.g. sharing/cifs
Parameter to be passed to FreeNAS, e.g. "array ('refquota' => '100 G')"
Does appear in WHMCS module debug log

user_getAllDetails$pidReturn an object with all relevant user details, like volume name, full path, disk usage, enabled services, etc.

Code Example:

Code Block
languagephp
linenumberstrue
<?php
require_once ('/path/to/modules/servers/freenas/autoload.php');
 
$freenas = FreenasAPI::getInstance ($pid); // replace $pid with tblhosting.id
 
// https://www.ixsystems.com/documentation/freenas/11.3-U4/api.html
// Execute API call like:
// $freenas->share_createNfs ($pid);
// $freenas->makeRequest ('get', '/api/v1.0/storage/dataset/', '', __METHOD__);

...