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!
소스 검색

Started implementing focker jail prune.

tags/0.92
부모
커밋
7a46e18d96
2개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. +5
    -1
      focker.py
  2. +16
    -0
      jail.py

+ 5
- 1
focker.py 파일 보기

@@ -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 파일 보기

@@ -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])

불러오는 중...
취소
저장