refactor: move vendor NOS Docker support into VendorDockerVM subclass

Extract the docker_exec console and GNS3_* prototype knobs (SKIP_INIT,
INTERFACE_NAMES, CONSOLE_CMD) from DockerVM into a VendorDockerVM subclass.
DockerVM is restored to its 3.1 baseline plus four small extension hooks
(_prepare_init_and_interface_env, _start_console_server,
_get_container_ifname, _cleanup_console_resources) that are pure
refactorings with zero behaviour change for existing nodes.

VendorDockerVM additionally replicates init.sh's volume persistence
(bind-mount /gns3volumes over the in-container path) via docker exec for
containers that skip init.sh, so vendor NOS config (e.g. /etc/opt/srlinux)
survives node stop/start.

The Docker manager selects VendorDockerVM when console_type == docker_exec;
all other nodes keep using DockerVM unchanged.
This commit is contained in:
YueGuobin committed 2026-08-13 02:05:17 +08:00
1 parent 511c52330b
commit 5388fd3796
3 files changed
+380 -207

No files matched your search

+11
View File
@@ -32,6 +32,7 @@ from gns3server.config import Config
from gns3server.utils.asyncio import locking
from gns3server.compute.base_manager import BaseManager
from gns3server.compute.docker.docker_vm import DockerVM
from gns3server.compute.docker.vendor_docker_vm import VendorDockerVM
from gns3server.compute.docker.docker_error import DockerError, DockerHttp304Error, DockerHttp404Error, DockerHttp409Error
log = logging.getLogger(__name__)
@@ -59,6 +60,16 @@ class Docker(BaseManager):
self._session = None
self._api_version = DOCKER_MINIMUM_API_VERSION
def _select_node_class(self, **kwargs):
"""Select the node class based on console_type."""
if kwargs.get("console_type") == "docker_exec":
return VendorDockerVM
return DockerVM
async def create_node(self, name, project_id, node_id, *args, **kwargs):
self._NODE_CLASS = self._select_node_class(**kwargs)
return await super().create_node(name, project_id, node_id, *args, **kwargs)
@staticmethod
async def install_busybox(dst_dir):