Exemplo n.º 1
0
    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())
Exemplo n.º 2
0
    def test_vf(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',
                        'product': 'Virtual Function',
                        'handle': 'PCI:0000:02:00.1',
                        'vendor': 'Intel Corporation',
                        'configuration': {
                            'driver': 'vfio-pci'
                        },
                    }],
                },
            ],
        })

        with mock.patch.object(dpdk.cmd,
                               'exec_sync',
                               return_value=(0, lshw_output, None)):

            dpdk.invalidate_dpdk_devices()
            expected_ports = {}
            assert expected_ports == dpdk.get_dpdk_devices()
Exemplo n.º 3
0
    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'
                    }
                }]
            }]
        })

        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': 'vfio-pci'
                },
                'dpdk1': {
                    'pci_addr': '0000:02:00.2',
                    'driver': 'igb_uio'
                }
            }
            self.assertEqual(expected_ports, dpdk.get_dpdk_devices())