libvirt.py 788 B

1234567891011121314151617181920212223242526272829303132333435
  1. """mock libvirt module
  2. WARNING: you did not import real libvirt module
  3. This is needed, because we don't currently ship libvirt-python for templates.
  4. The module contains libvirtError and openReadOnly() function, which
  5. does nothing and raises the aforementioned exception. More functions can be
  6. added as needed.
  7. """
  8. class libvirtError(Exception):
  9. def get_error_code(self):
  10. return VIR_ERR_NO_DOMAIN
  11. class virConnect:
  12. pass
  13. class virDomain:
  14. pass
  15. def openReadOnly(*args, **kwargs):
  16. raise libvirtError('mock module, always raises')
  17. def registerErrorHandler(f, ctx):
  18. pass
  19. VIR_DOMAIN_BLOCKED = 2
  20. VIR_DOMAIN_RUNNING = 1
  21. VIR_DOMAIN_PAUSED = 3
  22. VIR_DOMAIN_SHUTDOWN = 4
  23. VIR_DOMAIN_SHUTOFF = 5
  24. VIR_DOMAIN_CRASHED = 6
  25. VIR_DOMAIN_PMSUSPENDED = 7
  26. VIR_ERR_NO_DOMAIN = 0