Make hardware_facts.py work with different levels of PCI device trees

This commit is contained in:
Alexander Grothe 2018-04-20 11:47:18 +02:00
parent 37df4f25bb
commit f779fba01c
3 changed files with 486 additions and 475 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4617,6 +4617,7 @@ import os
import sys import sys
import usb.core import usb.core
from collections import namedtuple from collections import namedtuple
from itertools import chain
import kmodpy import kmodpy
from ansible.module_utils.basic import * from ansible.module_utils.basic import *
@ -4632,7 +4633,7 @@ vendor_dict = {
} }
def get_pci_devices(): def get_pci_devices():
for device in glob.glob('/sys/devices/pci*/*:*:*/'): for device in chain(glob.glob('/sys/devices/pci*/*:*:*/'), glob.glob('/sys/devices/pci*/*:*:*/*:*:*/')):
try: try:
with open(os.path.join(device, 'device')) as d: with open(os.path.join(device, 'device')) as d:
product_id = int(d.read().strip(), 16) product_id = int(d.read().strip(), 16)

View File

@ -66,6 +66,7 @@ import os
import sys import sys
import usb.core import usb.core
from collections import namedtuple from collections import namedtuple
from itertools import chain
import kmodpy import kmodpy
from ansible.module_utils.basic import * from ansible.module_utils.basic import *
@ -81,7 +82,7 @@ vendor_dict = {
} }
def get_pci_devices(): def get_pci_devices():
for device in glob.glob('/sys/devices/pci*/*:*:*/'): for device in chain(glob.glob('/sys/devices/pci*/*:*:*/'), glob.glob('/sys/devices/pci*/*:*:*/*:*:*/')):
try: try:
with open(os.path.join(device, 'device')) as d: with open(os.path.join(device, 'device')) as d:
product_id = int(d.read().strip(), 16) product_id = int(d.read().strip(), 16)