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:
Method | Parameters | Description |
---|---|---|
share_createNfs | $pid | Enable NFS share |
share_createFtp | $pid | Enable FTP account |
share_createCifs | $pid | Enable SMB share |
share_createIscsi | $pid | Enable iSCSI device |
share_deleteNfs | $pid | Disable NFS share |
share_deleteFtp | $pid | Disable FTP account |
share_deleteCifs | $pid | Disable SMB share |
share_deleteIscsi | $pid | Disable iSCSI device |
snapshot_createSnapshots | $pid, $comment | Create Snapshot |
snapshot_listSnapshots | $pid | List Snapshots (returns array) |
snapshot_deleteSnapshot | $snapshot_id | Delete Snapshot |
snapshot_rollbackSnapshot | $snapshot_id | Rollback Snapshot |
ipcontrol_removeIp | $pid, $service, $ip | Remove IP from ACL. $service must be iscsi, nfs or cifs |
ipcontrol_addIP | $pid, $service, $ip | Add IP to ACL. $service must be iscsi, nfs or cifs |
makeRequest | $method $apiEndoint $params $logFunction | get, post, put, delete |
user_getAllDetails | $pid | Return 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__);