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!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

54 lignes
1.6KB

  1. from argparse import ArgumentParser
  2. import yaml
  3. import os
  4. # from weir import zfs, process
  5. from .image import command_image_build, \
  6. command_image_untag, \
  7. command_image_list, \
  8. command_image_prune
  9. import sys
  10. from .zfs import zfs_init
  11. from .jail import command_jail_run
  12. def create_parser():
  13. parser_top = ArgumentParser()
  14. subparsers_top = parser_top.add_subparsers()
  15. subparsers = subparsers_top.add_parser('image').add_subparsers()
  16. parser = subparsers.add_parser('build')
  17. parser.set_defaults(func=command_image_build)
  18. parser.add_argument('focker_dir', type=str)
  19. parser.add_argument('--tag', '-t', type=str, nargs='+', default=[])
  20. parser = subparsers.add_parser('untag')
  21. parser.set_defaults(func=command_image_untag)
  22. parser.add_argument('tags', type=str, nargs='+', default=[])
  23. parser = subparsers.add_parser('list')
  24. parser.set_defaults(func=command_image_list)
  25. parser.add_argument('--full-sha256', '-f', action='store_true')
  26. parser = subparsers.add_parser('prune')
  27. parser.set_defaults(func=command_image_prune)
  28. subparsers = subparsers_top.add_parser('jail').add_subparsers()
  29. parser = subparsers.add_parser('run')
  30. parser.set_defaults(func=command_jail_run)
  31. parser.add_argument('image', type=str)
  32. parser.add_argument('--command', '-c', type=str, default='/bin/sh')
  33. return parser_top
  34. def main():
  35. zfs_init()
  36. parser = create_parser()
  37. args = parser.parse_args()
  38. if not hasattr(args, 'func'):
  39. sys.exit('You must choose a mode')
  40. args.func(args)
  41. if __name__ == '__main__':
  42. main()