Example #1
0
File: helper.py Project: xww/study
 def _get_conn(self):
     LOG.info("Getting new libvirt connection")
     global _LIBVIRT_CONN
     _LIBVIRT_CONN = libvirt.open(None)
     self._conn = _LIBVIRT_CONN
     LOG.info("Got new libvirt connection")
Example #2
0
File: helper.py Project: xww/study
import libvirt_qemu
from libvirt_qemu import libvirt
import threading

import log

LOG = log.getLogger(__name__)


try:
    LOG.info("Initing libvirt connection")
    _LIBVIRT_CONN = libvirt.open(None)
except libvirt.libvirtError as e:
    LOG.error("Init connection to libvirt failed, exception: %s" % e)
    raise e

CONN_LOCK = threading.RLock()


class LibvirtQemuHelper(object):
    def __init__(self):
        global _LIBVIRT_CONN
        if _LIBVIRT_CONN:
            self._conn = _LIBVIRT_CONN
        else:
            self._conn = None

    def _get_conn(self):
        LOG.info("Getting new libvirt connection")
        global _LIBVIRT_CONN