user-panel #9
|
@ -13,24 +13,32 @@ from utils.constants import ALGOS, CHASSIS_DH
|
||||||
def get_mac(hwinfo):
|
def get_mac(hwinfo):
|
||||||
|
|
||||||
low_ix = None
|
low_ix = None
|
||||||
|
lnets = []
|
||||||
|
|
||||||
nets = [x.split("\n") for x in hwinfo.split("\n\n")
|
nets = [x.split("\n") for x in hwinfo.split("\n\n")
|
||||||
if "network interface" in x and "Attached to" in x]
|
if "network interface" in x and "Attached to" in x]
|
||||||
|
|
||||||
for n in nets:
|
for n in nets:
|
||||||
ix = None
|
ix = None
|
||||||
if "Attached to:" in n:
|
mac = None
|
||||||
for v in c.split(" "):
|
for l in n:
|
||||||
if "#" in v:
|
if "Attached to:" in l:
|
||||||
ix = int(v.strip("#"))
|
for v in l.split(" "):
|
||||||
if not low_ix:
|
if "#" in v:
|
||||||
low_ix = ix
|
ix = int(v.strip("#"))
|
||||||
|
if not low_ix:
|
||||||
|
low_ix = ix
|
||||||
|
|
||||||
if "HW Address:" in n:
|
if "HW Address:" in l:
|
||||||
if low_ix <= ix:
|
mac = l.split(" ")[-1]
|
||||||
mac = c.split(" ")[-1]
|
if ix and mac:
|
||||||
print(f"MAC: {mac}")
|
lnets.append((ix, mac))
|
||||||
return mac
|
|
||||||
|
if lnets:
|
||||||
|
lnets.sort()
|
||||||
|
mac = lnets[0][1]
|
||||||
|
print(f"MAC: {mac}")
|
||||||
|
return mac
|
||||||
|
|
||||||
|
|
||||||
class Build:
|
class Build:
|
||||||
|
@ -108,6 +116,5 @@ class Build:
|
||||||
mac = get_mac(hwinfo_raw) or ""
|
mac = get_mac(hwinfo_raw) or ""
|
||||||
if not mac:
|
if not mac:
|
||||||
print("WARNING!! No there are MAC address")
|
print("WARNING!! No there are MAC address")
|
||||||
print(f"{manufacturer}{model}{chassis}{serial_number}{sku}{mac}")
|
|
||||||
|
|
||||||
return f"{manufacturer}{model}{chassis}{serial_number}{sku}{mac}"
|
return f"{manufacturer}{model}{chassis}{serial_number}{sku}{mac}"
|
||||||
|
|
Loading…
Reference in a new issue