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!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9KB

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