minor fix in mac parsing
This commit is contained in:
parent
53000725c7
commit
a0a22e7840
|
@ -22,8 +22,10 @@ def get_mac(lshw):
|
|||
except json.decoder.JSONDecodeError:
|
||||
hw = json.loads(repair_json(lshw))
|
||||
|
||||
networks = []
|
||||
get_lshw_child(hw, networks, 'network')
|
||||
nets = []
|
||||
get_lshw_child(hw, nets, 'network')
|
||||
|
||||
nets_sorted = sorted(nets, key=lambda x: x['businfo'])
|
||||
|
||||
if nets_sorted:
|
||||
mac = nets_sorted[0]['serial']
|
||||
|
@ -31,36 +33,6 @@ def get_mac(lshw):
|
|||
return mac
|
||||
|
||||
|
||||
def get_network_cards(child, nets):
|
||||
if child['id'] == 'network' and "PCI:" in child.get("businfo"):
|
||||
nets.append(child)
|
||||
if child.get('children'):
|
||||
[get_network_cards(x, nets) for x in child['children']]
|
||||
|
||||
|
||||
def get_mac(lshw):
|
||||
nets = []
|
||||
try:
|
||||
if type(lshw) is dict:
|
||||
hw = lshw
|
||||
else:
|
||||
hw = json.loads(lshw)
|
||||
except json.decoder.JSONDecodeError:
|
||||
hw = json.loads(repair_json(lshw))
|
||||
|
||||
try:
|
||||
get_network_cards(hw, nets)
|
||||
except Exception as ss:
|
||||
logger.warning("%s", ss)
|
||||
return
|
||||
|
||||
nets_sorted = sorted(nets, key=lambda x: x['businfo'])
|
||||
# This funcion get the network card integrated in motherboard
|
||||
# integrate = [x for x in nets if "pci@0000:00:" in x.get('businfo', '')]
|
||||
|
||||
if nets_sorted:
|
||||
return nets_sorted[0]['serial']
|
||||
|
||||
|
||||
class Build:
|
||||
def __init__(self, evidence_json, user, check=False):
|
||||
|
|
Loading…
Reference in a new issue