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.

98 Zeilen
3.3KB

  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. parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
  52. # volume
  53. subparsers = subparsers_top.add_parser('volume').add_subparsers()
  54. parser = subparsers.add_parser('create')
  55. parser.set_defaults(func=command_volume_create)
  56. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  57. parser = subparsers.add_parser('prune')
  58. parser.set_defaults(func=command_volume_prune)
  59. parser = subparsers.add_parser('list')
  60. parser.set_defaults(func=command_volume_list)
  61. parser.add_argument('--full-sha256', '-f', action='store_true')
  62. parser = subparsers.add_parser('tag')
  63. parser.set_defaults(func=command_volume_tag)
  64. parser.add_argument('reference', type=str)
  65. parser.add_argument('tags', type=str, nargs='+')
  66. parser = subparsers.add_parser('untag')
  67. parser.set_defaults(func=command_volume_untag)
  68. parser.add_argument('tags', type=str, nargs='+')
  69. return parser_top
  70. def main():
  71. zfs_init()
  72. parser = create_parser()
  73. args = parser.parse_args()
  74. if not hasattr(args, 'func'):
  75. sys.exit('You must choose a mode')
  76. args.func(args)
  77. if __name__ == '__main__':
  78. main()