Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hwinfo/pci/lspci.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ParserException(Exception):
pass

LABEL_REGEX = r'[\w+\ \.\-\/\[\]\(\)]+'
LABEL_REGEX = r'[\w+\ \.\,\+\&\-\/\[\]\(\)]+'
CODE_REGEX = r'[0-9a-fA-F]{4}'
BUSID_REGEX = r'[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]'

Expand Down
18 changes: 18 additions & 0 deletions hwinfo/pci/tests/test_lspci.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,24 @@ class IntelNetDeviceParser(TestSingleDeviceNNMMParse):
'pci_subdevice_id': '05d2',
}

class BrocadeNetDeviceParser(TestSingleDeviceNNMMParse):

SAMPLE_DATA = '0d:00.3 "Ethernet controller [0200]" "Brocade Communications Systems, Inc. [1657]" "1010/1020/1007/1741 10Gbps CNA [0014]" -r01 "Brocade Communications Systems, Inc. [1657]" "1010/1020/1007/1741 10Gbps CNA - LL [0015]"'

DEVICE_REC = {
'pci_device_bus_id': '0d:00.3',
'pci_device_class': '0200',
'pci_device_class_name': 'Ethernet controller',
'pci_vendor_name': 'Brocade Communications Systems, Inc.',
'pci_vendor_id': '1657',
'pci_device_id': '0014',
'pci_device_name': '1010/1020/1007/1741 10Gbps CNA',
'pci_subvendor_name': 'Brocade Communications Systems, Inc.',
'pci_subvendor_id': '1657',
'pci_subdevice_name': '1010/1020/1007/1741 10Gbps CNA - LL',
'pci_subdevice_id': '0015',
}

class TestMultiDeviceNNMMParse(unittest.TestCase):

SAMPLE_FILE = '%s/lspci-nnmm' % DATA_DIR
Expand Down
2 changes: 1 addition & 1 deletion hwinfo/tools/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def pci_filter_for_nics(devices):
return pci_filter(devices, nic_types)

def pci_filter_for_storage(devices):
storage_types = ['00', '01']
storage_types = ['00', '01', '0c04', '0c06']
return pci_filter(devices, storage_types)

def pci_filter_for_gpu(devices):
Expand Down
7 changes: 4 additions & 3 deletions hwinfo/tools/tests/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ def setUp(self):
device_b = mock.MagicMock()
device_c = mock.MagicMock()
device_d = mock.MagicMock()
device_e = mock.MagicMock()

device_a.get_pci_class.return_value = '0230'
device_b.get_pci_class.return_value = '0340'
device_c.get_pci_class.return_value = '0210'
device_d.get_pci_class.return_value = '0100'
device_e.get_pci_class.return_value = '0c04'

self.devices = [device_a, device_b, device_c, device_d]
self.devices = [device_a, device_b, device_c, device_d, device_e]

def test_pci_filter_match_all(self):
devs = inspector.pci_filter(self.devices, ['0'])
Expand All @@ -130,8 +132,7 @@ def test_pci_filter_for_nics(self):

def test_pci_filter_for_storage(self):
devs = inspector.pci_filter_for_storage(self.devices)
self.assertEqual(len(devs), 1)
self.assertEqual(devs[0].get_pci_class(), '0100')
self.assertEqual(len(devs), 2)

def test_pci_filter_for_gpu(self):
devs = inspector.pci_filter_for_gpu(self.devices)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
install_requires = [
'paramiko',
'prettytable',
'argparse',
],
)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ deps=
mock
prettytable
paramiko
argparse

commands=
coverage
Expand Down