A thin wrapper around ZFS from the OpenZFS project.
The library aims at providing a simple, low-level interface for working with ZFS, either by wrapping the zfs(8) and zpool(8) CLI utilities or by accessing the native python API.
It does not provide a high-level interface, however, and does not aim to. It also tries to keep as little state as possible.
Two interface classes make up the API, ZFS and ZPool, which are wrappers around the functionality of the CLI tools of the same name. They come with two implementations:
The CLI implementation wraps the executables
The Native implementation uses the native API released with OpenZFS 0.8.
In this early stage, the native implementation has not been written.
Status
The table gives a rough overview over features and their implementation state. For the PE Helper, functions where it is of no use are left empty (use zfs allow for those). Recursive is used to denote if it can destroy the dataset with dependent datasets, for example a fileset with its associated snapshots.
API |
Topic |
Feature |
CLI |
Native |
PE Helper |
Recursive |
|---|---|---|---|---|---|---|
ZFS |
Properties |
Read native |
Yes |
No |
||
Write native |
Yes |
No |
||||
Read metadata |
Yes |
No |
||||
Write metadata |
Yes |
No |
||||
Datasets |
List datasets |
Yes |
No |
|||
Check existance |
Yes |
No |
||||
Create Fileset |
Yes |
No |
Yes |
|||
Create Volume |
No |
No |
||||
Create Snapshot |
No |
No |
No |
|||
Create Bookmark |
No |
No |
||||
Destroy Fileset |
Yes |
No |
Yes |
Yes (Snaps) |
||
Destroy Volume |
No |
No |
No |
|||
Destroy Snapshot |
No |
No |
No |
|||
Destroy Bookmark |
No |
No |
No |
|||
ZPool |
Storage |
List pools |
No |
No |
||
Read structure |
Yes |
No |
||||
Replace disk |
No |
No |
No |
|||
Destroy |
No |
No |
No |
|||
Create |
No |
No |
No |
|||
Properties |
Read native |
No |
No |
|||
Write native |
No |
No |
No |
|||
Read metadata |
No |
No |
||||
Write metadata |
No |
No |
Usage
One can either get a concrete implementation by calling ZFSCli/ZFSNative or ZPoolCli/ZPoolNative, or more conveniently use the functions get_zfs(implementation_name) or get_zpool(implementation_name). First, get an instance:
>>> from simplezfs import get_zfs
>>> zfs = get_zfs('cli') # or "native" for the native API
>>> zfs
<simplezfs.zfs_cli.ZFSCli object at 0x7ffbca7fb9e8>
>>>
>>> for ds in zfs.list_datasets():
... print(ds.name)
...
tank
tank/system
tank/system/rootfs
Compatibility
The library is written with Python 3.6 or higher in mind, which was in a stable release in a few of the major Linux distributions we care about (Debian Buster, Ubuntu 18.04 LTS, RHEL 8, Gentoo).
On the OpenZFS side, the code is developed on version 0.8 and newer, and takes some validation values from that release. The library doesn’t make a lot of assumptions, the code should work on 0.7, too. If you spot an incompatibility, please let us know via the issue tracker.
Testing
An extensive set of tests are in the tests/ subfolder, it can be run using pytest from the source of the repository. At this time, only the validation functions and the ZFS Cli API are tested, the tests are non-destructive and won’t run the actual commands but instead mock away the subprocess invocations and supply dummy commands to run (usually /bin/true) should the code be changed in a way that isn’t caught by the test framework. Nevertheless, keep in mind that if commands are run for whatever reason, they most likely result in unrecoverable data loss.
It is planned to add a separate set of destructive tests that need to be specially activated for testing if the code works when run against an actual Linux system. This can’t be done using most of the CI providers, as the nature of ZFS requires having a operating system with loaded modules that may be destroyed during the test run.
Metadata
Release files for simplezfs 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplezfs-0.0.3.tar.gz | 27.7 kB | Without provenance | Details for simplezfs-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simplezfs-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for simplezfs-0.0.3-py3-none-any.whl |
Total release size: 57.9 kB
Release files / simplezfs-0.0.3.tar.gz
| Download URL | simplezfs-0.0.3.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e4d3e3d73ed7abaaaf4ca4aebf9947e3bd1ef877eed3bada147547a9dc11d8b
|
|
BLAKE2b-256 checksum How to use checksums |
e4e3ac178f9a2a7228acfffece9cc82f140ad78396607c0ae7b9f344baae01a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / simplezfs-0.0.3-py3-none-any.whl
| Download URL | simplezfs-0.0.3-py3-none-any.whl |
|---|---|
| Size | 30.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eadbb6f8af7c0508291182c4ad90ae1d18a94d843db10ab135b7195ada988688
|
|
BLAKE2b-256 checksum How to use checksums |
137afda36349defed39ef1a93567a614c28b27bd53901e1637e8cf84c4fa9af6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for simplezfs 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.