Skip to content

Commit 9e4e239

Browse files
committed
Merge pull request #12 from rdobson/brocade_hw_fix
Fix parsing to discover Brocade CNAs
2 parents 1e8a0ab + f474f95 commit 9e4e239

File tree

6 files changed

+26
-5
lines changed

6 files changed

+26
-5
lines changed

hwinfo/pci/lspci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class ParserException(Exception):
66
pass
77

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

hwinfo/pci/tests/test_lspci.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,24 @@ class IntelNetDeviceParser(TestSingleDeviceNNMMParse):
280280
'pci_subdevice_id': '05d2',
281281
}
282282

283+
class BrocadeNetDeviceParser(TestSingleDeviceNNMMParse):
284+
285+
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]"'
286+
287+
DEVICE_REC = {
288+
'pci_device_bus_id': '0d:00.3',
289+
'pci_device_class': '0200',
290+
'pci_device_class_name': 'Ethernet controller',
291+
'pci_vendor_name': 'Brocade Communications Systems, Inc.',
292+
'pci_vendor_id': '1657',
293+
'pci_device_id': '0014',
294+
'pci_device_name': '1010/1020/1007/1741 10Gbps CNA',
295+
'pci_subvendor_name': 'Brocade Communications Systems, Inc.',
296+
'pci_subvendor_id': '1657',
297+
'pci_subdevice_name': '1010/1020/1007/1741 10Gbps CNA - LL',
298+
'pci_subdevice_id': '0015',
299+
}
300+
283301
class TestMultiDeviceNNMMParse(unittest.TestCase):
284302

285303
SAMPLE_FILE = '%s/lspci-nnmm' % DATA_DIR

hwinfo/tools/inspector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def pci_filter_for_nics(devices):
170170
return pci_filter(devices, nic_types)
171171

172172
def pci_filter_for_storage(devices):
173-
storage_types = ['00', '01']
173+
storage_types = ['00', '01', '0c04', '0c06']
174174
return pci_filter(devices, storage_types)
175175

176176
def pci_filter_for_gpu(devices):

hwinfo/tools/tests/test_inspector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ def setUp(self):
9797
device_b = mock.MagicMock()
9898
device_c = mock.MagicMock()
9999
device_d = mock.MagicMock()
100+
device_e = mock.MagicMock()
100101

101102
device_a.get_pci_class.return_value = '0230'
102103
device_b.get_pci_class.return_value = '0340'
103104
device_c.get_pci_class.return_value = '0210'
104105
device_d.get_pci_class.return_value = '0100'
106+
device_e.get_pci_class.return_value = '0c04'
105107

106-
self.devices = [device_a, device_b, device_c, device_d]
108+
self.devices = [device_a, device_b, device_c, device_d, device_e]
107109

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

131133
def test_pci_filter_for_storage(self):
132134
devs = inspector.pci_filter_for_storage(self.devices)
133-
self.assertEqual(len(devs), 1)
134-
self.assertEqual(devs[0].get_pci_class(), '0100')
135+
self.assertEqual(len(devs), 2)
135136

136137
def test_pci_filter_for_gpu(self):
137138
devs = inspector.pci_filter_for_gpu(self.devices)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
install_requires = [
2020
'paramiko',
2121
'prettytable',
22+
'argparse',
2223
],
2324
)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ deps=
88
mock
99
prettytable
1010
paramiko
11+
argparse
1112

1213
commands=
1314
coverage

0 commit comments

Comments
 (0)