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!
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. from argparse import ArgumentParser
  2. import argparse
  3. import yaml
  4. import os
  5. # from weir import zfs, process
  6. from .image import command_image_build, \
  7. command_image_tag, \
  8. command_image_untag, \
  9. command_image_list, \
  10. command_image_prune, \
  11. command_image_remove
  12. from .volume import command_volume_create, \
  13. command_volume_prune, \
  14. command_volume_list, \
  15. command_volume_tag, \
  16. command_volume_untag
  17. import sys
  18. from .zfs import zfs_init
  19. from .jail import command_jail_create, \
  20. command_jail_start, \
  21. command_jail_stop, \
  22. command_jail_remove, \
  23. command_jail_exec, \
  24. command_jail_oneshot, \
  25. command_jail_list, \
  26. command_jail_tag, \
  27. command_jail_untag, \
  28. command_jail_prune
  29. def create_parser():
  30. parser_top = ArgumentParser()
  31. subparsers_top = parser_top.add_subparsers()
  32. # image
  33. subparsers = subparsers_top.add_parser('image').add_subparsers()
  34. parser = subparsers.add_parser('build')
  35. parser.set_defaults(func=command_image_build)
  36. parser.add_argument('focker_dir', type=str)
  37. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  38. parser = subparsers.add_parser('tag')
  39. parser.set_defaults(func=command_image_tag)
  40. parser.add_argument('reference', type=str)
  41. parser.add_argument('tags', type=str, nargs='+')
  42. parser = subparsers.add_parser('untag')
  43. parser.set_defaults(func=command_image_untag)
  44. parser.add_argument('tags', type=str, nargs='+', default=[])
  45. parser = subparsers.add_parser('list')
  46. parser.set_defaults(func=command_image_list)
  47. parser.add_argument('--full-sha256', '-f', action='store_true')
  48. parser = subparsers.add_parser('prune')
  49. parser.set_defaults(func=command_image_prune)
  50. parser = subparsers.add_parser('remove')
  51. parser.set_defaults(func=command_image_remove)
  52. parser.add_argument('reference', type=str)
  53. # parser.add_argument('--remove-children', '-r', action='store_true')
  54. parser.add_argument('--remove-dependents', '-R', action='store_true')
  55. # jail
  56. subparsers = subparsers_top.add_parser('jail').add_subparsers()
  57. parser = subparsers.add_parser('create')
  58. parser.set_defaults(func=command_jail_create)
  59. parser.add_argument('image', type=str)
  60. parser.add_argument('--command', '-c', type=str, default='/bin/sh')
  61. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  62. parser.add_argument('--env', '-e', type=str, nargs='+', default=[])
  63. parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
  64. parser.add_argument('--hostname', '-n', type=str)
  65. parser = subparsers.add_parser('start')
  66. parser.set_defaults(func=command_jail_start)
  67. parser.add_argument('reference', type=str)
  68. parser = subparsers.add_parser('stop')
  69. parser.set_defaults(func=command_jail_stop)
  70. parser.add_argument('reference', type=str)
  71. parser = subparsers.add_parser('remove')
  72. parser.set_defaults(func=command_jail_remove)
  73. parser.add_argument('reference', type=str)
  74. parser = subparsers.add_parser('exec')
  75. parser.set_defaults(func=command_jail_exec)
  76. parser.add_argument('reference', type=str)
  77. parser.add_argument('command', type=str, nargs=argparse.REMAINDER, default=['/bin/sh'])
  78. parser = subparsers.add_parser('oneshot')
  79. parser.set_defaults(func=command_jail_oneshot)
  80. parser.add_argument('image', type=str)
  81. parser.add_argument('--env', '-e', type=str, nargs='+', default=[])
  82. parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
  83. parser.add_argument('command', type=str, nargs=argparse.REMAINDER, default=['/bin/sh'])
  84. parser = subparsers.add_parser('list')
  85. parser.set_defaults(func=command_jail_list)
  86. parser.add_argument('--full-sha256', '-f', action='store_true')
  87. parser = subparsers.add_parser('tag')
  88. parser.set_defaults(func=command_jail_tag)
  89. parser.add_argument('reference', type=str)
  90. parser.add_argument('tags', type=str, nargs='+')
  91. parser = subparsers.add_parser('untag')
  92. parser.set_defaults(func=command_jail_untag)
  93. parser.add_argument('tags', type=str, nargs='+')
  94. parser = subparsers.add_parser('prune')
  95. parser.set_defaults(func=command_jail_prune)
  96. parser.add_argument('--force', '-f', action='store_true')
  97. # volume
  98. subparsers = subparsers_top.add_parser('volume').add_subparsers()
  99. parser = subparsers.add_parser('create')
  100. parser.set_defaults(func=command_volume_create)
  101. parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
  102. parser = subparsers.add_parser('prune')
  103. parser.set_defaults(func=command_volume_prune)
  104. parser = subparsers.add_parser('list')
  105. parser.set_defaults(func=command_volume_list)
  106. parser.add_argument('--full-sha256', '-f', action='store_true')
  107. parser = subparsers.add_parser('tag')
  108. parser.set_defaults(func=command_volume_tag)
  109. parser.add_argument('reference', type=str)
  110. parser.add_argument('tags', type=str, nargs='+')
  111. parser = subparsers.add_parser('untag')
  112. parser.set_defaults(func=command_volume_untag)
  113. parser.add_argument('tags', type=str, nargs='+')
  114. return parser_top
  115. def main():
  116. zfs_init()
  117. parser = create_parser()
  118. args = parser.parse_args()
  119. if not hasattr(args, 'func'):
  120. sys.exit('You must choose a mode')
  121. args.func(args)
  122. if __name__ == '__main__':
  123. main()