mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: repair imports lost in the 3.1 rebase and meet the new lint baseline
The rebase onto upstream 3.1 (mypy + ruff I001/F401 waves) left the tree short of the newly enforced baselines in three ways: * contextlib / UbridgeError imports dropped as false duplicates during conflict resolution left NameErrors in iou_vm and qemu_vm (F821); the Dynamips router grabbed the compute-level NIOTAP instead of the hypervisor one, breaking TAP anchoring (test failure). * unused imports (KERNEL_UNSUPPORTED_FILTERS, UbridgeError, List) and unsorted blocks left behind where the stack's later commits moved the last usage elsewhere — ruff I001/F401/RUF022 now enforce these. * mypy, now baseline-free: cache dict annotations in tc_probe, the locators candidate list, the resolved-params None branch in the MCP runner, and validate_bpf_syntax keeps the upstream Dict[str, Any] return (the strict Optional[str] was wrong for the "valid" bool entry). The e2e raw-frame probe resolves its compiler via shutil.which (S607) and zips with strict= (B905); the remaining subprocess call is S603 by nature and gets a per-file ignore like other test files. ruff check/format clean, mypy at upstream parity (no new errors), full unit suite 2167 passed.
This commit is contained in:
35 files changed
+165
-136
No files matched your search
@@ -24,14 +24,13 @@ markers, attach/detach, adapter carrier — lives in
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import logging
|
||||
|
||||
from gns3server.compute.kernel_datapath import KernelDatapathMixin
|
||||
from gns3server.compute.ubridge.ubridge_error import UbridgeError, UbridgeNamespaceError
|
||||
|
||||
from .docker_error import DockerError
|
||||
from gns3server.utils.kernel_anchor import anchor_suffix, kernel_anchor_name
|
||||
|
||||
import logging
|
||||
from .docker_error import DockerError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -33,14 +33,13 @@ import aiohttp
|
||||
import psutil
|
||||
|
||||
from gns3server.compute.compute_error import ComputeError
|
||||
from gns3server.compute.ubridge.ubridge_error import UbridgeError, UbridgeNamespaceError
|
||||
from gns3server.compute.ubridge.ubridge_error import UbridgeNamespaceError
|
||||
from gns3server.utils import int_to_macaddress, macaddress_to_int
|
||||
from gns3server.utils.asyncio import monitor_process, wait_for_file_creation, wait_run_in_executor
|
||||
from gns3server.utils.asyncio.raw_command_server import AsyncioRawCommandServer
|
||||
from gns3server.utils.asyncio.ssh_server import AsyncioSSHServer
|
||||
from gns3server.utils.asyncio.telnet_server import AsyncioTelnetServer
|
||||
from gns3server.utils.hostname import is_rfc1123_hostname_valid
|
||||
from gns3server.utils.packet_filter_validation import KERNEL_UNSUPPORTED_FILTERS
|
||||
|
||||
from ..adapters.ethernet_adapter import EthernetAdapter
|
||||
from ..base_node import BaseNode
|
||||
|
||||
@@ -672,4 +672,3 @@ class IOLDockerVM(VendorDockerVM):
|
||||
|
||||
if self._kernel_host_ifc(adapter_number, port_number) is not None:
|
||||
await KernelDatapathMixin._set_adapter_carrier(self, adapter_number, connected, port_number)
|
||||
|
||||
@@ -42,10 +42,10 @@ from ...base_node import BaseNode
|
||||
from ...error import NodeError
|
||||
from ...kernel_datapath import KernelDatapathMixin
|
||||
from ...nios.nio_bridge import NIOBridge
|
||||
from ...nios.nio_tap import NIOTAP
|
||||
from ...ubridge.ubridge_error import UbridgeError
|
||||
from ..adapters.adapter import ETHERNET_ADAPTERS, ETHERNET_WICS
|
||||
from ..dynamips_error import DynamipsError
|
||||
from ..nios.nio_tap import NIOTAP
|
||||
|
||||
|
||||
class Router(KernelDatapathMixin, BaseNode):
|
||||
|
||||
@@ -22,6 +22,7 @@ order to run an IOU VM.
|
||||
import asyncio
|
||||
import binascii
|
||||
import configparser
|
||||
import contextlib
|
||||
import functools
|
||||
import glob
|
||||
import hashlib
|
||||
@@ -951,9 +952,7 @@ class IOUVM(KernelDatapathMixin, BaseNode):
|
||||
raise self._kernel_error(
|
||||
"Bay {bay}/{unit} of IOU '{name}' has no TAP anchor to carry a kernel link "
|
||||
"(serial ports stay on the relay datapath, and a node whose uBridge lacks "
|
||||
"iol_bridge add_nio_tap runs relay-only)".format(
|
||||
bay=adapter_number, unit=port_number, name=self._name
|
||||
)
|
||||
"iol_bridge add_nio_tap runs relay-only)".format(bay=adapter_number, unit=port_number, name=self._name)
|
||||
)
|
||||
await self._ubridge_send(
|
||||
'iol_bridge add_nio_tap {name} {iol_id} {bay} {unit} "{tap}"'.format(
|
||||
|
||||
@@ -41,17 +41,16 @@ A node type using this mixin provides:
|
||||
failures surface as ``DockerError`` / ``QemuError`` rather than ``NodeError``.
|
||||
"""
|
||||
|
||||
import os
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
|
||||
from gns3server.utils.tc_capabilities import FILTER_EBPF_MODES, parse_tc_capabilities, usable_ebpf_modes
|
||||
from gns3server.compute.ubridge.ubridge_error import UbridgeError
|
||||
from gns3server.compute.error import NodeError
|
||||
from gns3server.compute.ubridge.ubridge_error import UbridgeError
|
||||
from gns3server.utils.tc_capabilities import FILTER_EBPF_MODES, parse_tc_capabilities, usable_ebpf_modes
|
||||
|
||||
from .nios.nio_bridge import NIOBridge
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ order to run a QEMU VM.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import contextlib
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
@@ -53,6 +54,7 @@ from ..kernel_datapath import KernelDatapathMixin
|
||||
from ..nios.nio_bridge import NIOBridge
|
||||
from ..nios.nio_tap import NIOTAP
|
||||
from ..nios.nio_udp import NIOUDP
|
||||
from ..ubridge.ubridge_error import UbridgeError
|
||||
from .qemu_error import QemuError
|
||||
from .utils.qcow2 import Qcow2, Qcow2Error
|
||||
from .utils.ziputils import pack_zip, unpack_zip
|
||||
|
||||
@@ -32,29 +32,31 @@ failure (missing binary, old build answering "Unknown command", timeout)
|
||||
means unknown, reported as None and cached as such.
|
||||
"""
|
||||
|
||||
import os
|
||||
import uuid
|
||||
import shutil
|
||||
import asyncio
|
||||
import tempfile
|
||||
import logging
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
from gns3server.config import Config
|
||||
from gns3server.utils.tc_capabilities import parse_tc_capabilities
|
||||
|
||||
from .hypervisor import Hypervisor
|
||||
from .ubridge_error import UbridgeError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# binary identity -> parsed report (None = probed and unusable)
|
||||
_cache = {}
|
||||
_cache: dict[tuple[str, int, int], Optional[dict[str, str]]] = {}
|
||||
# binary identity -> whether the tap module works (None = unknown)
|
||||
_tap_cache = {}
|
||||
_tap_cache: dict[tuple[str, int, int], Optional[bool]] = {}
|
||||
# binary identity -> whether iol_bridge can bind a port to a TAP (None = unknown)
|
||||
_iol_tap_cache = {}
|
||||
_iol_tap_cache: dict[tuple[str, int, int], Optional[bool]] = {}
|
||||
# binary identity -> whether the bridge module can release a named TAP NIO (None = unknown)
|
||||
_bridge_tap_cache = {}
|
||||
_bridge_tap_cache: dict[tuple[str, int, int], Optional[bool]] = {}
|
||||
_lock = asyncio.Lock()
|
||||
|
||||
|
||||
@@ -252,9 +254,7 @@ async def _probe_iol_tap(path, config, timeout):
|
||||
await hypervisor.send(f"iol_bridge create {bridge} {_IOL_PROBE_BRIDGE_ID}")
|
||||
try:
|
||||
await hypervisor.send(f"tap create {tap}")
|
||||
await hypervisor.send(
|
||||
f"iol_bridge add_nio_tap {bridge} {_IOL_PROBE_BRIDGE_ID - 1} 0 0 {tap}"
|
||||
)
|
||||
await hypervisor.send(f"iol_bridge add_nio_tap {bridge} {_IOL_PROBE_BRIDGE_ID - 1} 0 0 {tap}")
|
||||
await hypervisor.send(f"iol_bridge delete_nio_tap {bridge} 0 0")
|
||||
finally:
|
||||
# iol_bridge delete releases every port NIO (the TAP fd),
|
||||
|
||||
Reference in new issue
Block a user