Page tree
Skip to end of metadata
Go to start of metadata

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 to 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 for version 1.1.0 and higher:

<?php
require_once ('/path/to/modules/servers/freenas/autoload.php');

// If you have installed FreeNAS, do:
$freenas = new FreenasClient::getInstance ($pid); // replace $pid with tblhosting.id

// If you have installed TrueNAS, do:
$truenas = new TruenasClient::getInstance ($pid); // replace $pid with tblhosting.id

// FreeNAS: https://www.ixsystems.com/documentation/freenas/11.3-U4/api.html
// TrueNAS: https://www.truenas.com/docs/core/api/
// Execute API call like:
// $freenas->share_createNfs ($pid);
// $freenas->makeRequest ('get', '/api/v1.0/storage/dataset/', '', __METHOD__);

Code example for versions below 1.1.0:

<?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__);
  • No labels