diff --git a/hwinfo/pci/lspci.py b/hwinfo/pci/lspci.py index 4e2d0ba..465a289 100644 --- a/hwinfo/pci/lspci.py +++ b/hwinfo/pci/lspci.py @@ -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]' diff --git a/hwinfo/pci/tests/test_lspci.py b/hwinfo/pci/tests/test_lspci.py index 3b28848..57ee928 100644 --- a/hwinfo/pci/tests/test_lspci.py +++ b/hwinfo/pci/tests/test_lspci.py @@ -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 diff --git a/hwinfo/tools/inspector.py b/hwinfo/tools/inspector.py index 7f7b748..4b3eb1c 100644 --- a/hwinfo/tools/inspector.py +++ b/hwinfo/tools/inspector.py @@ -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): diff --git a/hwinfo/tools/tests/test_inspector.py b/hwinfo/tools/tests/test_inspector.py index 3362fda..16b9da7 100644 --- a/hwinfo/tools/tests/test_inspector.py +++ b/hwinfo/tools/tests/test_inspector.py @@ -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']) @@ -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) diff --git a/setup.py b/setup.py index 4527276..603e206 100644 --- a/setup.py +++ b/setup.py @@ -19,5 +19,6 @@ install_requires = [ 'paramiko', 'prettytable', + 'argparse', ], ) diff --git a/tox.ini b/tox.ini index a753882..528163f 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ deps= mock prettytable paramiko + argparse commands= coverage