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.

50 lignes
1.5KB

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