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.

57 Zeilen
1.6KB

  1. import os
  2. import yaml
  3. from .zfs import AmbiguousValueError, \
  4. zfs_find, \
  5. zfs_tag
  6. from .misc import random_sha256_hexdigest, \
  7. find_prefix
  8. import subprocess
  9. def build_volumes(spec):
  10. for tag in spec.keys():
  11. try:
  12. name, _ = zfs_find(tag, focker_type='volume')
  13. continue
  14. except AmbiguousValueError:
  15. raise
  16. except ValueError:
  17. pass
  18. sha256 = random_sha256_hexdigest()
  19. name = find_prefix(poolname + '/focker/volumes/', sha256)
  20. subprocess.check_output(['zfs', 'create', name])
  21. zfs_untag([ tag ], focker_type='volume')
  22. zfs_tag(name, [ tag ])
  23. def build_images(spec, path):
  24. # print('build_images(): NotImplementedError')
  25. for (tag, focker_dir) in spec.items():
  26. res = subprocess.run(['focker', 'image', 'build',
  27. os.path.join(path, focker_dir), '-t', tag])
  28. if res.returncode != 0:
  29. raise RuntimeError('Image build failed: ' + str(res.returncode))
  30. def build_jails(spec):
  31. print('build_jails(): NotImplementedError')
  32. def command_compose_build(args):
  33. if not os.path.exists(args.filename):
  34. raise ValueError('File not found: ' + args.filename)
  35. path, _ = os.path.split(args.filename)
  36. with open(args.filename, 'r') as f:
  37. spec = yaml.safe_load(f)
  38. if 'volumes' in spec:
  39. build_volumes(spec['volumes'])
  40. if 'images' in spec:
  41. build_images(spec['images'], path)
  42. if 'jails' in spec:
  43. build_jails(spec['jails'])
  44. def command_compose_run(args):
  45. raise NotImplementedError