Fix listing of pci cards and gpu filtering
This commit is contained in:
parent
fbd5e88f64
commit
12df1cba57
4648
Manual.html
4648
Manual.html
File diff suppressed because it is too large
Load Diff
14
Manual.org
14
Manual.org
@ -4163,8 +4163,16 @@ from ansible.module_utils.basic import *
|
||||
|
||||
PCIDevice = namedtuple("PCIDevice", 'idVendor idProduct idClass pciPath')
|
||||
|
||||
vendor_dict = {
|
||||
0x10de: 'nvidia',
|
||||
0x8086: 'intel',
|
||||
0x1002: 'amd',
|
||||
0x80ee: 'virtualbox',
|
||||
}
|
||||
|
||||
def get_pci_devices():
|
||||
for device in glob.glob('/sys/devices/pci*/*:*:*/'):
|
||||
for device in glob.glob('/sys/devices/pci*/*:*:*/*:*:*/'):
|
||||
try:
|
||||
with open(os.path.join(device, 'device')) as d:
|
||||
product_id = int(d.read().strip(), 16)
|
||||
with open(os.path.join(device, 'vendor')) as d:
|
||||
@ -4172,6 +4180,8 @@ def get_pci_devices():
|
||||
with open(os.path.join(device, 'class')) as d:
|
||||
class_id = int(d.read().strip(), 16)
|
||||
yield PCIDevice(idVendor=vendor_id, idProduct=product_id, idClass=class_id, pciPath=device)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
def format_device_list(iterator):
|
||||
return ["{:04x}:{:04x}".format(d.idVendor, d.idProduct) for d in iterator]
|
||||
@ -4180,7 +4190,7 @@ def format_gpu_device_list(iterator):
|
||||
def get_entries(iterator):
|
||||
for d in iterator:
|
||||
if d.idClass == 0x030000:
|
||||
yield ("{:04x}:{:04x}".format(d.idVendor, d.idProduct))
|
||||
yield (vendor_dict.get(d.id_Vendor, "unknown"), "{:04x}:{:04x}".format(d.idVendor, d.idProduct))
|
||||
return [entry for entry in get_entries(iterator)]
|
||||
|
||||
arg_specs = {
|
||||
|
@ -66,8 +66,16 @@ from ansible.module_utils.basic import *
|
||||
|
||||
PCIDevice = namedtuple("PCIDevice", 'idVendor idProduct idClass pciPath')
|
||||
|
||||
vendor_dict = {
|
||||
0x10de: 'nvidia',
|
||||
0x8086: 'intel',
|
||||
0x1002: 'amd',
|
||||
0x80ee: 'virtualbox',
|
||||
}
|
||||
|
||||
def get_pci_devices():
|
||||
for device in glob.glob('/sys/devices/pci*/*:*:*/'):
|
||||
for device in glob.glob('/sys/devices/pci*/*:*:*/*:*:*/'):
|
||||
try:
|
||||
with open(os.path.join(device, 'device')) as d:
|
||||
product_id = int(d.read().strip(), 16)
|
||||
with open(os.path.join(device, 'vendor')) as d:
|
||||
@ -75,6 +83,8 @@ def get_pci_devices():
|
||||
with open(os.path.join(device, 'class')) as d:
|
||||
class_id = int(d.read().strip(), 16)
|
||||
yield PCIDevice(idVendor=vendor_id, idProduct=product_id, idClass=class_id, pciPath=device)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
def format_device_list(iterator):
|
||||
return ["{:04x}:{:04x}".format(d.idVendor, d.idProduct) for d in iterator]
|
||||
@ -83,7 +93,7 @@ def format_gpu_device_list(iterator):
|
||||
def get_entries(iterator):
|
||||
for d in iterator:
|
||||
if d.idClass == 0x030000:
|
||||
yield ("{:04x}:{:04x}".format(d.idVendor, d.idProduct))
|
||||
yield (vendor_dict.get(d.id_Vendor, "unknown"), "{:04x}:{:04x}".format(d.idVendor, d.idProduct))
|
||||
return [entry for entry in get_entries(iterator)]
|
||||
|
||||
arg_specs = {
|
||||
|
Loading…
Reference in New Issue
Block a user