IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Add protect switch to volumes in compose.

master
parent
commit
050447f8d5
2 changed files with 8 additions and 1 deletions
  1. +5
    -0
      focker/compose.py
  2. +3
    -1
      tests/test_compose.py

+ 5
- 0
focker/compose.py View File

@@ -77,6 +77,11 @@ def build_volumes(spec):
os.chmod(mountpoint, params['chmod']) os.chmod(mountpoint, params['chmod'])
if 'zfs' in params: if 'zfs' in params:
zfs_set_props(name, params['zfs']) zfs_set_props(name, params['zfs'])
if 'protect' in params:
if params['protect']:
zfs_set_props(name, { 'focker:protect': 'on' })
else:
zfs_run(['zfs', 'inherit', '-r', 'focker:protect', name])
def build_images(spec, path, args): def build_images(spec, path, args):


+ 3
- 1
tests/test_compose.py View File

@@ -122,6 +122,7 @@ def test_build_volumes():
'test-build-volumes': { 'test-build-volumes': {
'chown': '65534:65534', 'chown': '65534:65534',
'chmod': 0o123, 'chmod': 0o123,
'protect': True,
'zfs': { 'zfs': {
'quota': '1G', 'quota': '1G',
'readonly': 'on' 'readonly': 'on'
@@ -134,9 +135,10 @@ def test_build_volumes():
assert st.st_uid == 65534 assert st.st_uid == 65534
assert st.st_gid == 65534 assert st.st_gid == 65534
assert ('%o' % st.st_mode)[-3:] == '123' assert ('%o' % st.st_mode)[-3:] == '123'
zst = zfs_parse_output(['zfs', 'get', '-H', 'quota,readonly', name])
zst = zfs_parse_output(['zfs', 'get', '-H', 'quota,readonly,focker:protect', name])
assert zst[0][2] == '1G' assert zst[0][2] == '1G'
assert zst[1][2] == 'on' assert zst[1][2] == 'on'
assert zst[2][2] == 'on'
subprocess.check_output(['zfs', 'destroy', '-r', '-f', name]) subprocess.check_output(['zfs', 'destroy', '-r', '-f', name])


Loading…
Cancel
Save