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.

68 line
2.2KB

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