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")
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, }
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, }
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 }
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) wok_log.info("*** Feature tests completed ***")
def _set_depend_capabilities(self): wok_log.info("*** Running dependable feature tests ***") conn = self.conn.get() self.qemu_stream = FeatureTests.qemu_supports_iso_stream() self.libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): self.libvirt_stream_protocols.append(p) wok_log.info("*** Dependable feature tests completed ***")
def _set_depend_capabilities(self): wok_log.info("\n*** Kimchi: Running dependable feature tests ***") conn = self.conn.get() self.qemu_stream = FeatureTests.qemu_supports_iso_stream() msg = "QEMU stream support .......: %s" wok_log.info(msg % str(self.qemu_stream)) self.libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): self.libvirt_stream_protocols.append(p) msg = "Libvirt Stream Protocols ..: %s" wok_log.info(msg % str(self.libvirt_stream_protocols)) wok_log.info("*** Kimchi: Dependable feature tests completed ***\n")
def test_customized_network(self): # Create a template t = {'name': 'test', 'cdrom': '/tmp/mock.iso'} req = json.dumps(t) resp = self.request('/plugins/kimchi/templates', req, 'POST') self.assertEquals(201, resp.status) # Create networks to be used for testing networks = [{'name': u'kīмсhī-пet', 'connection': 'isolated'}, {'name': u'nat-network', 'connection': 'nat'}, {'name': u'subnet-network', 'connection': 'nat', 'subnet': '127.0.100.0/24'}] # Verify the current system has at least one interface to create a # bridged network interfaces = json.loads( self.request('/plugins/kimchi/interfaces?type=nic').read() ) if len(interfaces) > 0: iface = interfaces[0]['name'] networks.append({'name': u'bridge-network', 'connection': 'macvtap', 'interfaces': [iface]}) if not FeatureTests.is_nm_running(): networks.append({'name': u'bridge-network-with-vlan', 'connection': 'bridge', 'interfaces': [iface], 'vlan_id': 987}) tmpl_nets = [] for net in networks: self.request('/plugins/kimchi/networks', json.dumps(net), 'POST') tmpl_nets.append(net['name']) req = json.dumps({'networks': tmpl_nets}) resp = self.request('/plugins/kimchi/templates/test', req, 'PUT') self.assertEquals(200, resp.status)
def lookup(self, *ident): report_tool = DebugReportsModel.get_system_report_tool() try: SoftwareUpdate() except Exception: update_tool = False else: update_tool = True try: repo = Repositories() except Exception: repo_mngt_tool = None else: repo_mngt_tool = repo._pkg_mnger.TYPE 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(), 'system_report_tool': bool(report_tool), 'update_tool': update_tool, 'repo_mngt_tool': repo_mngt_tool, 'federation': kconfig.get("server", "federation"), 'auth': kconfig.get("authentication", "method"), 'kernel_vfio': self.kernel_vfio, 'nm_running': FeatureTests.is_nm_running(), 'mem_hotplug_support': self.mem_hotplug_support }
def _set_network_bridge(self, params): params['forward'] = {'mode': 'bridge'} # Bridges cannot be the trunk device of a VLAN iface = params['interfaces'][0] if 'vlan_id' in params and netinfo.is_bridge(iface): raise InvalidParameter('KCHNET0019E', {'name': iface}) # User specified bridge interface, simply use it self._ensure_iface_up(iface) params['ovs'] = False if netinfo.is_bridge(iface): params['bridge'] = iface if netinfo.is_ovs_bridge(iface): params['ovs'] = True # connection == macvtap and iface is not bridge elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface): # libvirt bridge creation will fail with NetworkManager enabled if FeatureTests.is_nm_running(): raise InvalidParameter('KCHNET0027E') if 'vlan_id' in params: params['bridge'] = \ self._create_vlan_tagged_bridge(str(iface), str(params['vlan_id'])) else: # create Linux bridge interface and use it as actual iface iface = self._create_linux_bridge(iface) params['bridge'] = iface # unrecognized interface type: fail else: raise InvalidParameter("KCHNET0007E")
def test_network_lifecycle(self): # Verify all the supported network type networks = [{ 'name': u'kīмсhī-пet', 'connection': 'isolated' }, { 'name': u'<!nat-network>&', 'connection': 'nat' }, { 'name': u'subnet-network', 'connection': 'nat', 'subnet': '127.0.100.0/24' }] # Verify the current system has at least one interface to create a # bridged network interfaces = json.loads( self.request( '/plugins/kimchi/interfaces?_inuse=false&type=nic').read()) if len(interfaces) > 0: iface = interfaces[0]['name'] networks.append({ 'name': u'macvtap-network', 'connection': 'macvtap', 'interfaces': [iface] }) if not FeatureTests.is_nm_running(): networks.append({ 'name': u'bridge-network', 'connection': 'bridge', 'interfaces': [iface] }) for net in networks: _do_network_test(self, model, net)
class MockNetworkTests(unittest.TestCase): def setUp(self): self.request = partial(request) model.reset() @unittest.skipIf( FeatureTests.is_nm_running(), 'test_vlan_tag_bridge skipped because Network ' 'Manager is running.', ) def test_vlan_tag_bridge(self): # Verify the current system has at least one interface to create a # bridged network interfaces = json.loads( self.request('/plugins/kimchi/interfaces?_inuse=false&type=nic'). read().decode('utf-8')) if len(interfaces) > 0: iface = interfaces[0]['name'] _do_network_test( self, model, { 'name': u'vlan-tagged-bridge', 'connection': 'bridge', 'interface': iface, 'vlan_id': 987, }, )
def _set_depend_capabilities(self): wok_log.info('\n*** Kimchi: Running dependable feature tests ***') conn = self.conn.get() if conn is None: wok_log.info( '*** Kimchi: Dependable feature tests not completed ' '***\n') return self.qemu_stream = FeatureTests.qemu_supports_iso_stream() wok_log.info(f'QEMU stream support .......: {self.qemu_stream}') self.libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): self.libvirt_stream_protocols.append(p) wok_log.info( f'Libvirt Stream Protocols ..: {self.libvirt_stream_protocols}') wok_log.info('*** Kimchi: Dependable feature tests completed ***\n')
def _set_depend_capabilities(self): wok_log.info('\n*** Kimchi: Running dependable feature tests ***') conn = self.conn.get() if conn is None: wok_log.info('*** Kimchi: Dependable feature tests not completed ' '***\n') return self.qemu_stream = FeatureTests.qemu_supports_iso_stream() wok_log.info(f'QEMU stream support .......: {self.qemu_stream}') self.libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): self.libvirt_stream_protocols.append(p) wok_log.info( f'Libvirt Stream Protocols ..: {self.libvirt_stream_protocols}') wok_log.info('*** Kimchi: Dependable feature tests completed ***\n')
def lookup(self, *ident): 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}
def _clean_leftovers(self): conn = self.conn.get() FeatureTests.disable_libvirt_error_logging() try: dom = conn.lookupByName(FEATURETEST_VM_NAME) dom.undefine() except Exception: # Any exception can be ignored here pass try: pool = conn.storagePoolLookupByName(FEATURETEST_POOL_NAME) pool.undefine() except Exception: # Any exception can be ignored here pass FeatureTests.enable_libvirt_error_logging()
def test_customized_network(self): # Create a template t = { 'name': 'test', 'source_media': { 'type': 'disk', 'path': MOCK_ISO } } req = json.dumps(t) resp = self.request('/plugins/kimchi/templates', req, 'POST') self.assertEqual(201, resp.status) # Create networks to be used for testing networks = [ { 'name': 'kīмсhī-пet', 'connection': 'isolated' }, { 'name': 'nat-network', 'connection': 'nat' }, { 'name': 'subnet-network', 'connection': 'nat', 'subnet': '127.0.100.0/24' }, ] # Verify the current system has at least one interface to create a # bridged network interfaces = json.loads( self.request( '/plugins/kimchi/interfaces?_inuse=false&type=nic').read()) if len(interfaces) > 0: iface = interfaces[0]['name'] networks.append({ 'name': 'bridge-network', 'connection': 'macvtap', 'interfaces': [iface], }) if not FeatureTests.is_nm_running(): networks.append({ 'name': 'bridge-network-with-vlan', 'connection': 'bridge', 'interfaces': [iface], 'vlan_id': 987, }) tmpl_nets = [] for net in networks: self.request('/plugins/kimchi/networks', json.dumps(net), 'POST') tmpl_nets.append(net['name']) req = json.dumps({'networks': tmpl_nets}) resp = self.request('/plugins/kimchi/templates/test', req, 'PUT') self.assertEqual(200, resp.status)
def lookup(self, *ident): 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 }
def lookup(self, *ident): 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, }
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')
def lookup(self, *ident): 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(), 'federation': kconfig.get("server", "federation"), 'auth': kconfig.get("authentication", "method"), 'kernel_vfio': self.kernel_vfio, 'nm_running': FeatureTests.is_nm_running(), 'mem_hotplug_support': self.mem_hotplug_support }
def lookup(self, *ident): 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(), 'federation': kconfig.get("server", "federation"), 'auth': kconfig.get("authentication", "method"), 'kernel_vfio': self.kernel_vfio, 'nm_running': FeatureTests.is_nm_running(), 'mem_hotplug_support': self.mem_hotplug_support }
def _set_capabilities(self): wok_log.info("*** Running feature tests ***") conn = self.conn.get() self.qemu_stream = FeatureTests.qemu_supports_iso_stream() 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.libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): self.libvirt_stream_protocols.append(p) wok_log.info("*** Feature tests completed ***")
def _set_capabilities(conn=False): debug("Running feature tests. This can take a while.", True) if not conn: return qemu_stream = FeatureTests.qemu_supports_iso_stream() nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn) fc_host_support = FeatureTests.libvirt_support_fc_host(conn) kernel_vfio = FeatureTests.kernel_support_vfio() nm_running = FeatureTests.is_nm_running() mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn) libvirt_stream_protocols = [] for p in ['http', 'https', 'ftp', 'ftps', 'tftp']: if FeatureTests.libvirt_supports_iso_stream(conn, p): libvirt_stream_protocols.append(p) debug("Feature tests completed.", True)
def test_network_lifecycle(self): # Verify all the supported network type networks = [{'name': u'kīмсhī-пet', 'connection': 'isolated'}, {'name': u'<!nat-network>&', 'connection': 'nat'}, {'name': u'subnet-network', 'connection': 'nat', 'subnet': '127.0.100.0/24'}] # Verify the current system has at least one interface to create a # bridged network interfaces = json.loads( self.request( '/plugins/kimchi/interfaces?_inuse=false&type=nic').read()) if len(interfaces) > 0: iface = interfaces[0]['name'] networks.append({'name': u'macvtap-network', 'connection': 'macvtap', 'interfaces': [iface]}) if not FeatureTests.is_nm_running(): networks.append({'name': u'bridge-network', 'connection': 'bridge', 'interfaces': [iface]}) for net in networks: _do_network_test(self, model, net)