FreeNAS Local CLI
FreeNAS Local CLI
I created a python script that allows the user to easily interact with a FreeNAS storage server via a command line interface. This is done by sending commands to FreeNAS through it’s REST API. It allows the user to interact with the users, groups, pools, filesystems, snapshots, replications, disk, and scrub components of the FreeNAS server. The commands I created for the user to utilize are the following:
USAGE:
./freenas.py <command> <parameter>:<value> <parameter>:<value> ...
a successful create command returns 0; 1 if there was an error
commands:
USER
- check_user <parameter>:<value> ...
- create_user bsdusr_username:VALUE bsdusr_creategroup:VALUE bsdusr_full_name:VALUE bsdusr_password:VALUE bsdusr_uid:VALUE
- update_user id <parameter>:<value> ...
- destroy_user id password(optional)
- check_and_update_user <parameter>:<value> ...
GROUP
- check_group <parameter>:<value> ...
- create_group bsdgrp_gid:VALUE bsdgrp_group:VALUE
- update_group id <parameter>:<value> ...
- destroy_group gid
- check_and_update_group <parameter>:<value> ...
POOL (volume)
- create_pool volume_name:VALUE vdevtype:VALUE disks:DISK0,DISK1
- destroy_pool id
FILESYSTEM (dataset)
- check_fs <parameter>:<value> ...
- create_fs atime:VALUE avail:VALUE comments:VALUE compression:VALUE dedup:VALUE inherit_props:VALUE mountpoint:VALUE name:VALUE pool:VALUE quota:VALUE readonly:VALUE recordsize:VALUE refer:VALUE refquota:VALUE refreservation:VALUE reservation:VALUE used:VALUE
- update_fs name <parameter>:<value> ...
- destroy_fs name
- check_and_update_fs <parameter>:<value> ...
SNAPSHOT
- check_snapshot <parameter>:<value> ...
- create_snapshot dataset:VALUE name:VALUE recursive:VALUE vmware_sync:VALUE
- destroy_snapshot id
REPLICATION
- check_replication <parameter>:<value> ...
- create_replication repl_filesystem:VALUE repl_zfs:VALUE repl_remote_hostname:VALUE repl_remote_hostkey:VALUE repl_remote_cipher:VALUE
- update_replication id <parameter>:<value> ...
- destroy_replication id
DISK
- check_disk <parameter>:<value> ...
SCRUB
- check_scrub <parameter>:<value> ...
Project Repo: https://github.com/Novota15/FreeNAS-API-Script