This commit is contained in:
Cayo Puigdefabregas 2024-09-23 14:14:30 +02:00
parent 756570c7b4
commit d277e6cbaa
1 changed files with 11 additions and 3 deletions

View File

@ -46,13 +46,13 @@ def get_network_cards(child, nets):
if child['id'] == 'network': if child['id'] == 'network':
nets.append(child) nets.append(child)
if child.get('children'): if child.get('children'):
[e(x, nets) for x in child['children']] [get_network_cards(x, nets) for x in child['children']]
def get_mac(lshw): def get_mac(lshw):
# This funcion get the network card integrated in motherboard # This funcion get the network card integrated in motherboard
nets = [] nets = []
get_network_cards(lshw, nets) get_network_cards(json.loads(lshw), nets)
integrate = [x for x in nets if "pci@0000:00:" in x.get('businfo', '')] integrate = [x for x in nets if "pci@0000:00:" in x.get('businfo', '')]
if integrate: if integrate:
@ -130,8 +130,16 @@ class Build:
chassis = self.get_chassis_dh() chassis = self.get_chassis_dh()
serial_number = self.dmi.serial_number() serial_number = self.dmi.serial_number()
sku = self.get_sku() sku = self.get_sku()
if not snapshot["data"].get('hwinfo'):
return f"{manufacturer}{model}{chassis}{serial_number}{sku}"
if not snapshot["data"].get('lshw'):
return f"{manufacturer}{model}{chassis}{serial_number}{sku}"
hwinfo_raw = snapshot["data"]["hwinfo"] hwinfo_raw = snapshot["data"]["hwinfo"]
mac = get_mac(hwinfo_raw) or "" lshw = snapshot["data"]["lshw"]
# mac = get_mac2(hwinfo_raw) or ""
mac = get_mac(lshw) or ""
if not mac: if not mac:
print("WARNING!! No there are MAC address") print("WARNING!! No there are MAC address")
else: else: