This software is provided "as is," without any warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
The user assumes full responsibility for the usage of this software and the potential risks it may pose to their systems or data. This software interacts with ZFS, a powerful filesystem, and misconfiguration or misuse may lead to data loss or system instability.
It is strongly recommended to test this software in a controlled, non-production environment before deploying it to critical systems. Regular backups should be made to mitigate potential risks associated with using this software. By using this software, you agree to these terms and absolve the authors and contributors of any liability.
ZFS-Resty is a RESTful API for managing ZFS pools and devices. The application provides endpoints for authentication, creating pools, managing disks, and retrieving ZFS status information.
Note: This application requires root privileges for certain operations, such as managing ZFS pools.
Authenticate and retrieve a JWT token for subsequent requests.
- Endpoint:
/auth
- Method:
POST
- Parameters:
username
(string): System usernamepassword
(string): User password
- Endpoint:
/create-pool
- Method:
POST
- Parameters:
name
(string): Pool nameraid
(string, optional): RAID typedevices
(list): Device paths (e.g.,/dev/sda
)
- Endpoint:
/delete-pool
- Method:
POST
- Parameters:
name
(string): Pool name
- Endpoint:
/add-disk
- Method:
POST
- Parameters:
pool
(string): Pool namedevice
(string): Device path (e.g.,/dev/sdx
)
- Endpoint:
/add-spare-disk
- Method:
POST
- Parameters:
pool
(string): Pool namedevice
(string): Device path (e.g.,/dev/sdx
)
- Endpoint:
/replace-disk
- Method:
POST
- Parameters:
pool
(string): Pool nameold_device
(string): Path of the old devicenew_device
(string): Path of the replacement device
- Endpoint:
/mountpoint
- Method:
POST
- Parameters:
mountpoint
(string): Mountpoint path (e.g.,/mnt/pool
)pool
(string): Pool name
- Endpoint:
/devices
- Method:
GET
- Endpoint:
/status
- Method:
GET
- Endpoint:
/io-status
- Method:
GET
ZFS-Resty uses JWT for authentication. To authenticate:
- Send a
POST
request to/auth
with your systemusername
andpassword
. - A token will be returned in the response.
- Include this token in the
Authorization
header of all subsequent requests:Authorization: <token>
The application supports the following command-line arguments:
-p
,--port
: Set the HTTP port (default:8089
).-s
,--safe
: Restrict access to local network IPs (default:false
).
- Run the installation script:
chmod +x install.sh ./install.sh
-
Clone the repository:
git clone https://github.com/jersobh/zfs-resty.git cd zfs-resty
-
Install requirements:
pip install -r requirements.txt
-
Run the application:
sudo python zfs-resty.py
Request:
curl -X POST http://localhost:8089/auth -H "Content-Type: application/json" -d '{"username": "admin", "password": "admin"}'
Response:
{
"token": "your-jwt-token"
}
Request:
curl -X POST http://localhost:8089/create-pool -H "Authorization: <token>" -H "Content-Type: application/json" -d '{"name": "mypool", "raid": "mirror", "devices": ["/dev/sda", "/dev/sdb"]}'
Response:
{
"success": "Pool 'mypool' created successfully"
}
This project is licensed under the MIT License.