From 4c818c6b3794d90f9b226e800c717d97de947648 Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Sun, 30 Aug 2026 14:25:19 +0800 Subject: [PATCH] feat: show IOL-style interface names on iol-runner ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- docs/features/iol-runner-docker.md | 2 +- gns3server/compute/docker/iol_docker_vm.py | 9 +++++++++ tests/compute/docker/test_iol_docker_vm.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/features/iol-runner-docker.md b/docs/features/iol-runner-docker.md index f76da6a4b..bdee70e80 100644 --- a/docs/features/iol-runner-docker.md +++ b/docs/features/iol-runner-docker.md @@ -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 diff --git a/gns3server/compute/docker/iol_docker_vm.py b/gns3server/compute/docker/iol_docker_vm.py index 6243f8a94..b5cd588c7 100644 --- a/gns3server/compute/docker/iol_docker_vm.py +++ b/gns3server/compute/docker/iol_docker_vm.py @@ -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() diff --git a/tests/compute/docker/test_iol_docker_vm.py b/tests/compute/docker/test_iol_docker_vm.py index 672325012..006eb5a77 100644 --- a/tests/compute/docker/test_iol_docker_vm.py +++ b/tests/compute/docker/test_iol_docker_vm.py @@ -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() # ---------------------------------------------------------------------------