refactor: remove netplan apply endpoint and related code
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 7s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 7s
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user