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!
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

59 строки
1.7KB

  1. from argparse import ArgumentParser
  2. import yaml
  3. import os
  4. from weir import zfs, process
  5. from .build import build
  6. def clone(self, name, props={}, force=False):
  7. url = zfs._urlsplit(self.name)
  8. url_1 = zfs._urlsplit(name)
  9. if url.netloc != url_1.netloc:
  10. raise ValueError('Clone has to happen on the same host')
  11. cmd = ['zfs', 'clone']
  12. for prop, value in props.items():
  13. cmd.append('-o')
  14. cmd.append(prop + '=' + str(value))
  15. cmd.append(url.path)
  16. cmd.append(url_1.path)
  17. process.check_call(cmd, netloc=url.netloc)
  18. zfs.ZFSSnapshot.clone = clone
  19. def command_build(args):
  20. fname = os.path.join(args.focker_dir, 'Fockerfile.yml')
  21. print('fname:', fname)
  22. if not os.path.exists(fname):
  23. raise ValueError('No Fockerfile.yml could be found in the specified directory')
  24. with open(fname, 'r') as f:
  25. spec = yaml.safe_load(f)
  26. print('spec:', spec)
  27. build(spec)
  28. def run(args):
  29. pass
  30. def create_parser():
  31. parser = ArgumentParser()
  32. subparsers = parser.add_subparsers()
  33. parser_build = subparsers.add_parser('build')
  34. parser_build.set_defaults(func=command_build)
  35. parser_build.add_argument('focker_dir', type=str)
  36. parser_run = subparsers.add_parser('run')
  37. parser_run.set_defaults(func=run)
  38. parser_rm = subparsers.add_parser('rm')
  39. parser_rmi = subparsers.add_parser('rmi')
  40. parser_ps = subparsers.add_parser('ps')
  41. parser_images = subparsers.add_parser('images')
  42. return parser
  43. parser = create_parser()
  44. args = parser.parse_args()
  45. if not hasattr(args, 'func'):
  46. raise ValueError('You must choose the mode')
  47. args.func(args)