TP15: CRS326-Core als L3-Router aktiviert
- crs326-core nimmt Routing/DHCP/DNS/NAT/WAN/WireGuard von ap1 ueber. - L2-Portplan korrigiert (ap1 #15, Arris WAN #16, branch #8, Sonos #2/3/5/6, IoT #14, VLAN10-Access #11, VLAN1-Hybrid #3/7/9/10/12/17-24). - Backup-RSC gefixt (ether3-24 disabled) und via fixed-RSC eingespielt. - Gestagede L3-Config enabled in einem Rutsch. - Falsche statische Default-Route 0.0.0.0/0 -> 10.40.41.1 entfernt, WAN-DHCP via 90.146.33.177/24 aktiv. - SFP-Ports bleiben disabled (Stromersparnis). - ap1 ist L3-stillgelegt und wird in naechster Session reiner AP. Backup-Dateien (*.backup) und leases-export.json bleiben lokal. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
75
routeros/apply-core-cutover-l3.py
Normal file
75
routeros/apply-core-cutover-l3.py
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Lade die staged L3-Cutover-Config auf crs326-core (noch NICHT enablen).
|
||||
|
||||
Creds aus ~/.claude.json. Alle operativen Objekte in der rsc sind disabled=yes,
|
||||
also bleibt der aktive Datenpfad unberührt.
|
||||
"""
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
CORE_IP = "10.40.41.211"
|
||||
RSC = pathlib.Path(__file__).with_name("tp15-core-cutover-intended.rsc")
|
||||
CLAUDE_JSON = pathlib.Path.home() / ".claude.json"
|
||||
|
||||
|
||||
def load_core_creds():
|
||||
cfg = json.loads(CLAUDE_JSON.read_text())
|
||||
env = cfg.get("mcpServers", {}).get("mikromcp", {}).get("env", {})
|
||||
user = env.get("CRS326_CORE_USER") or env.get("ROUTER_USER")
|
||||
pw = env.get("CRS326_CORE_PASS") or env.get("ROUTER_PASS")
|
||||
if not user or not pw:
|
||||
raise SystemExit("CRS326_CORE_USER/PASS nicht in ~/.claude.json mikromcp.env gefunden")
|
||||
return user, pw
|
||||
|
||||
|
||||
def ssh_base(user, pw):
|
||||
return [
|
||||
"sshpass", "-p", pw,
|
||||
"ssh",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "PubkeyAuthentication=no",
|
||||
f"{user}@{CORE_IP}",
|
||||
]
|
||||
|
||||
|
||||
def run_silent(base, cmd):
|
||||
r = subprocess.run(base + [cmd], capture_output=True, text=True)
|
||||
if r.returncode != 0:
|
||||
out = (r.stdout + r.stderr).replace(pw, "***")
|
||||
raise SystemExit(f"Befehl fehlgeschlagen (rc={r.returncode}):\n{out}")
|
||||
return r
|
||||
|
||||
|
||||
def main():
|
||||
if not RSC.exists():
|
||||
raise SystemExit(f"{RSC} fehlt")
|
||||
user, pw = load_core_creds()
|
||||
base = ssh_base(user, pw)
|
||||
print(f"crs326-core L3-Cutover-Config laden ({RSC.name}) ...")
|
||||
|
||||
# 1) Datei auf Router kopieren
|
||||
r = subprocess.run(
|
||||
["sshpass", "-p", pw,
|
||||
"scp",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "PubkeyAuthentication=no",
|
||||
str(RSC),
|
||||
f"{user}@{CORE_IP}:{RSC.name}"],
|
||||
capture_output=True, text=True,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
raise SystemExit(f"SCP fehlgeschlagen: {r.stderr.replace(pw, '***')}")
|
||||
|
||||
# 2) Import auslösen
|
||||
run_silent(base, f'/import file-name="{RSC.name}"')
|
||||
|
||||
print(" Import abgeschlossen (staged / disabled).")
|
||||
print(" Nächster Schritt: L2-Portplan + Cutover-Enable.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user