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

Add --images switch to focker jail list.

master
Stanislaw Adaszewski il y a 4 ans
Parent
révision
e0f8520690
2 fichiers modifiés avec 30 ajouts et 6 suppressions
  1. +1
    -0
      focker/focker.py
  2. +29
    -6
      focker/jail.py

+ 1
- 0
focker/focker.py Voir le fichier

@@ -158,6 +158,7 @@ def create_parser():
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']])
parser.set_defaults(func=command_jail_list)
parser.add_argument('--full-sha256', '-f', action='store_true')
parser.add_argument('--images', '-i', action='store_true')
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['tag', 't']])
parser.set_defaults(func=command_jail_tag)


+ 29
- 6
focker/jail.py Voir le fichier

@@ -301,15 +301,38 @@ def command_jail_oneshot_old():
# raise
def command_jail_list(args):
lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint'], focker_type='jail')
headers = ['Tags', 'SHA256', 'mountpoint', 'JID']
res = []
jails = subprocess.check_output(['jls', '--libxo=json'])
jails = json.loads(jails)['jail-information']['jail']
jails = { j['path']: j for j in jails }
lst = list(map(lambda a: [ a[1],
a[0] if args.full_sha256 else a[0][:7],
a[2],
jails[a[2]]['jid'] if a[2] in jails else '-' ], lst))
print(tabulate(lst, headers=['Tags', 'SHA256', 'mountpoint', 'JID']))
if args.images:
headers.append('Image')
lst = zfs_list(fields=['name,focker:tags,focker:sha256'],
focker_type='image', zfs_type='snapshot')
images = {}
for (name, tags, sha256, *_) in lst:
images[name] = tags if tags != '-' \
else sha256 \
if args.full_sha256 \
else sha256[:7]
lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,origin'],
focker_type='jail')
for (sha256, tags, mountpoint, origin, *_) in lst:
row = [
tags,
sha256 if args.full_sha256 else sha256[:7],
mountpoint,
jails[mountpoint]['jid'] if mountpoint in jails else '-',
]
if args.images:
row.append(images[origin])
res.append(row)
print(tabulate(res, headers=headers))
def command_jail_tag(args):


Chargement…
Annuler
Enregistrer