4842 Commits

Author SHA1 Message Date
Cristi
104f56cb55 Enhancement: Refresh projects list without restarting the GNS3 server 2026-04-07 00:21:56 +03:00
Guobin Yue
2a11ab6ba3
Merge branch '3.0' into feature/extended-statistics 2026-04-03 21:39:38 +08:00
grossmj
1dc31127d9
Convert database template fields from PickleType to JSON 2026-04-03 20:59:57 +08:00
Jeremy Grossmann
d9f12366bc
Merge branch '3.0' into feature/extended-statistics 2026-04-01 12:54:54 +08:00
grossmj
0b6f17cf8e
Add keepalive mechanism using the NOP command 2026-03-31 18:30:59 +08:00
Jeremy Grossmann
bebf070e4d
Merge branch '3.0' into telnetlib3 2026-03-31 14:33:35 +08:00
Guobin Yue
02dc2b9a41
Merge branch '3.0' into feature/extended-statistics 2026-03-30 22:48:39 +08:00
YueGuobin
4cd74901a5
fix(copilot): improve device_type error message with tested types and config instructions
Add tested device types (cisco_ios_telnet, gns3_huawei_telnet_ce, gns3_ruijie_telnet)
to the error message and include Web UI configuration path.
2026-03-30 14:09:36 +08:00
YueGuobin
33fdfd65ba
feat(statistics): distinguish open vs closed project nodes
Closed project nodes don't have status info in topology JSON.
Add open_project_nodes and closed_project_nodes counts to
help clarify why by_status may be empty.
2026-03-30 00:06:50 +08:00
YueGuobin
b4caffe13b
fix(statistics): handle closed projects where nodes/links are dicts
Open projects store Node/Link objects, but closed projects store
dictionaries loaded from topology JSON. This fix checks the type
before accessing attributes.
2026-03-29 23:59:17 +08:00
YueGuobin
8b4c3a3517
feat(controller): extend /statistics API with project, node and link stats
Return aggregated statistics:
- computes: per-compute CPU/memory/disk stats (existing)
- projects: total, opened, closed counts
- nodes: total count with breakdown by type and status
- links: total count with capturing count
2026-03-29 23:49:36 +08:00
grossmj
46f77eb7d5
Remove old add_event_handler 2026-03-28 09:59:29 +08:00
grossmj
01a68fb23a
Use FastAPI Lifespan Events 2026-03-28 09:54:22 +08:00
YueGuobin
7f9416a070
feat(link): add control_offset field to LinkStyle 2026-03-28 02:11:30 +08:00
YueGuobin
e651ad589b
feat(symbols): add DELETE API for removing custom symbol files
- Add DELETE /v3/symbols/{symbol_id:path} endpoint
- Prevent deletion of built-in symbols (:/ prefix or in resource directory)
- Clear symbol size cache after deletion
- Require Symbol.Allocate privilege
2026-03-27 02:28:27 +08:00
Cristi
7f3468dcd3 Improved exception handling and telnet client disconnect 2026-03-24 15:23:00 +02:00
Cristi
83558d4d9f Enhancement: Re-write current Telnet server implementation using telnetlib3 library 2026-03-24 13:23:45 +02:00
Jeremy Grossmann
77bea35298
Merge pull request #2641 from cristian-ciobanu/3.0
Enhancement Added link type support on the server side
2026-03-20 13:15:03 +08:00
YueGuobin
01d24403d3
feat: improve error handling for API configuration errors
Add error_handler utility to detect and format HTML error responses
from misconfigured API base URLs. When the API returns HTML (indicating
configuration issues), users now see a helpful message instead of raw
HTML content.
2026-03-19 00:46:49 +08:00
grossmj
333386ac8b
Use status.HTTP_501_NOT_IMPLEMENTED from FastAPI 2026-03-18 16:08:47 +08:00
YueGuobin
cd1d28729a feat: make AI Copilot an optional dependency
This change makes AI Copilot features optional to reduce installation
size and support restricted environments.

Changes:
- Split AI dependencies into ai-requirements.txt
- Add ai-copilot optional dependency in pyproject.toml
- Add import protection in gns3server/agent/__init__.py
- Return 501 for AI endpoints when dependencies not installed
- Add gns3server-uninstall-ai-copilot command for cleanup
- Update README with installation and uninstallation instructions

Installation:
- Basic: pip install gns3-server
- With AI: pip install gns3-server[ai-copilot]
- Development: pip install gns3-server[ai-copilot,dev]

Uninstallation:
- gns3server-uninstall-ai-copilot
2026-03-18 15:21:23 +08:00
YueGuobin
0b741dd834 test: simplify class registration assertions in custom netmiko tests
Refactored test assertions for Huawei CE, Ruijie, and VPCS telnet drivers to compare only class names instead of full module paths. This change reduces test brittleness when classes are imported via different module paths while maintaining validation of correct class registration in CLASS_MAPPER and CLASS_MAPPER_BASE.
2026-03-17 22:45:02 +08:00
YueGuobin
55c7d249fb feat(tests): improve class comparison in custom netmiko tests
Refactor test assertions to compare classes by module and name instead of direct object comparison. This ensures tests remain reliable when classes are imported via different paths, preventing false failures due to import variations. Changes applied to Huawei CE, Ruijie, and VPCS telnet driver tests.
2026-03-17 22:33:28 +08:00
YueGuobin
e1f25ce63b fix(tests): replace assertIs with assertEqual in custom netmiko tests
Changed test assertions from `assertIs` to `assertEqual` for class mapper comparisons in Huawei CE, Ruijie, and VPCS telnet driver tests. This ensures proper equality checking rather than identity checking, which is more appropriate for class comparisons in these test cases.
2026-03-17 22:06:53 +08:00
YueGuobin
2557614ba8 refactor(llm-configs):
remove unused reserved_jsonb fields

   Remove the three reserved JSONB fields (reserved_jsonb_1, reserved_jsonb_2, reserved_jsonb_3) from the llm_model_configs
   table. These fields were planned for future use but are no longer needed.
2026-03-17 21:43:48 +08:00
Cristi
de1b539fb6 Enhancement Added link type support on the server side 2026-03-17 15:29:58 +02:00
YueGuobin
a240620443 fix(custom_netmiko): use
assertIs instead of assertEqual for class comparison

   Fix test failures in custom Netmiko driver tests by using assertIs instead
   of assertEqual when comparing class objects registered in CLASS_MAPPER.

   The issue occurred because test files add project root to sys.path, allowing
   the same module to be imported with different paths (e.g., gns3_copilot...
   vs gns3server.agent.gns3_copilot...). assertEqual compares class __module__
   attributes which differ based on import path, while assertIs checks object
   identity which correctly identifies them as the same class.

   Modified files:
   - test_huawei_ce.py
   - test_ruijie_telnet.py
   - test_vpcs_telnet.py
2026-03-17 21:24:39 +08:00
YueGuobin
bd06d3a08e feat(vpcs_tools_netmiko): update Nornir import to use core module
Update the import statement for Nornir from `nornir.core.nornir` to `nornir.core` to align with the latest Nornir library structure and avoid potential import errors. This ensures compatibility with updated Nornir versions.
2026-03-17 21:16:15 +08:00
YueGuobin
a2a52c8a7d feat(vpcs_tools_netmiko): import Nornir class for type hints
Add import of Nornir class from nornir.core.nornir to support type annotations and improve code clarity in the VPCS tools module.
2026-03-17 16:31:44 +08:00
Jeremy Grossmann
8f325b4127
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-17 13:41:21 +08:00
grossmj
cb18b60c5d
Ignore HTTPException received when closing a project 2026-03-17 13:23:19 +08:00
grossmj
4f863f3767
Fix typo 2026-03-17 12:51:36 +08:00
grossmj
0aa6566e50
Prevent router to be duplicated when running and add tests 2026-03-17 12:49:38 +08:00
UmmmAGoodName
95bd76a212 Fixed issue #1605 regarding Cisco slots causing configs to break 2026-03-16 19:09:32 +01:00
YueGuobin
64d3c02d42 refactor(compute): remove SPICE WebSocket console support
Remove all SPICE WebSocket-related code due to frontend dependency issues
with spice-html5 library (missing RSAKey/BigInteger implementations).

Changes:
- Remove start_spice_websocket_console() from BaseNode
- Remove SPICE WebSocket endpoints from QEMU and Docker compute APIs
- Remove SPICE WebSocket proxy endpoint from controller API
- Remove WebSocket subprotocol handling from authentication layers
- Remove SPICE documentation

The SPICE console type remains functional for direct connections,
but WebSocket proxy support has been removed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-17 01:15:26 +08:00
YueGuobin
c98f802362 feat(compute): add SPICE WebSocket console support
Add WebSocket-based console support for SPICE protocol, enabling
   browser-based graphical console access with enhanced features
   like clipboard sharing, USB redirection, and audio streaming.

   Changes:
   - Add start_spice_websocket_console() method in BaseNode for SPICE
     WebSocket to TCP bridging with bidirectional binary forwarding
   - Add /console/spice WebSocket endpoints in QEMU and Docker compute APIs
   - Add /console/spice WebSocket proxy endpoint in controller API
   - Add comprehensive API documentation in docs/features/

   Supported console types:
   - spice: Basic SPICE protocol support
   - spice+agent: SPICE with spice-vdagent for enhanced features

   Architecture:
   - Browser WebSocket → Controller (JWT + RBAC) → Compute (Basic Auth)
   - No external websockify processes required
   - Consistent with existing VNC WebSocket implementation
2026-03-16 22:21:25 +08:00
YueGuobin
ba92b405da feat: add VNC WebSocket console support for Docker and QEMU nodes
Add VNC console WebSocket endpoints for Docker and QEMU nodes:
- Add /console/vnc WebSocket endpoint to compute API (Docker & QEMU)
- Add /console/vnc WebSocket endpoint to controller API
- Implement start_vnc_websocket_console() in BaseNode
- Forward VNC WebSocket traffic between controller and compute layers

The implementation provides bidirectional WebSocket to TCP forwarding
for VNC protocol (RFB) connections, allowing browser-based VNC console
access to containers and VMs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-16 16:40:00 +08:00
Guobin Yue
09aa12cf94
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-15 23:13:15 +08:00
Jeremy Grossmann
6ac4c27bc1
Merge pull request #2639 from yueguobin/fix/telnet-server-connection-race-condition-3.0
Fix/telnet server connection race condition 3.0
2026-03-15 23:01:57 +08:00
Jeremy Grossmann
632b3daab7
Merge pull request #2635 from yueguobin/fix/iou-suspend-405
fix(iou): return 405 error for unsupported suspend operation
2026-03-15 22:47:42 +08:00
grossmj
6e7738a14f
Return 405 error for unsupported actions for other node types 2026-03-15 22:38:51 +08:00
YueGuobin
b71b323fd4 feat(agent): improve tiktoken initialization and device registration
- Configure tiktoken cache directory to isolate encoding files
- Add logging and timing for tiktoken initialization process
- Make Huawei CE and Ruijie Telnet device registration idempotent
- Add duplicate registration prevention with global flags
- Add logging for device type registration status
- Update .gitignore to exclude tiktoken cache files
2026-03-15 21:25:14 +08:00
YueGuobin
4f8daced17 Merge branch 'fix/telnet-server-connection-race-condition-3.0' into feature/ai-copilot-bridge 2026-03-15 13:38:40 +08:00
Guobin Yue
08b579ff83
Merge branch '3.0' into fix/telnet-server-connection-race-condition-3.0 2026-03-15 01:17:30 +08:00
Guobin Yue
9aa3f3b7a0
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-15 00:37:17 +08:00
YueGuobin
cda5fdd94b feat(telnet_server): improve error handling and connection management
- Catch OSError alongside ConnectionError in connection processing to handle more network errors
- Move client_info retrieval inside try block to prevent AttributeError on failed connections
- Replace bare except with specific exceptions (OSError, ConnectionError, asyncio.TimeoutError)
- Improve error logging to include specific exception details and client information
2026-03-15 00:19:51 +08:00
YueGuobin
e4faf673af fix(telnet): handle connection race condition during broadcast
Fixes two critical issues in telnet server when clients rapidly
   connect/disconnect during broadcast operations:

   1. **OSError [Errno 107]**: Transport endpoint not connected
      - Root cause: getpeername() called outside try block
      - Fix: Move getpeername() inside try block and catch OSError
      - Expand exception handling to include OSError and TimeoutError

   2. **KeyError**: Double deletion from connections dictionary
      - Root cause: Connection deleted in broadcast loop, then deleted
        again in top-level exception handler
      - Fix: Use dict.pop(key, None) instead of del dict[key]

   **Changes**:
   - Line 216: Add OSError to top-level exception handler
   - Line 227-228: Use pop() to avoid KeyError on double deletion
   - Line 305-316: Move getpeername() inside try block, expand
     exception types, use pop() for safe deletion

   **Impact**:
   - Prevents unhandled exceptions from propagating to asyncio event loop
   - Ensures proper resource cleanup even with race conditions
   - No resource leaks or zombie connections
   - Long-lived clients unaffected by rapid client disconnects

   **Test Script**:
   - Added stress test script to reproduce the issue
   - Supports IOU-L3, VPCS, and generic device types
   - Rapid clients send broadcast-triggering commands (show/run/OSPF)

   **Related**: Fixes bug documented in docs/bugs/telnet-server-connection-race-condition.md
2026-03-15 00:19:51 +08:00
Jeremy Grossmann
c6be1a28ae
Change first() to one_or_none() for image query 2026-03-14 19:06:27 +08:00
YueGuobin
c3b18f4ce2 feat(copilot): add dynamic wait time calculation for node startup
Optimize GNS3StartNodeTool with device-type-aware wait time calculation
   to significantly reduce startup time for fast devices (VPCS, IOU).

   Changes:
   - Add NODE_STARTUP_TIME configuration
     * VPCS: 15s base + 2s per additional node
     * IOU: 25s base + 3s per additional node
     * Other devices: 120s base + 10s per additional node (conservative)

   - Add calculate_startup_time() function
     * Detects device types via node.node_type
     * Uses fast startup time if all nodes are VPCS/IOU
     * Uses conservative time if any slow device present
     * Logs selected strategy and detected types

   - Optimize GNS3StartNodeTool._run() method
     * Retrieve node info (including node_type) before starting
     * Calculate wait time based on detected device types
     * Send start commands after info retrieval
     * Use calculated wait time for progress bar
     * Reuse collected node objects for status retrieval

   Performance improvements:
   - 1 VPCS node: 140s → 15s (89% faster)
   - 5 VPCS nodes: 180s → 23s (87% faster)
   - 1 IOU node: 140s → 25s (82% faster)
   - 5 IOU nodes: 180s → 37s (79% faster)
   - Mixed VPCS/IOU: 180s → 33s (82% faster)

   Documentation:
   - Update node-control-tools.md with dynamic wait time strategy
   - Add device type comparison table
   - Document performance improvements
   - Update changelog

   Code quality:
   - All comments in English
   - flake8 check passed
   - mypy check passed
2026-03-14 15:24:27 +08:00
YueGuobin
a946ef2d69 eat(copilot): add dynamic wait time calculation for node startup
Optimize GNS3StartNodeTool with device-type-aware wait time calculation
   to significantly reduce startup time for fast devices (VPCS, IOU).

   Changes:
   - Add NODE_STARTUP_TIME configuration
     * VPCS: 10s base + 2s per additional node
     * IOU: 20s base + 3s per additional node
     * Other devices: 120s base + 10s per additional node (conservative)

   - Add calculate_startup_time() function
     * Detects device types via node.node_type
     * Uses fast startup time if all nodes are VPCS/IOU
     * Uses conservative time if any slow device present
     * Logs selected strategy and detected types

   - Optimize GNS3StartNodeTool._run() method
     * Retrieve node info (including node_type) before starting
     * Calculate wait time based on detected device types
     * Send start commands after info retrieval
     * Use calculated wait time for progress bar
     * Reuse collected node objects for status retrieval

   Performance improvements:
   - 1 VPCS node: 140s → 10s (93% faster)
   - 5 VPCS nodes: 180s → 18s (90% faster)
   - 1 IOU node: 140s → 20s (86% faster)
   - 5 IOU nodes: 180s → 32s (82% faster)
   - Mixed VPCS/IOU: 180s → 28s (84% faster)

   Documentation:
   - Update node-control-tools.md with dynamic wait time strategy
   - Add device type comparison table
   - Document performance improvements
   - Update changelog

   Code quality:
   - All comments in English
   - flake8 check passed
   - mypy check passed
2026-03-14 15:14:28 +08:00