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!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

95 Zeilen
3.1KB

  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 = subparsers.add_parser('tag')
  61. parser.set_defaults(func=command_volume_tag)
  62. parser.add_argument('tags', type=str, nargs='+')
  63. parser = subparsers.add_parser('untag')
  64. parser.set_defaults(func=command_volume_untag)
  65. parser.add_argument('tags', type=str, nargs='+')
  66. return parser_top
  67. def main():
  68. zfs_init()
  69. parser = create_parser()
  70. args = parser.parse_args()
  71. if not hasattr(args, 'func'):
  72. sys.exit('You must choose a mode')
  73. args.func(args)
  74. if __name__ == '__main__':
  75. main()