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!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

46 řádky
1.4KB

  1. #
  2. # Copyright (C) Stanislaw Adaszewski, 2020
  3. # License: GNU General Public License v3.0
  4. # URL: https://github.com/sadaszewski/focker
  5. # URL: https://adared.ch/focker
  6. #
  7. from .misc import random_sha256_hexdigest
  8. from .zfs import *
  9. from tabulate import tabulate
  10. def command_volume_create(args):
  11. sha256 = random_sha256_hexdigest()
  12. poolname = zfs_poolname()
  13. for pre in range(7, 64):
  14. name = poolname + '/focker/volumes/' + sha256[:pre]
  15. if not zfs_exists(name):
  16. break
  17. zfs_run(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
  18. zfs_tag(name, args.tags)
  19. def command_volume_prune(args):
  20. zfs_prune(focker_type='volume')
  21. def command_volume_list(args):
  22. poolname = zfs_poolname()
  23. lst = zfs_parse_output(['zfs', 'list', '-o', 'name,refer,focker:sha256,focker:tags,mountpoint', '-H', '-r', poolname + '/focker/volumes'])
  24. lst = list(filter(lambda a: a[2] != '-', lst))
  25. lst = list(map(lambda a: [ a[3], a[1],
  26. a[2] if args.full_sha256 else a[2][:7],
  27. a[4] ], lst))
  28. print(tabulate(lst, headers=['Tags', 'Size', 'SHA256', 'Mountpoint']))
  29. def command_volume_tag(args):
  30. name, _ = zfs_find(args.reference, focker_type='volume')
  31. zfs_untag(args.tags, focker_type='volume')
  32. zfs_tag(name, args.tags)
  33. def command_volume_untag(args):
  34. zfs_untag(args.tags, focker_type='volume')