hooks: test zfs metadata consistency

This commit is contained in:
Franzi 2021-12-29 13:23:07 +01:00
parent 0b4f0e142f
commit 390f18a3a4
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 55 additions and 1 deletions

View file

@ -1,8 +1,22 @@
from bundlewrap.exceptions import BundleError
from bundlewrap.utils.text import bold, green, yellow
from bundlewrap.utils.ui import io
def test_node(repo, node, **kwargs):
if not node.has_bundle('backup-client'):
return
if node.metadata.get('backups/exclude_from_backups', False):
io.stderr('{x} {node} exclude_from_backups=True'.format(
x=yellow("»"),
node=bold(node.name),
))
return
assert len(node.metadata.get('backups/paths', set())) > 0, f'{node.name} has backups configured, but no backup paths defined!'
if not len(node.metadata.get('backups/paths', set())):
raise BundleError(f'{node.name} has backups configured, but no backup paths defined!')
io.stdout('{x} {node} backup metadata conforms to standards'.format(
x=green(""),
node=bold(node.name),
))