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!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

focker.py 4.4KB

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