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!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

97 wiersze
3.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. from .volume import command_volume_create, \
  12. command_volume_prune, \
  13. command_volume_list, \
  14. command_volume_tag, \
  15. command_volume_untag
  16. import sys
  17. from .zfs import zfs_init
  18. from .jail import command_jail_run
  19. def create_parser():
  20. parser_top = ArgumentParser()
  21. subparsers_top = parser_top.add_subparsers()
  22. # image
  23. subparsers = subparsers_top.add_parser('image').add_subparsers()
  24. parser = subparsers.add_parser('build')
  25. parser.set_defaults(func=command_image_build)
  26. parser.add_argument('focker_dir', type=str)
  27. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  28. parser = subparsers.add_parser('tag')
  29. parser.set_defaults(func=command_image_tag)
  30. parser.add_argument('reference', type=str)
  31. parser.add_argument('tags', type=str, nargs='+')
  32. parser = subparsers.add_parser('untag')
  33. parser.set_defaults(func=command_image_untag)
  34. parser.add_argument('tags', type=str, nargs='+', default=[])
  35. parser = subparsers.add_parser('list')
  36. parser.set_defaults(func=command_image_list)
  37. parser.add_argument('--full-sha256', '-f', action='store_true')
  38. parser = subparsers.add_parser('prune')
  39. parser.set_defaults(func=command_image_prune)
  40. parser = subparsers.add_parser('remove')
  41. parser.set_defaults(func=command_image_remove)
  42. parser.add_argument('reference', type=str)
  43. # parser.add_argument('--remove-children', '-r', action='store_true')
  44. parser.add_argument('--remove-dependents', '-R', action='store_true')
  45. # jail
  46. subparsers = subparsers_top.add_parser('jail').add_subparsers()
  47. parser = subparsers.add_parser('run')
  48. parser.set_defaults(func=command_jail_run)
  49. parser.add_argument('image', type=str)
  50. parser.add_argument('--command', '-c', type=str, default='/bin/sh')
  51. # volume
  52. subparsers = subparsers_top.add_parser('volume').add_subparsers()
  53. parser = subparsers.add_parser('create')
  54. parser.set_defaults(func=command_volume_create)
  55. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  56. parser = subparsers.add_parser('prune')
  57. parser.set_defaults(func=command_volume_prune)
  58. parser = subparsers.add_parser('list')
  59. parser.set_defaults(func=command_volume_list)
  60. parser.add_argument('--full-sha256', '-f', action='store_true')
  61. parser = subparsers.add_parser('tag')
  62. parser.set_defaults(func=command_volume_tag)
  63. parser.add_argument('reference', type=str)
  64. parser.add_argument('tags', type=str, nargs='+')
  65. parser = subparsers.add_parser('untag')
  66. parser.set_defaults(func=command_volume_untag)
  67. parser.add_argument('tags', type=str, nargs='+')
  68. return parser_top
  69. def main():
  70. zfs_init()
  71. parser = create_parser()
  72. args = parser.parse_args()
  73. if not hasattr(args, 'func'):
  74. sys.exit('You must choose a mode')
  75. args.func(args)
  76. if __name__ == '__main__':
  77. main()