feat: Implement initial Homelab Automation API v2 with new models, routes, and core architecture, including a SQLAlchemy model refactoring script.
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled

This commit is contained in:
2026-03-03 20:18:22 -05:00
parent 608f4b9197
commit c3cd7c2621
50 changed files with 2265 additions and 188 deletions
+53
View File
@@ -613,5 +613,58 @@ class DockerActionsService:
}
async def list_networks(
self,
host_id: str,
) -> Dict[str, Any]:
"""List Docker networks on a host."""
import json as json_lib
host = await self._get_host_info(host_id)
try:
conn = await self._ssh_connect(host["ip"])
try:
use_sudo_state: Dict[str, Optional[bool]] = {"value": None}
result = await self._run_docker(
conn,
'docker network ls --format "{{json .}}"',
use_sudo_state,
)
networks = []
if result["success"] and result["stdout"].strip():
for line in result["stdout"].strip().splitlines():
line = line.strip()
if not line:
continue
try:
net = json_lib.loads(line)
networks.append({
"id": net.get("ID", ""),
"name": net.get("Name", ""),
"driver": net.get("Driver", ""),
"scope": net.get("Scope", ""),
})
except json_lib.JSONDecodeError:
continue
return {
"host_id": host_id,
"host_name": host["name"],
"networks": networks,
"total": len(networks),
}
finally:
conn.close()
except DockerActionError as e:
return {
"host_id": host_id,
"host_name": host.get("name", ""),
"networks": [],
"total": 0,
"error": str(e),
}
# Singleton instance
docker_actions = DockerActionsService()