service.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. from comar.service import *
  3. import os
  4. serviceType = "local"
  5. serviceDesc = _({"en": "libvirt virtualization API daemon",
  6. "tr": "libvirt sanallaştırma hizmeti"})
  7. serviceDefault = "on"
  8. PIDFILE = "/run/libvirt/libvirtd.pid"
  9. KRB5_KTNAME = "/etc/libvirt/krb5.tab"
  10. LIBVIRTD_CONFIG = "/etc/libvirt/libvirtd.conf"
  11. @synchronized
  12. def start():
  13. os.environ["KRB5_KTNAME"] = config.get("KRB5_KTNAME", KRB5_KTNAME)
  14. os.environ["PATH"] = "/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin"
  15. if os.path.exists(PIDFILE):
  16. os.unlink(PIDFILE)
  17. startService(command="/usr/sbin/libvirtd",
  18. args="--daemon --config %s %s --pid-file %s" % (
  19. config.get("LIBVIRTD_ARGS", ""),
  20. config.get("LIBVIRTD_CONFIG", LIBVIRTD_CONFIG),
  21. PIDFILE,
  22. ),
  23. donotify=True)
  24. @synchronized
  25. def stop():
  26. stopService(pidfile="/run/libvirt/libvirtd.pid",
  27. donotify=True)
  28. if os.path.exists(PIDFILE):
  29. os.unlink(PIDFILE)
  30. @synchronized
  31. def reload():
  32. if os.path.exists(PIDFILE):
  33. os.kill(int(open(PIDFILE, "r").read().strip()), 1)
  34. def status():
  35. return isServiceRunning(pidfile=PIDFILE)