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!
Quellcode durchsuchen

Started implementing focker jail prune.

tags/0.92
Stanislaw Adaszewski vor 4 Jahren
Ursprung
Commit
7a46e18d96
2 geänderte Dateien mit 21 neuen und 1 gelöschten Zeilen
  1. +5
    -1
      focker.py
  2. +16
    -0
      jail.py

+ 5
- 1
focker.py Datei anzeigen

@@ -18,7 +18,8 @@ from .zfs import zfs_init
from .jail import command_jail_run, \
command_jail_list, \
command_jail_tag, \
command_jail_untag
command_jail_untag, \
command_jail_prune
def create_parser():
@@ -75,6 +76,9 @@ def create_parser():
parser.set_defaults(func=command_jail_untag)
parser.add_argument('tags', type=str, nargs='+')
parser = subparsers.add_parser('prune')
parser.set_defaults(func=command_jail_prune)
# volume
subparsers = subparsers_top.add_parser('volume').add_subparsers()
parser = subparsers.add_parser('create')


+ 16
- 0
jail.py Datei anzeigen

@@ -56,6 +56,10 @@ def jail_run(path, command, mounts=[]):
raise RuntimeError('Command failed')
def jail_remove(path):
print('Removing jail:', path)
def command_jail_run(args):
base, _ = zfs_snapshot_by_tag_or_sha256(args.image)
# root = '/'.join(base.split('/')[:-1])
@@ -95,3 +99,15 @@ def command_jail_tag(args):
def command_jail_untag(args):
zfs_untag(args.tags, focker_type='jail')
def command_jail_prune(args):
jails = subprocess.check_output(['jls', '--libxo=json'])
jails = json.loads(jails)['jail-information']['jail']
used = set()
for j in jails:
used.add(j['path'])
lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,name'], focker_type='jail')
for j in lst:
if j[1] == '-' and j[2] not in used:
jail_remove(j[3])

Laden…
Abbrechen
Speichern