Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf209e5236 | ||
|
|
b55a819067 | ||
|
|
f66fb6c122 |
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 "
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user