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!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. command_jail_list, \
  20. command_jail_tag, \
  21. command_jail_untag
  22. def create_parser():
  23. parser_top = ArgumentParser()
  24. subparsers_top = parser_top.add_subparsers()
  25. # image
  26. subparsers = subparsers_top.add_parser('image').add_subparsers()
  27. parser = subparsers.add_parser('build')
  28. parser.set_defaults(func=command_image_build)
  29. parser.add_argument('focker_dir', type=str)
  30. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  31. parser = subparsers.add_parser('tag')
  32. parser.set_defaults(func=command_image_tag)
  33. parser.add_argument('reference', type=str)
  34. parser.add_argument('tags', type=str, nargs='+')
  35. parser = subparsers.add_parser('untag')
  36. parser.set_defaults(func=command_image_untag)
  37. parser.add_argument('tags', type=str, nargs='+', default=[])
  38. parser = subparsers.add_parser('list')
  39. parser.set_defaults(func=command_image_list)
  40. parser.add_argument('--full-sha256', '-f', action='store_true')
  41. parser = subparsers.add_parser('prune')
  42. parser.set_defaults(func=command_image_prune)
  43. parser = subparsers.add_parser('remove')
  44. parser.set_defaults(func=command_image_remove)
  45. parser.add_argument('reference', type=str)
  46. # parser.add_argument('--remove-children', '-r', action='store_true')
  47. parser.add_argument('--remove-dependents', '-R', action='store_true')
  48. # jail
  49. subparsers = subparsers_top.add_parser('jail').add_subparsers()
  50. parser = subparsers.add_parser('run')
  51. parser.set_defaults(func=command_jail_run)
  52. parser.add_argument('image', type=str)
  53. parser.add_argument('--command', '-c', type=str, default='/bin/sh')
  54. parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
  55. parser = subparsers.add_parser('list')
  56. parser.set_defaults(func=command_jail_list)
  57. parser.add_argument('--full-sha256', '-f', action='store_true')
  58. parser = subparsers.add_parser('tag')
  59. parser.set_defaults(func=command_jail_tag)
  60. parser.add_argument('reference', type=str)
  61. parser.add_argument('tags', type=str, nargs='+')
  62. parser = subparsers.add_parser('untag')
  63. parser.set_defaults(func=command_jail_untag)
  64. parser.add_argument('tags', type=str, nargs='+')
  65. # volume
  66. subparsers = subparsers_top.add_parser('volume').add_subparsers()
  67. parser = subparsers.add_parser('create')
  68. parser.set_defaults(func=command_volume_create)
  69. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  70. parser = subparsers.add_parser('prune')
  71. parser.set_defaults(func=command_volume_prune)
  72. parser = subparsers.add_parser('list')
  73. parser.set_defaults(func=command_volume_list)
  74. parser.add_argument('--full-sha256', '-f', action='store_true')
  75. parser = subparsers.add_parser('tag')
  76. parser.set_defaults(func=command_volume_tag)
  77. parser.add_argument('reference', type=str)
  78. parser.add_argument('tags', type=str, nargs='+')
  79. parser = subparsers.add_parser('untag')
  80. parser.set_defaults(func=command_volume_untag)
  81. parser.add_argument('tags', type=str, nargs='+')
  82. return parser_top
  83. def main():
  84. zfs_init()
  85. parser = create_parser()
  86. args = parser.parse_args()
  87. if not hasattr(args, 'func'):
  88. sys.exit('You must choose a mode')
  89. args.func(args)
  90. if __name__ == '__main__':
  91. main()