def test_two_different_dpdk_devices(self): lshw_output = json.dumps({'id': 'fake.redhat.com', 'class': 'system', 'vendor': 'HP', 'serial': 'GB803344A9', 'children': [ {'id': 'core', 'class': 'bus', 'description': 'Motherboard', }, {'id': 'pci:0', 'class': 'bridge', 'handle': 'PCIBUS:0000:00', 'description': 'Host bridge', 'product': '5500 I/O Hub to ESI Port', 'vendor': 'Intel Corporation', 'children': [ {'id': 'network:1', 'class': 'network', 'handle': 'PCI:0000:02:00.1', 'vendor': 'Intel Corporation', 'configuration': { 'driver': 'vfio-pci'}}, {'id': 'network:2', 'class': 'network', 'handle': 'PCI:0000:02:00.2', 'vendor': 'Intel Corporation', 'configuration': { 'driver': 'igb_uio'}}]}]}) with mock.patch.object(dpdk.cmd, 'exec_sync', return_value=(0, lshw_output, None)): dpdk.invalidate_dpdk_devices() expected_ports = { 'dpdk0': {'pci_addr': '0000:02:00.1', 'driver': 'vfio-pci'}, 'dpdk1': {'pci_addr': '0000:02:00.2', 'driver': 'igb_uio'} } self.assertEqual(expected_ports, dpdk.get_dpdk_devices())
def test_two_different_dpdk_devices(self): lshw_output = json.dumps({'id': 'fake.redhat.com', 'class': 'system', 'vendor': 'HP', 'serial': 'GB803344A9', 'children': [ {'id': 'core', 'class': 'bus', 'description': 'Motherboard', }, {'id': 'pci:0', 'class': 'bridge', 'handle': 'PCIBUS:0000:00', 'description': 'Host bridge', 'product': '5500 I/O Hub to ESI Port', 'vendor': 'Intel Corporation', 'children': [ {'id': 'network:1', 'class': 'network', 'handle': 'PCI:0000:02:00.1', 'vendor': 'Intel Corporation', 'configuration': { 'driver': 'vfio-pci'}}, {'id': 'network:2', 'class': 'network', 'handle': 'PCI:0000:02:00.2', 'vendor': 'Intel Corporation', 'configuration': { 'driver': 'igb_uio'}}]}]}) with mock.patch.object(dpdk.cmd, 'exec_sync', return_value=(0, lshw_output, None)): dpdk.invalidate_dpdk_devices() expected_ports = { 'dpdk0': {'pci_addr': '0000:02:00.1', 'driver': 'vfio-pci'}, 'dpdk1': {'pci_addr': '0000:02:00.2', 'driver': 'igb_uio'} } self.assertEqual(expected_ports, dpdk.get_dpdk_devices())
def list(): dpdk_links = (dpdk.link_info(dev_name, dev_info['pci_addr']) for dev_name, dev_info in six.viewitems(dpdk.get_dpdk_devices())) for properties in itertools.chain(link.iter_links(), dpdk_links): if 'type' not in properties: properties['type'] = get_alternative_type(properties['name']) yield properties
def list(): dpdk_links = (dpdk.link_info(dev_name, dev_info['pci_addr']) for dev_name, dev_info in six.viewitems(dpdk.get_dpdk_devices())) for properties in itertools.chain(link.iter_links(), dpdk_links): if 'type' not in properties: properties['type'] = get_alternative_type(properties['name']) yield properties
def _test_one_dpdk_device(self, driver): lshw_output = json.dumps({ 'id': 'fake.redhat.com', 'class': 'system', 'vendor': 'HP', 'serial': 'GB803344A9', 'children': [ { 'id': 'core', 'class': 'bus', 'description': 'Motherboard', }, { 'id': 'pci:0', 'class': 'bridge', 'handle': 'PCIBUS:0000:00', 'description': 'Host bridge', 'product': '5500 I/O Hub to ESI Port', 'vendor': 'Intel Corporation', 'children': [{ 'id': 'network:1', 'class': 'network', 'handle': 'PCI:0000:02:00.1', 'vendor': 'Intel Corporation', 'configuration': { 'driver': driver }, }], }, ], }) mock_exec_sync = mock.patch.object(dpdk.cmd, 'exec_sync', return_value=(0, lshw_output, None)) mock_getboolean = mock.patch.object(dpdk.config, 'getboolean', return_value=True) with mock_exec_sync, mock_getboolean: dpdk.invalidate_dpdk_devices() expected_ports = { 'dpdk0': { 'pci_addr': '0000:02:00.1', 'driver': driver } } self.assertEqual(expected_ports, dpdk.get_dpdk_devices())
def getLinks(): """Return an iterator of Link objects, each per a link in the system.""" dpdk_links = ( dpdk.link_info(dev_name, dev_info['pci_addr']) for dev_name, dev_info in six.viewitems(dpdk.get_dpdk_devices())) for data in itertools.chain(link.iter_links(), dpdk_links): try: yield Link.fromDict(data) except IOError: # If a link goes missing we just don't report it continue
def getLinks(): """Return an iterator of Link objects, each per a link in the system.""" dpdk_links = (dpdk.link_info(dev_name, dev_info['pci_addr']) for dev_name, dev_info in six.viewitems(dpdk.get_dpdk_devices())) for data in itertools.chain(link.iter_links(), dpdk_links): try: yield Link.fromDict(data) except IOError: # If a link goes missing we just don't report it continue
def exists(self): if dpdk.is_dpdk(self._dev): return self._dev in dpdk.get_dpdk_devices() return os.path.exists(os.path.join(NET_PATH, self._dev))