3 Commits
Author SHA1 Message Date
clawdbuddy bf209e5236 fix: load node specs from backend on App mount so remote-host config is included in sim start
Previously nodeSpecs was only set when user visited NodeManager tab.
If user clicked Start from Dashboard without visiting NodeManager first,
the start request had no 'nodes' field -> backend generated all-local
defaults -> remote host-manet-node never started.

Fix: fetch /api/nodes/specs in App useEffect on mount.
2026-05-17 14:42:11 +08:00
clawdbuddy b55a819067 fix: handle host-manet-node:latest image mapping in start_one 2026-05-17 14:06:31 +08:00
clawdbuddy f66fb6c122 feat: auto-pull node images if not present locally; add image version field in NodeManager UI 2026-05-17 13:45:42 +08:00
4 changed files with 41 additions and 12 deletions

No files matched your search

@@ -103,6 +103,14 @@ class DockerMgr:
log.info("启动 %s (镜像=%s 模式=%s IP=%s)",
name, spec.image, spec.user_app_mode, spec.ip)
# 自动拉取镜像(如果本地不存在)
try:
self.client.images.get(spec.image)
except docker.errors.ImageNotFound:
log.info("镜像 %s 不存在,正在拉取...", spec.image)
self.client.images.pull(spec.image)
log.info("镜像 %s 拉取完成", spec.image)
container = self.client.containers.run(
image=spec.image,
name=name,
@@ -217,12 +217,16 @@ class HostNodeMgr:
name, self.host_ip, spec.image, spec.ip)
# 3) docker run (--net=host, --privileged)
# If spec.image is the default container image, use the host-specific one.
# Otherwise trust the caller's image choice (e.g. GHCR path).
if spec.image == "manet-node:latest":
# Map local image names to GHCR host-manet-node images.
# If the caller specifies a custom image (e.g. GHCR path), use it as-is.
image = spec.image or "manet-node:latest"
if image in ("manet-node:latest", "host-manet-node:latest"):
image = "ghcr.io/clawdbuddy/host-manet-node:main"
else:
image = spec.image
# v1.1.4+ tagged images
if image == "host-manet-node:1.1.4":
image = "ghcr.io/clawdbuddy/host-manet-node:1.1.4"
# Auto-pull if not present
self._exec(f"docker images -q {image} 2>/dev/null | grep -q . || docker pull {image}")
run_cmd = (
f"docker run -d --name {name} --hostname host-manet-{spec.id} "
f"--net=host --privileged --cap-add NET_ADMIN --cap-add SYS_ADMIN "
+9 -1
View File
@@ -1,4 +1,4 @@
import { useState, useCallback } from 'react';
import { useState, useCallback, useEffect } from 'react';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
import { useSimConfig } from '@/hooks/useSimConfig';
@@ -42,6 +42,14 @@ function App() {
const [activePage, setActivePage] = useState<PageKey>('dashboard');
const [nodeSpecs, setNodeSpecs] = useState<NodeSpec[] | undefined>(undefined);
// Load node specs from backend on mount (so Start always includes remote-host config)
useEffect(() => {
fetch('/api/nodes/specs')
.then(r => r.ok ? r.json() : [])
.then(data => { if (Array.isArray(data) && data.length > 0) setNodeSpecs(data); })
.catch(() => {});
}, []);
const handleStart = () => {
startSimulation(config, undefined, nodeSpecs);
};
@@ -363,10 +363,11 @@ export function NodeManager({ onNodeSpecsChange }: NodeManagerProps) {
{/* Header */}
<div className="grid grid-cols-12 gap-2 px-3 py-1.5 text-xs font-medium text-muted-foreground border-b">
<div className="col-span-1">ID</div>
<div className="col-span-3">IP 地址</div>
<div className="col-span-2">IP 地址</div>
<div className="col-span-2">角色</div>
<div className="col-span-4">主机</div>
<div className="col-span-2" />
<div className="col-span-3">主机</div>
<div className="col-span-3">镜像版本</div>
<div className="col-span-1" />
</div>
{nodeSpecs.length === 0 ? (
@@ -381,7 +382,7 @@ export function NodeManager({ onNodeSpecsChange }: NodeManagerProps) {
className="grid grid-cols-12 gap-2 items-center px-3 py-2 rounded-lg border bg-card hover:bg-accent/30 transition-colors"
>
<div className="col-span-1 font-mono text-sm font-medium">{spec.id}</div>
<div className="col-span-3">
<div className="col-span-2">
<Input
value={spec.ip}
onChange={e => updateNode(spec.id, 'ip', e.target.value)}
@@ -399,7 +400,7 @@ export function NodeManager({ onNodeSpecsChange }: NodeManagerProps) {
<option value="gateway">Gateway</option>
</select>
</div>
<div className="col-span-4">
<div className="col-span-3">
<select
value={spec.host}
onChange={e => updateNode(spec.id, 'host', e.target.value)}
@@ -411,7 +412,15 @@ export function NodeManager({ onNodeSpecsChange }: NodeManagerProps) {
))}
</select>
</div>
<div className="col-span-2 flex justify-end">
<div className="col-span-3">
<Input
value={spec.image ?? 'manet-node:latest'}
onChange={e => updateNode(spec.id, 'image' as keyof NodeSpec, e.target.value)}
placeholder="manet-node:latest"
className="h-8 text-xs font-mono"
/>
</div>
<div className="col-span-1 flex justify-end">
<Button
size="sm"
variant="ghost"