mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-22 19:02:23 +03:00
vendor: skip /etc/network in volume bridge and permission passes
GNS3_SKIP_INIT containers never run init.sh, so /etc/network (GNS3's own network config consumed by init.sh's ifup) has no consumer — the NOS manages its own interfaces. VendorDockerVM._persistent_volumes() filters it out for both _setup_skip_init_volumes and _fix_permissions, saving one docker exec per pass. The shared _mount_binds is untouched, and without GNS3_SKIP_INIT the full volume list is returned so behaviour matches the base class.
This commit is contained in:
parent
486c5cc1cb
commit
46e863b975
@ -241,6 +241,13 @@ host ──Docker bind mount──▶ /gns3volumes/etc/opt/srlinux (always m
|
|||||||
> host-side root-owned, and an unprivileged GNS3 process cannot chown them
|
> host-side root-owned, and an unprivileged GNS3 process cannot chown them
|
||||||
> from the host. Container-side root (with GNS3's `UsernsMode: host`) can.
|
> from the host. Container-side root (with GNS3's `UsernsMode: host`) can.
|
||||||
|
|
||||||
|
With `GNS3_SKIP_INIT`, `/etc/network` is skipped by both vendor passes
|
||||||
|
(`VendorDockerVM._persistent_volumes()`): it holds GNS3's own network config
|
||||||
|
for init.sh's `ifup`, which never runs for SKIP_INIT containers — the NOS
|
||||||
|
manages its own interfaces. The Docker mount itself is left alone (shared
|
||||||
|
`_mount_binds`, hardcoded at `docker_vm.py` `_mount_binds()`); only the
|
||||||
|
vendor-side bridge/fix passes skip it.
|
||||||
|
|
||||||
### Lifecycle summary
|
### Lifecycle summary
|
||||||
|
|
||||||
| Phase | Normal Docker node | `VendorDockerVM` + `GNS3_SKIP_INIT` |
|
| Phase | Normal Docker node | `VendorDockerVM` + `GNS3_SKIP_INIT` |
|
||||||
|
|||||||
@ -95,6 +95,19 @@ class VendorDockerVM(DockerVM):
|
|||||||
last_ifname = f"eth{self.adapters - 1}"
|
last_ifname = f"eth{self.adapters - 1}"
|
||||||
params["Env"].append(f"GNS3_MAX_ETHERNET={last_ifname}")
|
params["Env"].append(f"GNS3_MAX_ETHERNET={last_ifname}")
|
||||||
|
|
||||||
|
def _persistent_volumes(self):
|
||||||
|
"""
|
||||||
|
Volumes relevant to vendor persistence. With GNS3_SKIP_INIT, drop
|
||||||
|
/etc/network — GNS3's own network config for init.sh's ifup, unused
|
||||||
|
when init.sh is skipped (the NOS manages its own interfaces). The
|
||||||
|
Docker mount itself is left alone (shared _mount_binds); only the
|
||||||
|
vendor-side bridge/fix passes skip it. Without SKIP_INIT the full
|
||||||
|
list is returned so behaviour matches the base class.
|
||||||
|
"""
|
||||||
|
if self._gns3_init:
|
||||||
|
return self._volumes
|
||||||
|
return [v for v in self._volumes if v != "/etc/network"]
|
||||||
|
|
||||||
def _get_container_ifname(self, adapter_number):
|
def _get_container_ifname(self, adapter_number):
|
||||||
"""
|
"""
|
||||||
Override: honour GNS3_INTERFACE_NAMES (e.g. mgmt0, e1-1) in adapter
|
Override: honour GNS3_INTERFACE_NAMES (e.g. mgmt0, e1-1) in adapter
|
||||||
@ -157,7 +170,7 @@ class VendorDockerVM(DockerVM):
|
|||||||
return
|
return
|
||||||
|
|
||||||
uid, gid = os.getuid(), os.getgid()
|
uid, gid = os.getuid(), os.getgid()
|
||||||
for volume in self._volumes:
|
for volume in self._persistent_volumes():
|
||||||
target = f"/gns3volumes{volume}"
|
target = f"/gns3volumes{volume}"
|
||||||
log.debug("Docker container '%s' fix ownership on %s", self._name, target)
|
log.debug("Docker container '%s' fix ownership on %s", self._name, target)
|
||||||
try:
|
try:
|
||||||
@ -199,7 +212,7 @@ class VendorDockerVM(DockerVM):
|
|||||||
Permission-changes recorded by _fix_permissions at the previous
|
Permission-changes recorded by _fix_permissions at the previous
|
||||||
stop are restored (best-effort).
|
stop are restored (best-effort).
|
||||||
"""
|
"""
|
||||||
for volume in self._volumes:
|
for volume in self._persistent_volumes():
|
||||||
vol_target = f"/gns3volumes{volume}"
|
vol_target = f"/gns3volumes{volume}"
|
||||||
# fmt: off
|
# fmt: off
|
||||||
script = (
|
script = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user