refactor: remove netplan apply endpoint and related code
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 7s

This commit is contained in:
2025-11-24 17:52:24 +01:00
parent e8d0f6692b
commit 3488ec12a6

View File

@@ -60,35 +60,3 @@ def nft_ruleset():
# ---------------------
app.include_router(network_api.router, prefix="/network", tags=["network"])
# ---------------------
# Netplan Apply
# ---------------------
NETPLAN_FILE = "/etc/netplan/99-app.yaml"
@app.post("/netplan/apply")
def apply_netplan(config: netplan.NetworkConfig):
try:
data = {"network": config.dict(exclude_none=True)}
with open(NETPLAN_FILE, "w") as f:
yaml.dump(data, f, sort_keys=False)
result = subprocess.run(
["netplan", "try", "--timeout", "10"],
capture_output=True,
text=True,
)
if result.returncode != 0:
raise HTTPException(
status_code=500,
detail=f"Netplan failed: {result.stderr}"
)
return {"status": "ok", "output": result.stdout}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))