Files
es24n-conf/es24n_conf.py
scott ac2f67adad Split monolithic script into focused modules
Refactored the single 1200-line es24n_conf.py into six modules plus a
slim entry point, in preparation for the upcoming network-based config
workflow. Each file has a clear, single responsibility:

  ui.py              — ANSI colours, display primitives, input prompts
  serial_port.py     — SerialPort class (termios/fcntl/select)
  models.py          — IOMConfig and ShelfConfig dataclasses
  redfish.py         — Redfish API client (shared by all workflows)
  workflow_serial.py — Serial-based IOM network configuration workflow
  workflow_firmware.py — IOM and Fabric Card firmware update workflow
  es24n_conf.py      — Entry point and main menu only

No functional changes. All imports verified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 17:48:51 -04:00

61 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""
ES24N IOM Network Configuration Tool
TrueNAS ES24N Expansion Shelf — Serial Configuration Utility
Based on ES24N Product Service Guide v.26011
Zero external dependencies — Python 3 standard library only.
Compatible with TrueNAS (FreeBSD) and Linux.
Usage:
python3 es24n_conf.py
All source files must be present in the same directory:
ui.py, serial_port.py, models.py, redfish.py,
workflow_serial.py, workflow_firmware.py
"""
import sys
import time
from ui import _c, C, banner, draw_box, ok, warn, prompt
from workflow_firmware import firmware_update_workflow
from workflow_serial import configure_shelf
def main():
while True:
banner()
draw_box([
f" {_c(C.BOLD, '1')} Configure a new ES24N shelf (serial)",
f" {_c(C.BOLD, '2')} Update IOM / Fabric Card Firmware",
f" {_c(C.BOLD, '3')} Exit",
])
print()
choice = prompt("Select [1/2/3]")
if choice == "1":
another = configure_shelf()
if not another:
break
elif choice == "2":
firmware_update_workflow()
elif choice == "3":
break
else:
warn("Please enter 1, 2, or 3.")
time.sleep(1)
print()
ok("Exiting ES24N IOM Configuration Tool. Goodbye.")
print()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print()
warn("Interrupted. Exiting.")
sys.exit(0)