Skip to content

Commit 1fbac09

Browse files
Major Updates
* Test updates * Add index option to get_all_snapshots() * find_snapshots - Removing check for path existing in current FS * get_diffs(): * Add checks for stdout / stderr and return code * Remove Python2 supports * add name_full property to snapshot
1 parent 1da774b commit 1fbac09

File tree

11 files changed

+1102
-35
lines changed

11 files changed

+1102
-35
lines changed

LICENSE

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
TBD
1+
MIT License
2+
3+
Copyright (c) 2022 Timothy C. Quinn <javascriptdude [at] protonmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ZFS Libraries for Python
44

55
Python library for reading from ZFS Pools. Capable of reading, Pools, Datasets, Snapshots and Diffs for use by other Python Tools.
66

7-
This tool presently targets Python v3.7+ but will be backported if there is desire from the community and after the APIs have been stablized.
7+
This tool presently targets Python v3.7+ but has been tested for Python 2.7.18 but Python 2.x support my be removed with future releases.
88

99
## Installation
1010

dev.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PYTHONPATH=./src:${PYTHONPATH}

examples/ex_remote.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,35 @@ def main(argv):
2525

2626

2727
# Get first snapshot in specific pool/dataset
28-
p = poolset.get_pool('freenas-boot')
29-
ds = p.get_dataset('ROOT/11.3-U5')
28+
p = poolset.get_pool('tank')
29+
ds = p.get_dataset('.system/samba4')
3030
all_snaps = ds.get_all_snapshots()
3131
if len(all_snaps) == 0:
3232
print('No snapshots found for dataset: {}'.format(ds))
33+
3334
else:
34-
print('First Snapshot for dataset {}: {}'.format(ds, all_snaps[0]))
35+
snap = all_snaps[0]
36+
37+
print('First Snapshot for dataset {}: {}'.format(ds, snap))
3538

3639

37-
if False:
38-
# Lookup snapshot by its name within poolset
39-
snap = poolset.lookup('freenas-boot/ROOT/11.3-U5@2020-01-30-19:49:13')
40-
print('poolset.lookup snap: {}'.format(snap))
40+
if True:
41+
# Lookup snapshot by its name within poolset
42+
snap = poolset.lookup(snap.path)
43+
print('poolset.lookup snap: {}'.format(snap))
4144

4245

43-
if False:
44-
# Lookup snapshot by its name within pool
45-
p = poolset.get_pool('freenas-boot')
46-
snap = p.lookup('ROOT/11.3-U5@2020-01-30-19:49:13')
47-
print('pool.lookup snap: {}'.format(snap))
46+
if True:
47+
# Lookup snapshot by its name within pool
48+
snap = p.lookup(snap.name_full)
49+
print('pool.lookup snap: {}'.format(snap))
4850

4951

50-
# Iterate through all pools and print all datasets
51-
if False:
52-
print("Pools and Datasets:")
53-
for p in poolset:
54-
print_all_datasets(p)
52+
# Iterate through all pools and print all datasets
53+
if True:
54+
print("Pools and Datasets:")
55+
for p in poolset:
56+
print_all_datasets(p)
5557

5658

5759

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[tool.poetry]
2+
name = "zfslib"
3+
version = "0.9.1"
4+
description = "ZFS Utilities For Python3"
5+
license = "MIT"
6+
authors = ["Timothy C. Quinn"]
7+
readme = "README.md"
8+
homepage = "https://pypi.org/project/zfslib"
9+
repository = "https://github.com/JavaScriptDude/zfslib"
10+
classifiers = [
11+
'Development Status :: 4 - Beta',
12+
'Environment :: Console',
13+
'Intended Audience :: System Administrators',
14+
'License :: OSI Approved :: BSD License',
15+
'Operating System :: POSIX :: Linux',
16+
'Operating System :: POSIX :: BSD',
17+
'Operating System :: POSIX :: SunOS/Solaris',
18+
'Operating System :: MacOS :: MacOS X',
19+
'Programming Language :: Python :: 3 :: Only',
20+
'Programming Language :: Python :: 3.7',
21+
'Programming Language :: Python :: 3.8',
22+
'Programming Language :: Python :: 3.9',
23+
'Topic :: System :: Filesystems',
24+
'Topic :: Utilities',
25+
]
26+
27+
[tool.poetry.dependencies]
28+
python = "^3.7.9"
29+
30+
[tool.poetry.dev-dependencies]
31+
32+
[build-system]
33+
requires = ["poetry-core>=1.0.0"]
34+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pathlib2

src/zfslib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .zfslib import *

0 commit comments

Comments
 (0)