feat: show IOL-style interface names on iol-runner ports

Name ports after the IOL interface they map to (Ethernet0/0, one 4-port
unit per adapter range) via the _get_container_ifname override point, so
the GNS3 UI matches the IOS CLI. Display only — the flat adapter number
remains the socket index.
This commit is contained in:
YueGuobin 2026-08-30 14:25:19 +08:00
parent cd17306372
commit 4c818c6b37
No known key found for this signature in database
3 changed files with 24 additions and 1 deletions

View File

@ -103,7 +103,7 @@ API docs for the auth flow), or in the Web UI under
| `extra_volumes` | `["/config"]` | `/tmp/run` is auto-added. **Never add `/tmp`** — it would persist the socket directory into the projects tree and uBridge would reject the too-long AF_UNIX path. |
| `memory` | optional; `0` (default) = no cap | Unset works — Docker applies no limit. When you do set a cap, keep it at IOL memory + ~512 MB, or the cgroup OOM-killer shoots the router. |
| `console_type` | `telnet` | The runner muxes the IOS console onto PID 1 stdio; `docker_exec` is not needed. |
| `adapters` | multiple of 4 | IOL port granularity; interfaces are `Ethernet0/0`-style. |
| `adapters` | multiple of 4 | IOL port granularity. Ports are shown as `Ethernet0/0`-style (one 4-port unit per adapter range), matching the IOS CLI. |
### Verify

View File

@ -105,6 +105,15 @@ class IOLDockerVM(VendorDockerVM):
volumes.append(needed)
return volumes
def _get_container_ifname(self, adapter_number):
"""
Override: name ports after the IOL interface they map to
(Ethernet0/0, Ethernet0/1, a new 4-port unit every four
adapters), so what the GNS3 UI shows matches the IOS CLI. Wiring is
unaffected: the flat adapter number remains the socket index.
"""
return f"Ethernet{adapter_number // 4}/{adapter_number % 4}"
async def start(self):
await self._prepare_iol_runtime()

View File

@ -177,6 +177,20 @@ def test_iol_memory_knob(compute_project, manager):
assert vm._iol_memory == 2048
# ---------------------------------------------------------------------------
# Port naming
# ---------------------------------------------------------------------------
def test_ports_are_named_after_iol_interfaces(compute_project, manager):
vm = _make_vm(compute_project, manager, adapters=8)
assert vm._get_container_ifname(0) == "Ethernet0/0"
assert vm._get_container_ifname(3) == "Ethernet0/3"
# the second 4-port unit starts its own slot numbering
assert vm._get_container_ifname(4) == "Ethernet1/0"
assert vm._get_container_ifname(7) == "Ethernet1/3"
# ---------------------------------------------------------------------------
# create()
# ---------------------------------------------------------------------------