Extend system check to display MAC, hostname, and link status
_parse_network_data now returns mac, hostname, and link_status extracted from the Redfish EthernetInterfaces/1 response (MACAddress, HostName, LinkStatus fields confirmed present in live IOM output). _print_results gains a second table — Interface Details (IOM | MAC | Hostname) — between the Network Settings and Firmware Versions tables. Network Settings table drops the redundant Origin column and adds Link Status instead. Both _check_via_serial and _check_via_network updated to unpack and pass the additional fields. fetch_current_config in workflow_serial.py also updated to use the same address-parsing logic and trimmed table layout. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,13 +29,15 @@ from ui import (
|
||||
|
||||
def _parse_network_data(data: dict) -> tuple:
|
||||
"""
|
||||
Extract (dhcp_enabled, ip, gateway, netmask, origin) from a
|
||||
Redfish EthernetInterfaces/1 response dict.
|
||||
Extract network details from a Redfish EthernetInterfaces/1 response dict.
|
||||
Returns (dhcp_enabled, ip, gateway, netmask, mac, hostname, link_status).
|
||||
"""
|
||||
dhcp_enabled = (
|
||||
data.get("DHCPv4", {}).get("DHCPEnabled", False) or
|
||||
data.get("DHCPv6", {}).get("DHCPEnabled", False)
|
||||
)
|
||||
|
||||
# Prefer IPv4StaticAddresses; fall back to IPv4Addresses
|
||||
addrs = data.get("IPv4StaticAddresses") or data.get("IPv4Addresses", [])
|
||||
if addrs:
|
||||
addr = addrs[0]
|
||||
@@ -45,20 +47,34 @@ def _parse_network_data(data: dict) -> tuple:
|
||||
else:
|
||||
ip = gateway = netmask = "--"
|
||||
|
||||
origin = (
|
||||
data.get("IPv4Addresses", [{}])[0].get("AddressOrigin", "Unknown")
|
||||
if data.get("IPv4Addresses")
|
||||
else ("DHCP" if dhcp_enabled else "Static")
|
||||
)
|
||||
return dhcp_enabled, ip, gateway, netmask, origin
|
||||
mac = data.get("MACAddress", "--")
|
||||
hostname = data.get("HostName", "--")
|
||||
link_status = data.get("LinkStatus", "--")
|
||||
|
||||
return dhcp_enabled, ip, gateway, netmask, mac, hostname, link_status
|
||||
|
||||
|
||||
def _print_results(net_rows: list, fw_rows: list):
|
||||
def _print_results(net_rows: list, iface_rows: list, fw_rows: list):
|
||||
"""
|
||||
Display network settings, interface identity, and firmware versions.
|
||||
|
||||
net_rows: [IOM, Mode, IP Address, Gateway, Subnet Mask, Link Status]
|
||||
iface_rows: [IOM, MAC Address, Hostname]
|
||||
fw_rows: [IOM, IOM Firmware, Fabric Firmware]
|
||||
"""
|
||||
rule("Network Settings")
|
||||
draw_table(
|
||||
["IOM", "Mode", "Origin", "IP Address", "Gateway", "Subnet Mask"],
|
||||
["IOM", "Mode", "IP Address", "Gateway", "Subnet Mask", "Link"],
|
||||
net_rows,
|
||||
[5, 10, 8, 16, 16, 16],
|
||||
[5, 8, 15, 15, 15, 8],
|
||||
)
|
||||
print()
|
||||
|
||||
rule("Interface Details")
|
||||
draw_table(
|
||||
["IOM", "MAC Address", "Hostname"],
|
||||
iface_rows,
|
||||
[5, 19, 42],
|
||||
)
|
||||
print()
|
||||
|
||||
@@ -108,11 +124,13 @@ def _check_via_serial():
|
||||
"/redfish/v1/Managers/IOM1/EthernetInterfaces/1",
|
||||
)
|
||||
if net_ok and isinstance(net_data, dict):
|
||||
dhcp, ip, gw, nm, origin = _parse_network_data(net_data)
|
||||
dhcp, ip, gw, nm, mac, hostname, link = _parse_network_data(net_data)
|
||||
mode = _c(C.CYN, "DHCP") if dhcp else _c(C.GRN, "Static")
|
||||
net_rows = [["IOM1", mode, origin, ip, gw, nm]]
|
||||
net_rows = [["IOM1", mode, ip, gw, nm, link]]
|
||||
iface_rows = [["IOM1", mac, hostname]]
|
||||
else:
|
||||
net_rows = [["IOM1", _c(C.RED, "No response"), "--", "--", "--", "--"]]
|
||||
net_rows = [["IOM1", _c(C.RED, "No response"), "--", "--", "--", "--"]]
|
||||
iface_rows = [["IOM1", "--", "--"]]
|
||||
error(f"IOM1 network query failed: {net_data}")
|
||||
|
||||
# ── IOM firmware version ───────────────────────────────────────────────────
|
||||
@@ -139,7 +157,7 @@ def _check_via_serial():
|
||||
else _c(C.RED, "Unreachable")
|
||||
)
|
||||
|
||||
_print_results(net_rows, [["IOM1", iom_ver, fab_ver]])
|
||||
_print_results(net_rows, iface_rows, [["IOM1", iom_ver, fab_ver]])
|
||||
close_serial_connection(ser, device)
|
||||
|
||||
|
||||
@@ -160,30 +178,33 @@ def _check_via_network():
|
||||
info("Querying network settings and firmware versions over the network...")
|
||||
print()
|
||||
|
||||
net_rows = []
|
||||
fw_rows = []
|
||||
net_rows = []
|
||||
iface_rows = []
|
||||
fw_rows = []
|
||||
|
||||
for iom, ip in iom_list:
|
||||
for iom, host in iom_list:
|
||||
# ── Network settings ───────────────────────────────────────────────────
|
||||
net_ok, net_data = _redfish_request(
|
||||
password, "GET",
|
||||
f"/redfish/v1/Managers/{iom}/EthernetInterfaces/1",
|
||||
host=ip,
|
||||
host=host,
|
||||
)
|
||||
if net_ok and isinstance(net_data, dict):
|
||||
dhcp, ip_addr, gw, nm, origin = _parse_network_data(net_data)
|
||||
dhcp, ip_addr, gw, nm, mac, hostname, link = _parse_network_data(net_data)
|
||||
mode = _c(C.CYN, "DHCP") if dhcp else _c(C.GRN, "Static")
|
||||
net_rows.append([iom, mode, origin, ip_addr, gw, nm])
|
||||
net_rows.append([iom, mode, ip_addr, gw, nm, link])
|
||||
iface_rows.append([iom, mac, hostname])
|
||||
else:
|
||||
net_rows.append([iom, _c(C.RED, "No response"), "--", "--", "--", "--"])
|
||||
iface_rows.append([iom, "--", "--"])
|
||||
error(f"{iom} network query failed: {net_data}")
|
||||
|
||||
# ── Firmware versions (reuse shared redfish helpers) ───────────────────
|
||||
iom_ver = _get_iom_fw_version(password, ip, iom)
|
||||
fab_ver = _get_fabric_fw_version(password, ip, iom)
|
||||
iom_ver = _get_iom_fw_version(password, host, iom)
|
||||
fab_ver = _get_fabric_fw_version(password, host, iom)
|
||||
fw_rows.append([iom, iom_ver, fab_ver])
|
||||
|
||||
_print_results(net_rows, fw_rows)
|
||||
_print_results(net_rows, iface_rows, fw_rows)
|
||||
|
||||
|
||||
# ── Top-level entry point ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user