Make hardware_facts.py work with different levels of PCI device trees
This commit is contained in:
parent
37df4f25bb
commit
f779fba01c
955
Manual.html
955
Manual.html
File diff suppressed because it is too large
Load Diff
@ -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)
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user