Initial commit of AthonetTools

This commit is contained in:
2025-08-21 12:59:43 +00:00
commit cd932b8fcb
2483 changed files with 433999 additions and 0 deletions

31
services/state.py Normal file
View File

@@ -0,0 +1,31 @@
# services/state.py
from pathlib import Path
import json
STATE_FILE = Path("system_info.json")
def load_state():
if STATE_FILE.exists():
return json.loads(STATE_FILE.read_text() or "{}")
return {}
def save_state(d: dict):
STATE_FILE.write_text(json.dumps(d, indent=2))
def set_target_ip(ip: str):
st = load_state()
st["target_host_ip"] = ip
save_state(st)
def get_target_ip() -> str | None:
return load_state().get("target_host_ip")
def set_mgmt_info(cidr: str, gw: str):
"""Persist the current DHCP values we discovered for eth0 so we can render static OAM later."""
st = load_state()
st["mgmt"] = {"cidr": cidr, "gw": gw}
save_state(st)
def get_mgmt_info() -> dict:
"""Return {'cidr': 'x.x.x.x/yy', 'gw': 'x.x.x.x'} if previously captured, else {}."""
return load_state().get("mgmt") or {}