Commit Graph
8200 Commits
Author SHA1 Message Date
YueGuobin 076c949a4e fix: default tagless Docker image pulls to the latest tag
The daemon pulls every tag of a repository when the tag parameter is
empty. The docker CLI never hits this because it adds :latest before
calling the API, so only raw API callers do. Pulling "debian" through
the API downloaded dozens of images until the registry rate limit
stopped the pull.

Pass tag=latest when the reference has no tag and no digest. Only a
':' after the last '/' counts as a tag separator: before it, it is a
registry port (e.g. registry:5000/repo).

This covers both the /docker/images/pull route and the automatic pull
fallback when a node image is missing.
2026-11-07 14:43:13 +08:00
YueGuobin c846c2ae90 fix: refuse Docker image deletion while templates reference the image
A deletion the user must confirm belongs in the response of the delete
request, not in a notification sent after the fact. The controller now
refuses with a 409 (code image_referenced_by_templates, the template
names in details) while any Docker template references the image,
before the compute is touched. force=true confirms the deletion.

The docker.image.deleted notification stays as a change signal so
clients can refresh their image lists.
2026-11-06 22:15:52 +08:00
YueGuobin de986e890e feat: name nodes and templates in Docker image delete conflicts
The compute translates the container ids in a daemon delete conflict
into the GNS3 node and project behind each container. Leftover
containers from closed projects and containers created outside GNS3
are named as such.

The controller lists the templates referencing the image in the
conflict error, matched through the canonical image name. After a
successful deletion it emits a docker.image.deleted notification with
those templates: their nodes can no longer start.
2026-11-06 22:05:52 +08:00
YueGuobin 04a8ba06a8 fix: start pull events when the pull begins and reject unsafe image names
The pull started event was emitted by the route before the pull took
its per compute lock, so a request queued behind another pull claimed
to be running while it was still waiting. The pull now reports the
started state itself, once it owns the lock.

Deleting an image interpolates the name into the daemon API path. The
pattern on the path parameter limits it to the characters of an image
reference and validate_docker_image_name also rejects "..", so a name
cannot escape that path. Applied on both the controller and compute
routes.
2026-11-06 15:42:51 +08:00
YueGuobin d5d25eba06 fix: stop reporting a missing image as a network problem
A 404 from the registry means the image name is wrong or the registry
needs authentication, but the pull wrapped every error with "please
check your Internet connection". Say what actually failed and keep the
network advice for the other errors.
2026-11-06 15:23:34 +08:00
YueGuobin 8c98142d26 feat: report Docker pull progress and add an idle timeout
A pull now reports docker.image.pull notifications on the controller
stream: started, throttled downloading events with the layer counts
and the latest daemon message, then completed or failed. An optional
progress_id is echoed in every event so a client can correlate them
with its own request. Image operations belong to a compute, not to a
project, so the events go to the controller stream and reach clients
that have no project open.

The pull also has an idle socket read timeout of 60 seconds. Without
it an unreachable registry left the pull, the compute request and the
client request hanging forever with no feedback at all. The timeout
is idle time, not total time: the daemon streams progress during the
whole pull, so a minute without data means the registry is gone. When
it fires, the daemon connection closes and Docker cancels the pull.

Docker.http_query now accepts an aiohttp ClientTimeout object so a
caller can ask for a policy finer than a total timeout.
2026-11-06 15:03:34 +08:00
YueGuobin 424ba919d8 fix: skip non-image files when scanning the image roots
The image inventory scanned every file under the image roots and
reported anything without an image header as an invalid image. Files
users legitimately keep next to their images, such as the Cisco IOU
keygen script, made every scan report errors and the sync job partial.

Extend the existing ignore filter with the extensions of scripts,
documentation and certificates. They are skipped by both the scan and
the file watcher, so they no longer trigger rescans either. Real
corrupted images are still reported.
2026-11-06 14:36:03 +08:00
YueGuobin 54cfcef6e2 fix: send the docker force query parameter as a string
The aiohttp URL builder only accepts strings, ints and floats as query
values and raises a TypeError on a Python bool, so deleting an image
answered a 500. Send true/false like the controller does.
2026-11-06 14:31:26 +08:00
YueGuobin c1e03194d3 api: list Docker image details and delete images
GET /computes/{compute_id}/docker/images now returns the daemon image
id, size and creation date in addition to the tag, so a UI can show
and compare images instead of bare names. The fields are optional to
keep the response compatible with older computes.

Add DELETE /computes/{compute_id}/docker/images/{image} which removes
the image from the compute Docker daemon. The image name is passed as
a path so names with a slash or a tag separator work. A daemon that
refuses because a container uses the image answers a conflict; the
force query parameter removes it anyway.

The compute also drops the controller digest to local id translation
recorded when the image was synced, since it no longer matches
anything on the daemon.
2026-11-06 14:22:22 +08:00
YueGuobin 4c00d223e4 fix: pass the leading slash to the compute load endpoint path
getUrl joins the path directly after /v3/compute, so a path without
the leading slash produces /v3/computedocker/images/load and the
compute answers 404. Match the path shape used by forward() and the
image sync path.
2026-11-06 12:46:21 +08:00
YueGuobin 092202615e api: add controller endpoint to load Docker images on a compute
Add POST /computes/{compute_id}/docker/images/load. It streams an
uploaded docker save tar (plain or gzip) to the compute, which loads
it into its Docker daemon. Clients can now install image packages
such as iol-xe-17-18-02.tar.gz without SSH access to the server.

The body is proxied without buffering (async iterable to chunked
transfer) and runs with no total timeout, like the existing image
sync path between computes.
2026-11-06 10:00:17 +08:00
Jeremy Grossmann 111a4b756c Merge pull request #3061 from yueguobin/fix/remove-ace-route-dump
Remove leftover debug print dumping all routes on ACE creation
2026-11-05 17:26:11 +01:00
Jeremy Grossmann c80bea5279 Merge pull request #3060 from yueguobin/feat/user-privileges-endpoint
Add endpoint returning the current user's privileges
2026-11-05 17:25:29 +01:00
YueGuobin 425d91c085 fix: remove leftover debug print dumping all routes on ACE creation
Creating an ACE printed every route path of the application to stdout.
The debug loop was left behind when the route iteration moved to
_iter_route_paths() in 021991410.
2026-11-05 23:13:42 +08:00
YueGuobin 3ddfe0254d api: add endpoint returning the current user's privileges
Add GET /access/users/me/privileges. It returns the effective privileges
of the logged in user, flattened across all roles assigned to the user
(directly or through group membership). Superadmins get the full
privilege list.

This gives clients a way to render their UI based on permissions. The
server stays the authority for permission checks: a privilege in the
list can still be denied on a specific resource path.
2026-11-05 23:05:28 +08:00
Jeremy Grossmann 94077b4884 Merge pull request #3051 from GNS3/arm64-qemu-support
Enhance aarch64 support with UEFI and improved console options
2026-11-05 14:06:29 +01:00
Jeremy Grossmann 2e5e761c3e Merge pull request #3057 from GNS3/dependabot/pip/3.1/langgraph-gte-1.2.19
Update langgraph requirement from >=1.0.9 to >=1.2.19
2026-11-05 14:04:49 +01:00
Jeremy Grossmann ac54b6d717 Merge branch '3.1' into dependabot/pip/3.1/langgraph-gte-1.2.19 2026-11-05 13:21:28 +01:00
Jeremy Grossmann ddd1f61b6a Merge pull request #3056 from GNS3/dependabot/pip/3.1/python-dotenv-gte-1.2.4
Update python-dotenv requirement from >=1.2.1 to >=1.2.4
2026-11-05 13:20:27 +01:00
Jeremy Grossmann 0a04d084cc Merge pull request #3055 from GNS3/dependabot/pip/3.1/langchain-core-gte-1.7.3
Update langchain-core requirement from >=1.2.16 to >=1.7.3
2026-11-05 13:20:01 +01:00
Jeremy Grossmann 0331cfd2f3 Merge pull request #3054 from GNS3/dependabot/pip/3.1/langchain-openai-gte-1.7.3
Update langchain-openai requirement from >=1.7.2 to >=1.7.3
2026-11-05 13:19:44 +01:00
Jeremy Grossmann d6e70da9ff Merge pull request #3053 from GNS3/dependabot/pip/3.1/langgraph-checkpoint-sqlite-gte-3.1.3
Update langgraph-checkpoint-sqlite requirement from >=3.1.2 to >=3.1.3
2026-11-05 13:19:29 +01:00
Jeremy Grossmann 5943887031 Merge pull request #3058 from GNS3/dependabot/pip/3.1/langchain-xai-gte-1.3.0
Update langchain-xai requirement from >=1.2.2 to >=1.3.0
2026-11-05 13:19:06 +01:00
Jeremy Grossmann b539793281 Merge pull request #3059 from yueguobin/fix/duplicate-project-created-by
fix: attribute duplicated project to the user who duplicated it
2026-11-05 12:49:08 +01:00
dependabot[bot] c327055703 Update langchain-xai requirement from >=1.2.2 to >=1.3.0
Updates the requirements on [langchain-xai](https://github.com/langchain-ai/langchain) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langchain/releases)
- [Commits](https://github.com/langchain-ai/langchain/compare/langchain-xai==1.2.2...langchain-xai==1.3.0)

---
updated-dependencies:
- dependency-name: langchain-xai
  dependency-version: 1.3.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:26:06 +00:00
dependabot[bot] 9429dad9d0 Update langgraph requirement from >=1.0.9 to >=1.2.19
Updates the requirements on [langgraph](https://github.com/langchain-ai/langgraph) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langgraph/releases)
- [Commits](https://github.com/langchain-ai/langgraph/compare/1.0.9...1.2.19)

---
updated-dependencies:
- dependency-name: langgraph
  dependency-version: 1.2.19
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:23:29 +00:00
dependabot[bot] 2480fb669e Update python-dotenv requirement from >=1.2.1 to >=1.2.4
Updates the requirements on [python-dotenv](https://github.com/theskumar/python-dotenv) to permit the latest version.
- [Release notes](https://github.com/theskumar/python-dotenv/releases)
- [Changelog](https://github.com/theskumar/python-dotenv/blob/main/CHANGELOG.md)
- [Commits](https://github.com/theskumar/python-dotenv/compare/v1.2.1...v1.2.4)

---
updated-dependencies:
- dependency-name: python-dotenv
  dependency-version: 1.2.4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:23:18 +00:00
dependabot[bot] 70155eac83 Update langchain-core requirement from >=1.2.16 to >=1.7.3
Updates the requirements on [langchain-core](https://github.com/langchain-ai/langchain) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langchain/releases)
- [Commits](https://github.com/langchain-ai/langchain/compare/langchain-core==1.2.16...langchain-core==1.7.3)

---
updated-dependencies:
- dependency-name: langchain-core
  dependency-version: 1.7.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:23:13 +00:00
dependabot[bot] e7b901de30 Update langchain-openai requirement from >=1.7.2 to >=1.7.3
Updates the requirements on [langchain-openai](https://github.com/langchain-ai/langchain) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langchain/releases)
- [Commits](https://github.com/langchain-ai/langchain/compare/langchain-openai==1.7.2...langchain-openai==1.7.3)

---
updated-dependencies:
- dependency-name: langchain-openai
  dependency-version: 1.7.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:22:59 +00:00
dependabot[bot] 6a7c9e4417 Update langgraph-checkpoint-sqlite requirement from >=3.1.2 to >=3.1.3
Updates the requirements on [langgraph-checkpoint-sqlite](https://github.com/langchain-ai/langgraph) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langgraph/releases)
- [Commits](https://github.com/langchain-ai/langgraph/compare/checkpointsqlite==3.1.2...checkpointsqlite==3.1.3)

---
updated-dependencies:
- dependency-name: langgraph-checkpoint-sqlite
  dependency-version: 3.1.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-05 11:22:40 +00:00
YueGuobin 517b0b0d85 fix: attribute duplicated project to the user who duplicated it
duplicate() kept the original author in created_by. The project list
filters on created_by, so a non-admin user could not see the copy they
just made. Pass the caller through both duplication paths, the same way
import already does since #3017.
2026-11-05 19:22:27 +08:00
Jeremy Grossmann 7230e86c15 Merge pull request #3052 from yueguobin/fix/legacy-project-list-visibility
fix: keep legacy projects visible to non-admin users
2026-11-05 09:49:00 +01:00
YueGuobin 70ef92b55f fix: keep legacy projects visible to non-admin users
Projects created before GNS3 3.1 have no created_by field. The project
list filtered them out for every non-superadmin user, so all old
projects disappeared from the list after an upgrade.

Fall back to the pre-3.1 ACE-only visibility rule when created_by is
not set. Projects owned by another user stay hidden.
2026-11-05 15:42:51 +08:00
grossmj 5e11378a03 feat(qemu): improve UEFI boot configuration and add KVM acceleration warning 2026-11-04 13:07:21 +07:00
Jeremy Grossmann bbb1dc4f80 Merge pull request #3050 from yueguobin/fix/graceful-shutdown-timeout
Bound graceful shutdown and stop notification WebSockets on exit
2026-11-04 06:40:42 +01:00
YueGuobin a56fce4c36 fix: do not monkeypatch attributes on Starlette State in tests
pytest 9.2 reads the old value of a monkeypatched attribute from the
instance __dict__. Starlette State keeps attributes in an internal
dict, so the old value looks unset and the teardown deletes the
attribute for the rest of the test session. The first test that
touches app.state.exiting passes but removes it, and every later
monkeypatch.setattr on it fails with AttributeError.

Use plain assignments instead.
2026-11-04 09:22:15 +08:00
grossmj 0a88127e33 feat(qemu): enhance aarch64 support with UEFI and improved console options 2026-11-04 00:31:52 +07:00
Guobin Yue 8f763c0439 Merge branch '3.1' into fix/graceful-shutdown-timeout 2026-11-04 00:59:22 +08:00
Jeremy Grossmann 9bcffab41e Merge pull request #3049 from yueguobin/copilot-tool-name-align
copilot: reuse MCP tools, align tool names, and manage the step budget
2026-11-03 17:37:42 +01:00
YueGuobin 52c19002f2 fix: bound graceful shutdown and stop notification WebSockets on exit
By default uvicorn waits for open connections forever. A long-lived
streaming response keeps the server waiting after Ctrl+C. One common
case is the MCP Streamable HTTP transport: the client opens a
standalone GET request and the server answers with an SSE stream
(not the old SSE transport). A second Ctrl+C sets force_exit. Uvicorn
then skips the lifespan shutdown, so project and controller cleanup
does not run.

Add timeout_graceful_shutdown. After the timeout uvicorn cancels the
remaining tasks and runs the lifespan shutdown. Also make the four
notification WebSocket handlers stop when app.state.exiting is set.
The HTTP stream handlers already do this.
2026-11-04 00:32:34 +08:00
YueGuobin 42e0a5dd5b fix(copilot): bound LLM requests with a timeout and one retry
A field log showed one request stayed silent for 604s (the OpenAI SDK
default timeout), then the SDK retried on a fresh connection and got
200 OK in under a second. The abort signal did not cancel the in-flight
HTTP call, so the turn could look hung for ten minutes.

- set timeout (default 120s, request_timeout in the LLM config wins),
  max_retries=1 and stream_usage=True for the providers that accept them
  (openai, deepseek, anthropic, xai). ollama and google-genai reject
  these kwargs, so they keep the old behavior.
- log the elapsed time of each LLM call. A slow first token or an SDK
  retry now shows up in the log line.
- add request_timeout to the LLM config schemas and docs (JSON column,
  no migration).
- tests: cover the defaults, the override, invalid values, provider
  filtering and the title model.
2026-11-03 23:57:07 +08:00
YueGuobin f2f42c4817 docs(mcp): document show_filters_icon on link tools
The server link schema has show_filters_icon (default true) and the PUT
passes it through, but the MCP tool docs did not mention it. The old
copilot packet filter tool always set it to false to hide the filter icon
during fault injection; after the move to link_update the icon stayed
visible because the model had no way to know the field exists.

- link_update: add show_filters_icon to the supported kwargs
- link_list: add show_filters_icon to the available response fields
2026-11-03 23:19:00 +08:00
YueGuobin 5a294461e8 fix(copilot): make the step budget real, configurable and visible
The graph passed remaining_steps=20 (50 for injection) in the run inputs.
RemainingSteps is a LangGraph managed value derived from recursion_limit,
so the input was ignored and the real budget was 25 (100 for injection).
No one could see those numbers, and a turn that hit the cap ended on a
bare tool result with no explanation.

- Remove the dead remaining_steps input.
- Add resolve_recursion_limit(): max_steps from the LLM model config wins;
  otherwise 25 teaching_assistant, 50 lab_automation_assistant, 100
  troubleshooting_injection.
- When fewer than 4 steps remain after a tool run, route to the new
  budget_wrapup node. The next llm_call binds no tools and gets a wrap-up
  instruction, so the turn ends with a short summary of what was done and
  what remains.
- should_continue skips the title call after a wrap-up (no step left).
- budget_exhausted is reset at the start of every user turn.
- Add max_steps to the LLM config schemas. The config is a JSON column,
  so no migration is needed.
- Tests: 16 new tests cover the resolver, the routing, the tool-free
  wrap-up call and the removed input. Docs updated.
2026-11-03 23:16:26 +08:00
YueGuobin e8462507a5 feat(copilot): surface console, snapshot, capture and marker tools per mode
The bridge made 49 project-scoped MCP tools available, but the mode
tables still mirrored the old copilot capability set. Expand them:

- lab_automation_assistant: node_console_exec (raw console for nodes
  without a device_type tag), node_list, snapshot_list/create/delete/
  restore
- teaching_assistant: node_list/node_get, link_list, link_marker
  (read-only diagnostics plus traffic-insight markers)
- troubleshooting_injection: link_capture_start/stop/download and
  marker_definition (inject -> capture -> verify loop)

Also fix the tools_by_name registry: it was built from the lab and
injection tables only, which worked while teaching was a strict subset
of lab. Teaching-only tools would have raised KeyError in tool_node
when the LLM called them; the registry now unions all three mode
tables. A new test pins each mode's exact toolset, checks that no
administration tool leaks in, and asserts every referenced name is
resolvable.
2026-11-03 22:57:09 +08:00
YueGuobin 6a4cbe39c1 refactor(copilot): reuse MCP tools via a bridge; extract shared device runners
The copilot and the MCP service maintained two parallel wrapper layers
(LangChain BaseTool classes vs @mcp.tool() functions) over the same
handlers in gns3_client/api_handlers.py. Descriptions and parameters
drifted apart (compute_id and link_type were missing on the copilot
side). This makes the MCP registration the single source of truth and
removes the duplicated wrappers.

tools_v2/mcp_bridge.py adapts the MCP server's tool registration into
LangChain tools: names, descriptions and argument schemas come from the
MCP tools. The pool is filtered to project-scoped tools
(MCP_ALLOWED_TOOLS) because the copilot runs inside one open project —
project management, compute/appliance/image administration and server
info tools stay out. The bridge carries the copilot's request JWT into
the MCP contextvars (username/token_version decoded from the token so
ticket-minting tools work) and runs the async MCP functions from the
copilot's sync tool node on either thread flavor.

Mode toolsets (teaching / lab_automation / troubleshooting_injection)
are now composed from adapted MCP tools plus a few copilot-native ones
that add value the MCP versions lack: link_create (port-name
resolution), wait_seconds, packet_analysis(+skills), and the topology
reader. Eight orphaned LangChain wrappers are deleted.

The device command tools had the dependency inverted (the MCP handlers
instantiated the copilot LangChain classes and round-tripped through
JSON strings). The Nornir/Netmiko classes moved verbatim (git mv) into
the shared layer as plain runners — DeviceConfigCommandRunner,
DeviceShowCommandRunner, VpcsCommandRunner — with _run(json_string)
becoming run(params, gns3_ctx). The optional Jinja2 template rendering
moved from the MCP handlers into the runners (and into
utils/device_configs.render_device_template), so both entry paths get
it; the MCP handlers are now pure delegation. This also drops the
json.dumps/json.loads detour the MCP path used to take.

test_tool_params consistency gate extended: a handler that forwards the
whole params dict to a callee is a wildcard (same rationale as the
params.items() case) — the per-key check cannot see through delegation.
2026-11-03 22:04:57 +08:00
YueGuobin 9c27a293d0 refactor(copilot): align tool names with MCP convention
Rename five copilot tools to the MCP <object>_<verb> naming so both
agent surfaces expose the same names:

- create_gns3_node              -> node_create
- create_gns3_link              -> link_create
- create_gns3_text_drawing      -> drawing_create_text
- create_gns3_rectangle_drawing -> drawing_create_rectangle
- create_gns3_ellipse_drawing   -> drawing_create_ellipse

Also close two capability gaps found during the comparison:

- node_create: accept optional per-node compute_id (passed through to
  the shared handler; before, every node landed on local)
- link_create: accept optional per-link link_type (ethernet default,
  serial supported; before, serial links were impossible)

All tools keep calling the same shared handlers in
gns3_client/api_handlers.py, so the rename has no effect on execution
semantics. Old names appeared nowhere else (prompts, tests, mode tool
lists are clean); docs updated accordingly.
2026-11-03 15:30:44 +08:00
Jeremy Grossmann bfe25641fc Merge pull request #3048 from yueguobin/mcp-console-exec-websocat
feat(mcp): node_console_exec — run console commands in one tool call
2026-11-03 06:22:26 +01:00
YueGuobin c63b2e3e14 docs(mcp): node_console_exec — QEMU serial getty login needs one call
Field finding from the smoke test: login flushes typed-ahead input
before printing "Password: ", so a password sent in a separate call is
lost (Login incorrect loop). Sending username and password in the same
command string logs in reliably; the shell then persists across calls.
2026-11-03 00:32:55 +08:00
YueGuobin 78199d14a4 fix(mcp): collect the console stream in websocat binary mode (-b)
websocat's text mode (-t, and also the default) appends a newline after
every received WebSocket message and turns CR/LF inside a message into
spaces. The compute ships console output as one BINARY frame per
arbitrary read(1024) burst, so text mode diced the stream at every frame
boundary — prompts split into pieces, short "narrow-column" lines, lost
carriage-return redraws (field report: Password: broken in three).

Measured against a local WS server sending known frames:
  -t:  A\nB\nC\na b\na  b\n  ("a\rb" -> "a b")
  -b:  ABCa\rba\r\nb        (byte-exact, both directions)

Binary command frames stay console data on the compute side (only a line
that is itself a JSON {cols,rows} object would be taken as a resize
frame). The regression test fails on -t and passes on -b.
2026-11-03 00:02:58 +08:00
YueGuobin 7bf18ac2e8 feat(mcp): node_console_exec — one-shot console session via the host's websocat
Replaces node_console (which handed a URL + ticket to the client for a
bash websocat chain) with a tool that runs the whole session server-side:
spawn `timeout N websocat -t --no-close <console-ws-url>`, feed the
command lines through stdin (paced, CRLF), read stdout until the timeout
kills websocat, return the collected output as plain text.

- plain text replies: "output: ..." or bare error text — no JSON
  envelope, no status field (the server cannot judge command success)
- raw output: UTF-8 decode with replacement only, no telnet/ANSI
  stripping; control keys are real characters (description teaches
  \u0003, no \x03 translation)
- output funnel: grep=<python regex> filter; <=50 lines return as-is;
  beyond that a 10-line sample plus hints — regrep=true re-filters the
  node's cached capture (no re-run), full=true returns the last 400
  lines / 64 KiB, and the full capture is written to the node's files
  (console-capture.txt) with a ticketed curl download URL
- get_node_console_info_handler removed with its hashlib/TTL imports;
  the node-bound console ticket redemption path stays (comment updated,
  no current producer)
2026-11-02 22:52:46 +08:00