mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 12:30:13 +03:00
fix: extend remote compute image path conversion to all node types
Previously only the "path" field was converted to a relative path for remote computes, causing issues with QEMU and VMware nodes that use different image path fields. Now all known image path fields are converted, ensuring consistent behavior across IOU, QEMU, Dynamips, and VMware node types.
This commit is contained in:
parent
6ff4f575bb
commit
38f5e8df76
@ -75,17 +75,30 @@ if os.path.isabs(orig_path):
|
||||
|
||||
### 实现方案
|
||||
|
||||
修改控制器端的 `_node_data()` 方法,对远程计算节点发送相对路径(仅文件名)而非绝对路径。
|
||||
修改控制器端的 `_node_data()` 方法,对远程计算节点发送相对路径(仅文件名)而非绝对路径。此修复适用于所有节点类型(IOU、QEMU、Dynamips、VMware)。
|
||||
|
||||
**文件**: `gns3server/controller/node.py`
|
||||
|
||||
**修改位置**: 第541-546行
|
||||
**修改位置**: 第541-558行
|
||||
|
||||
```python
|
||||
# For remote computes, convert absolute image paths to relative paths
|
||||
# The remote compute will search for the image in its own configured directories
|
||||
if self._compute.id != "local" and "path" in data and os.path.isabs(data["path"]):
|
||||
data["path"] = os.path.basename(data["path"])
|
||||
if self._compute.id != "local":
|
||||
# Image path fields for various node types
|
||||
image_path_fields = {
|
||||
# Common fields (IOU, Docker, etc.)
|
||||
"path", "image",
|
||||
# QEMU-specific fields
|
||||
"hda_disk_image", "hdb_disk_image", "hdc_disk_image", "hdd_disk_image",
|
||||
"cdrom_image", "bios_image", "initrd", "kernel_image",
|
||||
# VMware-specific fields
|
||||
"vmx_path",
|
||||
}
|
||||
|
||||
for field in image_path_fields:
|
||||
if field in data and data[field] and os.path.isabs(data[field]):
|
||||
data[field] = os.path.basename(data[field])
|
||||
```
|
||||
|
||||
### 工作原理
|
||||
@ -137,17 +150,30 @@ except ComputeConflictError as e:
|
||||
|
||||
### 场景 1:镜像已存在于计算节点
|
||||
|
||||
**IOU 节点:**
|
||||
1. 控制器创建节点,发送相对路径 `i86bi-linux-l3-adventerprisek9-15.4.1T.bin`
|
||||
2. 计算节点在 `~/GNS3/images/IOU/` 中找到镜像
|
||||
3. 节点创建成功 ✅
|
||||
|
||||
**QEMU 节点:**
|
||||
1. 控制器创建节点,发送相对路径 `vios-adventerprisek9-m.qcow2`
|
||||
2. 计算节点在 `~/GNS3/images/QEMU/` 中找到镜像
|
||||
3. 节点创建成功 ✅
|
||||
|
||||
### 场景 2:镜像不存在于计算节点
|
||||
|
||||
**IOU 节点:**
|
||||
1. 控制器创建节点,发送相对路径 `i86bi-linux-l3-adventerprisek9-15.4.1T.bin`
|
||||
2. 计算节点未找到镜像,返回 `ImageMissingError`
|
||||
3. 控制器自动上传镜像到计算节点
|
||||
4. 重试创建,节点创建成功 ✅
|
||||
|
||||
**QEMU 节点:**
|
||||
1. 控制器创建节点,发送相对路径 `vios-adventerprisek9-m.qcow2`
|
||||
2. 计算节点未找到镜像,返回 `ImageMissingError`
|
||||
3. 控制器自动上传镜像到计算节点
|
||||
4. 重试创建,节点创建成功 ✅
|
||||
|
||||
### 场景 3:同名但内容不同的镜像
|
||||
|
||||
⚠️ **潜在风险**:如果计算节点已存在同名镜像但内容不同(不同版本),不会触发上传,可能使用错误的镜像。
|
||||
@ -156,8 +182,7 @@ except ComputeConflictError as e:
|
||||
|
||||
## 当前状态
|
||||
|
||||
- ✅ IOU 节点已修复
|
||||
- ⏳ 其他节点类型(QEMU, Dynamips, VMware)需要类似的修复
|
||||
- ✅ 所有节点类型已修复(IOU, QEMU, Dynamips, VMware)
|
||||
|
||||
## 相关文件
|
||||
|
||||
|
||||
@ -542,8 +542,21 @@ class Node:
|
||||
|
||||
# For remote computes, convert absolute image paths to relative paths
|
||||
# The remote compute will search for the image in its own configured directories
|
||||
if self._compute.id != "local" and "path" in data and os.path.isabs(data["path"]):
|
||||
data["path"] = os.path.basename(data["path"])
|
||||
if self._compute.id != "local":
|
||||
# Image path fields for various node types
|
||||
image_path_fields = {
|
||||
# Common fields (IOU, Docker, etc.)
|
||||
"path", "image",
|
||||
# QEMU-specific fields
|
||||
"hda_disk_image", "hdb_disk_image", "hdc_disk_image", "hdd_disk_image",
|
||||
"cdrom_image", "bios_image", "initrd", "kernel_image",
|
||||
# VMware-specific fields
|
||||
"vmx_path",
|
||||
}
|
||||
|
||||
for field in image_path_fields:
|
||||
if field in data and data[field] and os.path.isabs(data[field]):
|
||||
data[field] = os.path.basename(data[field])
|
||||
|
||||
if self._console:
|
||||
# console is optional for builtin nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user