Skip to content

Commit 0c1e4be

Browse files
committed
Renaming pci_device_typ to pci_device_class to be more helpful.
Signed-off-by: Rob Dobson <rob.dobson@citrix.com>
1 parent 083face commit 0c1e4be

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

hwinfo/pci/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def get_pci_id(self):
5656
self.lookup_value('pci_subdevice_id'),
5757
)
5858

59+
def get_pci_class(self):
60+
return self.lookup_value('pci_device_class')
61+
5962
def is_subdevice(self):
6063
return self.lookup_value('pci_subvendor_id') and self.lookup_value('pci_subdevice_id')
6164

hwinfo/pci/lspci.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class LspciVVParser(CommandParser):
99
"""Parser object for the output of lspci -vv"""
1010

1111
ITEM_REGEXS = [
12-
r'(?P<pci_device_bus_id>([0-9][0-9]:[0-9][0-9]\.[0-9]))\ (?P<pci_device_type>[\w\ ]*):\ (?P<pci_device_string>(.*))\n',
12+
r'(?P<pci_device_bus_id>([0-9][0-9]:[0-9][0-9]\.[0-9]))\ (?P<pci_device_class_name>[\w\ ]*):\ (?P<pci_device_string>(.*))\n',
1313
r'Product\ Name:\ (?P<pci_device_vpd_product_name>(.)*)\n',
1414
r'Subsystem:\ (?P<pci_device_sub_string>(.)*)\n',
1515
]
@@ -18,7 +18,7 @@ class LspciVVParser(CommandParser):
1818

1919
MUST_HAVE_FIELDS = [
2020
'pci_device_bus_id',
21-
'pci_device_type',
21+
'pci_device_class_name',
2222
'pci_device_string',
2323
]
2424

@@ -27,7 +27,7 @@ class LspciNParser(CommandParser):
2727

2828
#ff:0d.1 0880: 8086:0ee3 (rev 04)
2929
ITEM_REGEXS = [
30-
r'(?P<pci_device_bus_id>([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]\.[0-9a-f]))\ (?P<pci_device_type_id>[0-9a-f]{4}):\ (?P<pci_vendor_id>[0-9a-f]{4}):(?P<pci_device_id>[0-9a-f]{4})',
30+
r'(?P<pci_device_bus_id>([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]\.[0-9a-f]))\ (?P<pci_device_class>[0-9a-f]{4}):\ (?P<pci_vendor_id>[0-9a-f]{4}):(?P<pci_device_id>[0-9a-f]{4})',
3131
]
3232

3333
ITEM_SEPERATOR = "\n"
@@ -36,7 +36,7 @@ class LspciNParser(CommandParser):
3636
'pci_device_bus_id',
3737
'pci_device_id',
3838
'pci_vendor_id',
39-
'pci_device_type_id',
39+
'pci_device_class',
4040
]
4141

4242

@@ -49,7 +49,7 @@ class LspciNNMMParser(CommandParser):
4949
#02:00.1 "Ethernet controller [0200]" "Broadcom Corporation [14e4]" "NetXtreme II BCM5716 Gigabit Ethernet [163b]" -r20 "Dell [1028]" "Device [02a3]"
5050

5151
ITEM_REGEXS = [
52-
r'(?P<pci_device_bus_id>([0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]))\ "(?P<pci_device_type_name>' + LABEL_REGEX + r')\ \[(?P<pci_device_type_id>' + CODE_REGEX + r')\]"' \
52+
r'(?P<pci_device_bus_id>([0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]))\ "(?P<pci_device_class_name>' + LABEL_REGEX + r')\ \[(?P<pci_device_class>' + CODE_REGEX + r')\]"' \
5353
+ r'\ "(?P<pci_vendor_name>' + LABEL_REGEX + r')\ \[(?P<pci_vendor_id>' + CODE_REGEX + r')\]"\ "(?P<pci_device_name>' + LABEL_REGEX + r')\ \[(?P<pci_device_id>' + CODE_REGEX + r')\]"' \
5454
+ r'\ .*\ "((?P<pci_subvendor_name>' + LABEL_REGEX + r')\ \[(?P<pci_subvendor_id>' + CODE_REGEX + r')\])*"\ "((?P<pci_subdevice_name>' + LABEL_REGEX + r')\ \[(?P<pci_subdevice_id>' + CODE_REGEX + r')\])*',
5555
]

hwinfo/pci/tests/test_lspci.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class TestSingleDeviceVVParse(unittest.TestCase):
1212

1313
DEVICE_REC = {
1414
'pci_device_string': 'Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet (rev 20)',
15-
'pci_device_type': 'Ethernet controller',
15+
'pci_device_class': '0200',
16+
'pci_device_class_name': 'Ethernet controller',
1617
'pci_device_bus_id': '02:00.0',
1718
'pci_device_sub_string': 'Dell Device 0488',
1819
'pci_device_vpd_product_name': 'Broadcom NetXtreme II Ethernet Controller',
@@ -36,9 +37,9 @@ def test_pci_device_bus_id(self):
3637
rec = self.parser.parse_items().pop()
3738
self._assert_rec_key(rec, 'pci_device_bus_id')
3839

39-
def test_pci_device_type(self):
40+
def test_pci_device_class_name(self):
4041
rec = self.parser.parse_items().pop()
41-
self._assert_rec_key(rec, 'pci_device_type')
42+
self._assert_rec_key(rec, 'pci_device_class_name')
4243

4344
def test_pci_device_sub_string(self):
4445
rec = self.parser.parse_items().pop()
@@ -70,7 +71,7 @@ class TestSingleDeviceNParse(unittest.TestCase):
7071
'pci_device_bus_id': 'ff:10.5',
7172
'pci_vendor_id': '8086',
7273
'pci_device_id': '0eb5',
73-
'pci_device_type_id': '0880',
74+
'pci_device_class': '0880',
7475
}
7576

7677
def setUp(self):
@@ -89,8 +90,8 @@ def test_pci_vendor_id(self):
8990
def test_pci_device_id(self):
9091
self._assert_rec_key('pci_device_id')
9192

92-
def test_pci_device_type_id(self):
93-
self._assert_rec_key('pci_device_type_id')
93+
def test_pci_device_class(self):
94+
self._assert_rec_key('pci_device_class')
9495

9596
class TestMultiDeviceNParse(unittest.TestCase):
9697

@@ -113,8 +114,8 @@ class TestSingleDeviceNNMMParse(unittest.TestCase):
113114

114115
DEVICE_REC = {
115116
'pci_device_bus_id': '02:00.0',
116-
'pci_device_type_id': '0200',
117-
'pci_device_type_name': 'Ethernet controller',
117+
'pci_device_class': '0200',
118+
'pci_device_class_name': 'Ethernet controller',
118119
'pci_vendor_name': 'Broadcom Corporation',
119120
'pci_vendor_id': '14e4',
120121
'pci_device_id': '163b',
@@ -135,11 +136,11 @@ def _assert_rec_key(self, key):
135136
def test_pci_device_bus_id(self):
136137
self._assert_rec_key('pci_device_bus_id')
137138

138-
def test_pci_device_type_id(self):
139-
self._assert_rec_key('pci_device_type_id')
139+
def test_pci_device_class(self):
140+
self._assert_rec_key('pci_device_class')
140141

141-
def test_pci_device_type_name(self):
142-
self._assert_rec_key('pci_device_type_name')
142+
def test_pci_device_class_name(self):
143+
self._assert_rec_key('pci_device_class_name')
143144

144145
def test_pci_vendor_name(self):
145146
self._assert_rec_key('pci_vendor_name')
@@ -168,8 +169,8 @@ class LsiDeviceParse(TestSingleDeviceNNMMParse):
168169

169170
DEVICE_REC = {
170171
'pci_device_bus_id': '03:00.0',
171-
'pci_device_type_id': '0100',
172-
'pci_device_type_name': 'SCSI storage controller',
172+
'pci_device_class': '0100',
173+
'pci_device_class_name': 'SCSI storage controller',
173174
'pci_vendor_name': 'LSI Logic / Symbios Logic',
174175
'pci_vendor_id': '1000',
175176
'pci_device_id': '0058',
@@ -187,8 +188,8 @@ class IntelUSBControllerDeviceParse(TestSingleDeviceNNMMParse):
187188

188189
DEVICE_REC = {
189190
'pci_device_bus_id': '00:1d.0',
190-
'pci_device_type_id': '0c03',
191-
'pci_device_type_name': 'USB controller',
191+
'pci_device_class': '0c03',
192+
'pci_device_class_name': 'USB controller',
192193
'pci_vendor_name': 'Intel Corporation',
193194
'pci_vendor_id': '8086',
194195
'pci_device_id': '3b34',

hwinfo/pci/tests/test_pci.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class TestPCIDeviceObject(unittest.TestCase):
77

88
DEVICE_REC = {
99
'pci_device_bus_id': '02:00.0',
10-
'pci_device_type_id': '0200',
11-
'pci_device_type_name': 'Ethernet controller',
10+
'pci_device_class': '0200',
11+
'pci_device_class_name': 'Ethernet controller',
1212
'pci_vendor_name': 'Broadcom Corporation',
1313
'pci_vendor_id': '14e4',
1414
'pci_device_id': '163b',
@@ -64,3 +64,7 @@ def test_is_subdevice(self):
6464
def test_get_device_info(self):
6565
info = self.device.get_info()
6666
self.assertEqual(info, 'Dell [Device 02a3] (Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet)')
67+
68+
def test_get_device_class(self):
69+
pci_class = self.device.get_pci_class()
70+
self.assertEqual(pci_class, '0200')

0 commit comments

Comments
 (0)