Esempio n. 1
0
 def _set_capabilities(self):
     wok_log.info("\n*** Kimchi: Running feature tests ***")
     self.libvirtd_running = is_libvirtd_up()
     msg = "Service Libvirtd running ...: %s"
     wok_log.info(msg % str(self.libvirtd_running))
     if self.libvirtd_running == False:
         wok_log.info("*** Kimchi: Feature tests not completed ***\n")
         return
     conn = self.conn.get()
     self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
     msg = "NFS Target Probe support ...: %s"
     wok_log.info(msg % str(self.nfs_target_probe))
     self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
     msg = "Fibre Channel Host support .: %s"
     wok_log.info(msg % str(self.fc_host_support))
     self.kernel_vfio = FeatureTests.kernel_support_vfio()
     msg = "Kernel VFIO support ........: %s"
     wok_log.info(msg % str(self.kernel_vfio))
     self.nm_running = FeatureTests.is_nm_running()
     msg = "Network Manager running ....: %s"
     wok_log.info(msg % str(self.nm_running))
     self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
     msg = "Memory Hotplug support .....: %s"
     wok_log.info(msg % str(self.mem_hotplug_support))
     wok_log.info("*** Kimchi: Feature tests completed ***\n")
Esempio n. 2
0
    def lookup(self, *ident):
        if not is_libvirtd_up():
            return {
                'libvirt_stream_protocols': [],
                'qemu_spice': False,
                'qemu_stream': False,
                'screenshot': None,
                'kernel_vfio': self.kernel_vfio,
                'nm_running': FeatureTests.is_nm_running(),
                'mem_hotplug_support': False,
                'libvirtd_running': False
            }
        elif self.libvirtd_running == False:
            # Libvirt returned, run tests again
            self._set_capabilities()
            self._set_depend_capabilities()

        return {
            'libvirt_stream_protocols': self.libvirt_stream_protocols,
            'qemu_spice': self._qemu_support_spice(),
            'qemu_stream': self.qemu_stream,
            'screenshot': VMScreenshot.get_stream_test_result(),
            'kernel_vfio': self.kernel_vfio,
            'nm_running': FeatureTests.is_nm_running(),
            'mem_hotplug_support': self.mem_hotplug_support,
            'libvirtd_running': True
        }
Esempio n. 3
0
    def lookup(self, *ident):
        if not is_libvirtd_up():
            return {
                "libvirt_stream_protocols": [],
                "qemu_spice": False,
                "qemu_stream": False,
                "screenshot": None,
                "kernel_vfio": self.kernel_vfio,
                "nm_running": FeatureTests.is_nm_running(),
                "mem_hotplug_support": False,
                "libvirtd_running": False,
            }
        elif self.libvirtd_running == False:
            # Libvirt returned, run tests again
            self._set_capabilities()
            self._set_depend_capabilities()

        return {
            "libvirt_stream_protocols": self.libvirt_stream_protocols,
            "qemu_spice": self._qemu_support_spice(),
            "qemu_stream": self.qemu_stream,
            "screenshot": VMScreenshot.get_stream_test_result(),
            "kernel_vfio": self.kernel_vfio,
            "nm_running": FeatureTests.is_nm_running(),
            "mem_hotplug_support": self.mem_hotplug_support,
            "libvirtd_running": True,
        }
Esempio n. 4
0
 def _set_capabilities(self):
     wok_log.info("\n*** Kimchi: Running feature tests ***")
     self.libvirtd_running = is_libvirtd_up()
     msg = "Service Libvirtd running ...: %s"
     wok_log.info(msg % str(self.libvirtd_running))
     if self.libvirtd_running == False:
         wok_log.info("*** Kimchi: Feature tests not completed ***\n")
         return
     conn = self.conn.get()
     self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
     msg = "NFS Target Probe support ...: %s"
     wok_log.info(msg % str(self.nfs_target_probe))
     self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
     msg = "Fibre Channel Host support .: %s"
     wok_log.info(msg % str(self.fc_host_support))
     self.kernel_vfio = FeatureTests.kernel_support_vfio()
     msg = "Kernel VFIO support ........: %s"
     wok_log.info(msg % str(self.kernel_vfio))
     self.nm_running = FeatureTests.is_nm_running()
     msg = "Network Manager running ....: %s"
     wok_log.info(msg % str(self.nm_running))
     self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
     msg = "Memory Hotplug support .....: %s"
     wok_log.info(msg % str(self.mem_hotplug_support))
     wok_log.info("*** Kimchi: Feature tests completed ***\n")
Esempio n. 5
0
    def lookup(self, *ident):
        if not is_libvirtd_up():
            return {
                'libvirt_stream_protocols': [],
                'qemu_spice': False,
                'qemu_stream': False,
                'screenshot': None,
                'kernel_vfio': self.kernel_vfio,
                'nm_running': FeatureTests.is_nm_running(),
                'mem_hotplug_support': False,
                'libvirtd_running': False,
            }
        elif not self.libvirtd_running:
            # Libvirt returned, run tests again
            self._set_capabilities()
            self._set_depend_capabilities()

        return {
            'libvirt_stream_protocols': self.libvirt_stream_protocols,
            'qemu_spice': self._qemu_support_spice(),
            'qemu_stream': self.qemu_stream,
            'screenshot': VMScreenshot.get_stream_test_result(),
            'kernel_vfio': self.kernel_vfio,
            'nm_running': FeatureTests.is_nm_running(),
            'mem_hotplug_support': self.mem_hotplug_support,
            'libvirtd_running': True,
        }
Esempio n. 6
0
 def _set_capabilities(self):
     wok_log.info("*** Running feature tests ***")
     conn = self.conn.get()
     self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
     self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
     self.kernel_vfio = FeatureTests.kernel_support_vfio()
     self.nm_running = FeatureTests.is_nm_running()
     self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
     self.libvirtd_running = is_libvirtd_up()
     wok_log.info("*** Feature tests completed ***")
Esempio n. 7
0
    def lookup(self, *ident):
        if not is_libvirtd_up():
            return {'libvirt_stream_protocols': [],
                    'qemu_spice': False,
                    'qemu_stream': False,
                    'screenshot': None,
                    'kernel_vfio': self.kernel_vfio,
                    'nm_running': FeatureTests.is_nm_running(),
                    'mem_hotplug_support': False,
                    'libvirtd_running': False}

        return {'libvirt_stream_protocols': self.libvirt_stream_protocols,
                'qemu_spice': self._qemu_support_spice(),
                'qemu_stream': self.qemu_stream,
                'screenshot': VMScreenshot.get_stream_test_result(),
                'kernel_vfio': self.kernel_vfio,
                'nm_running': FeatureTests.is_nm_running(),
                'mem_hotplug_support': self.mem_hotplug_support,
                'libvirtd_running': True}
Esempio n. 8
0
 def _set_capabilities(self):
     wok_log.info('\n*** Kimchi: Running feature tests ***')
     self.libvirtd_running = is_libvirtd_up()
     wok_log.info(f'Service Libvirtd running ...: {self.libvirtd_running}')
     if not self.libvirtd_running:
         wok_log.info('*** Kimchi: Feature tests not completed ***\n')
         return
     conn = self.conn.get()
     self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
     wok_log.info(f'NFS Target Probe support ...: {self.nfs_target_probe}')
     self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
     wok_log.info(f'Fibre Channel Host support .: {self.fc_host_support}')
     self.kernel_vfio = FeatureTests.kernel_support_vfio()
     wok_log.info(f'Kernel VFIO support ........: {self.kernel_vfio}')
     self.nm_running = FeatureTests.is_nm_running()
     wok_log.info(f'Network Manager running ....: {self.nm_running}')
     self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
     wok_log.info(
         f'Memory Hotplug support .....: {self.mem_hotplug_support}')
     wok_log.info('*** Kimchi: Feature tests completed ***\n')
Esempio n. 9
0
 def _set_capabilities(self):
     wok_log.info('\n*** Kimchi: Running feature tests ***')
     self.libvirtd_running = is_libvirtd_up()
     wok_log.info(f'Service Libvirtd running ...: {self.libvirtd_running}')
     if not self.libvirtd_running:
         wok_log.info('*** Kimchi: Feature tests not completed ***\n')
         return
     conn = self.conn.get()
     self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
     wok_log.info(f'NFS Target Probe support ...: {self.nfs_target_probe}')
     self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
     wok_log.info(f'Fibre Channel Host support .: {self.fc_host_support}')
     self.kernel_vfio = FeatureTests.kernel_support_vfio()
     wok_log.info(f'Kernel VFIO support ........: {self.kernel_vfio}')
     self.nm_running = FeatureTests.is_nm_running()
     wok_log.info(f'Network Manager running ....: {self.nm_running}')
     self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
     wok_log.info(
         f'Memory Hotplug support .....: {self.mem_hotplug_support}')
     wok_log.info('*** Kimchi: Feature tests completed ***\n')
Esempio n. 10
0
    def lookup(self, *ident):
        if not is_libvirtd_up():
            return {
                'libvirt_stream_protocols': [],
                'qemu_spice': False,
                'qemu_stream': False,
                'screenshot': None,
                'kernel_vfio': self.kernel_vfio,
                'nm_running': FeatureTests.is_nm_running(),
                'mem_hotplug_support': False,
                'libvirtd_running': False
            }

        return {
            'libvirt_stream_protocols': self.libvirt_stream_protocols,
            'qemu_spice': self._qemu_support_spice(),
            'qemu_stream': self.qemu_stream,
            'screenshot': VMScreenshot.get_stream_test_result(),
            'kernel_vfio': self.kernel_vfio,
            'nm_running': FeatureTests.is_nm_running(),
            'mem_hotplug_support': self.mem_hotplug_support,
            'libvirtd_running': True
        }
Esempio n. 11
0
    def get(self, conn_id=0):
        """
        Return current connection to libvirt or open a new one.  Wrap all
        callable libvirt methods so we can catch connection errors and handle
        them by restarting the server.
        """
        def wrapMethod(f):
            def wrapper(*args, **kwargs):
                try:
                    ret = f(*args, **kwargs)
                    return ret
                except libvirt.libvirtError as e:
                    edom = e.get_error_domain()
                    ecode = e.get_error_code()
                    EDOMAINS = (libvirt.VIR_FROM_REMOTE,
                                libvirt.VIR_FROM_RPC)
                    ECODES = (libvirt.VIR_ERR_SYSTEM_ERROR,
                              libvirt.VIR_ERR_INTERNAL_ERROR,
                              libvirt.VIR_ERR_NO_CONNECT,
                              libvirt.VIR_ERR_INVALID_CONN)
                    if edom in EDOMAINS and ecode in ECODES:
                        wok_log.error('Connection to libvirt broken. '
                                      'Recycling. ecode: %d edom: %d' %
                                      (ecode, edom))
                        with LibvirtConnection._connectionLock:
                            self._connections[conn_id] = None
                    raise
            wrapper.__name__ = f.__name__
            wrapper.__doc__ = f.__doc__
            return wrapper

        if not is_libvirtd_up():
            wok_log.error('Libvirt service is not active.')
            add_notification('KCHCONN0002E', plugin_name='/plugins/kimchi')
            return None

        with LibvirtConnection._connectionLock:
            conn = self._connections.get(conn_id)
            if not conn:
                retries = 5
                while True:
                    retries = retries - 1
                    try:
                        conn = libvirt.open(self.uri)
                        break
                    except libvirt.libvirtError:
                        wok_log.error('Unable to connect to libvirt.')
                        if not retries:
                            wok_log.error("Unable to establish connection "
                                          "with libvirt. Please check "
                                          "your libvirt URI which is often "
                                          "defined in "
                                          "/etc/libvirt/libvirt.conf")
                            add_notification("KCHCONN0001E",
                                             plugin_name="/plugins/kimchi")
                            return None
                    time.sleep(2)

                for name in dir(libvirt.virConnect):
                    method = getattr(conn, name)
                    if callable(method) and not name.startswith('_'):
                        setattr(conn, name, wrapMethod(method))

                for cls in self.wrappables:
                    for name in dir(cls):
                        method = getattr(cls, name)
                        if callable(method) and not name.startswith('_'):
                            setattr(cls, name, wrapMethod(method))

                self._connections[conn_id] = conn
                # In case we're running into troubles with keeping the
                # connections alive we should place here:
                # conn.setKeepAlive(interval=5, count=3)
                # However the values need to be considered wisely to not affect
                # hosts which are hosting a lot of virtual machines
            return conn
Esempio n. 12
0
    def get_list(self):
        if not is_libvirtd_up():
            return []

        with self.objstore as session:
            return session.get_list('template')
Esempio n. 13
0
    def get(self, conn_id=0):
        """
        Return current connection to libvirt or open a new one.  Wrap all
        callable libvirt methods so we can catch connection errors and handle
        them by restarting the server.
        """

        def wrapMethod(f):
            def wrapper(*args, **kwargs):
                try:
                    ret = f(*args, **kwargs)
                    return ret
                except libvirt.libvirtError as e:
                    edom = e.get_error_domain()
                    ecode = e.get_error_code()
                    EDOMAINS = (libvirt.VIR_FROM_REMOTE, libvirt.VIR_FROM_RPC)
                    ECODES = (
                        libvirt.VIR_ERR_SYSTEM_ERROR,
                        libvirt.VIR_ERR_INTERNAL_ERROR,
                        libvirt.VIR_ERR_NO_CONNECT,
                        libvirt.VIR_ERR_INVALID_CONN,
                    )
                    if edom in EDOMAINS and ecode in ECODES:
                        wok_log.error(
                            'Connection to libvirt broken. '
                            'Recycling. ecode: %d edom: %d' % (ecode, edom)
                        )
                        with LibvirtConnection._connectionLock:
                            self._connections[conn_id] = None
                    raise

            wrapper.__name__ = f.__name__
            wrapper.__doc__ = f.__doc__
            return wrapper

        if not is_libvirtd_up():
            wok_log.error('Libvirt service is not active.')
            add_notification('KCHCONN0002E', plugin_name='/plugins/kimchi')
            return None
        elif notificationsStore.get('KCHCONN0002E') is not None:
            try:
                del_notification('KCHCONN0002E')
            except Exception:
                # If notification was not found, just ignore
                pass

        with LibvirtConnection._connectionLock:
            conn = self._connections.get(conn_id)
            if not conn:
                conn = self._get_new_connection()

                for name in dir(libvirt.virConnect):
                    method = getattr(conn, name)
                    if callable(method) and not name.startswith('_'):
                        setattr(conn, name, wrapMethod(method))

                for cls in self.wrappables:
                    for name in dir(cls):
                        method = getattr(cls, name)
                        if callable(method) and not name.startswith('_'):
                            setattr(cls, name, wrapMethod(method))

                self._connections[conn_id] = conn
                # In case we're running into troubles with keeping the
                # connections alive we should place here:
                # conn.setKeepAlive(interval=5, count=3)
                # However the values need to be considered wisely to not affect
                # hosts which are hosting a lot of virtual machines
            return conn
Esempio n. 14
0
    def get(self, conn_id=0):
        """
        Return current connection to libvirt or open a new one.  Wrap all
        callable libvirt methods so we can catch connection errors and handle
        them by restarting the server.
        """
        def wrapMethod(f):
            def wrapper(*args, **kwargs):
                try:
                    ret = f(*args, **kwargs)
                    return ret
                except libvirt.libvirtError as e:
                    edom = e.get_error_domain()
                    ecode = e.get_error_code()
                    EDOMAINS = (libvirt.VIR_FROM_REMOTE, libvirt.VIR_FROM_RPC)
                    ECODES = (libvirt.VIR_ERR_SYSTEM_ERROR,
                              libvirt.VIR_ERR_INTERNAL_ERROR,
                              libvirt.VIR_ERR_NO_CONNECT,
                              libvirt.VIR_ERR_INVALID_CONN)
                    if edom in EDOMAINS and ecode in ECODES:
                        wok_log.error('Connection to libvirt broken. '
                                      'Recycling. ecode: %d edom: %d' %
                                      (ecode, edom))
                        with LibvirtConnection._connectionLock:
                            self._connections[conn_id] = None
                    raise

            wrapper.__name__ = f.__name__
            wrapper.__doc__ = f.__doc__
            return wrapper

        if not is_libvirtd_up():
            wok_log.error('Libvirt service is not active.')
            add_notification('KCHCONN0002E', plugin_name='/plugins/kimchi')
            return None

        with LibvirtConnection._connectionLock:
            conn = self._connections.get(conn_id)
            if not conn:
                retries = 5
                while True:
                    retries = retries - 1
                    try:
                        conn = libvirt.open(self.uri)
                        break
                    except libvirt.libvirtError:
                        wok_log.error('Unable to connect to libvirt.')
                        if not retries:
                            wok_log.error("Unable to establish connection "
                                          "with libvirt. Please check "
                                          "your libvirt URI which is often "
                                          "defined in "
                                          "/etc/libvirt/libvirt.conf")
                            add_notification("KCHCONN0001E",
                                             plugin_name="/plugins/kimchi")
                            return None
                    time.sleep(2)

                for name in dir(libvirt.virConnect):
                    method = getattr(conn, name)
                    if callable(method) and not name.startswith('_'):
                        setattr(conn, name, wrapMethod(method))

                for cls in self.wrappables:
                    for name in dir(cls):
                        method = getattr(cls, name)
                        if callable(method) and not name.startswith('_'):
                            setattr(cls, name, wrapMethod(method))

                self._connections[conn_id] = conn
                # In case we're running into troubles with keeping the
                # connections alive we should place here:
                # conn.setKeepAlive(interval=5, count=3)
                # However the values need to be considered wisely to not affect
                # hosts which are hosting a lot of virtual machines
            return conn