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!
Parcourir la source

Added focker image prune

tags/0.92
Stanislaw Adaszewski il y a 4 ans
Parent
révision
d65a623b2b
2 fichiers modifiés avec 25 ajouts et 1 suppressions
  1. +5
    -1
      focker.py
  2. +20
    -0
      image.py

+ 5
- 1
focker.py Voir le fichier

@@ -4,7 +4,8 @@ import os
# from weir import zfs, process
from .image import command_image_build, \
command_image_untag, \
command_image_list
command_image_list, \
command_image_prune
import sys
from .zfs import zfs_init
from .jail import command_jail_run
@@ -28,6 +29,9 @@ def create_parser():
parser.set_defaults(func=command_image_list)
parser.add_argument('--full-sha256', '-f', action='store_true')
parser = subparsers.add_parser('prune')
parser.set_defaults(func=command_image_prune)
subparsers = subparsers_top.add_parser('jail').add_subparsers()
parser = subparsers.add_parser('run')
parser.set_defaults(func=command_jail_run)


+ 20
- 0
image.py Voir le fichier

@@ -88,3 +88,23 @@ def command_image_list(args):
a[2] if args.full_sha256 else a[2][:7],
a[4].split('/')[-1].split('@')[0] ], lst))
print(tabulate(lst, headers=['Tags', 'Size', 'SHA256', 'Base']))
def command_image_prune(args):
again = True
while again:
again = False
lst = zfs_parse_output(['zfs', 'list', '-o', 'focker:sha256,focker:tags,origin,name', '-H'])
used = set()
for r in lst:
if r[2] == '-':
continue
used.add(r[2].split('@')[0])
for r in lst:
if r[0] == '-' or r[1] != '-':
continue
if r[3] not in used:
print('Removing:', r[3])
zfs_run(['zfs', 'destroy', '-f', r[3]])
again = True
# zfs_parse_output(['zfs'])

Chargement…
Annuler
Enregistrer