mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: dedupe and report automatic template creation from images
install_appliances_from_image relied on the name+version pair check in TemplatesService, so the same appliance reached through a second image (the CSR1000v case) created a second template sharing the name. The auto path now skips when any template with the same name exists, whatever the version, and returns a manifest of created and skipped candidates; POST /images/install replies 200 with that manifest instead of an empty 204, and the image_install MCP tool surfaces it.
This commit is contained in:
7 files changed
+154
-11
No files matched your search
@@ -1435,7 +1435,9 @@ async def image_install() -> list[dict[str, Any]]:
|
||||
|
||||
This is NOT for downloading images. Images must be uploaded first (via the GNS3 Web UI).
|
||||
If an uploaded image matches a known appliance, a template is automatically created.
|
||||
Images already referenced by existing templates are skipped.
|
||||
Returns {"created": [...], "skipped": [...]}: images already referenced by existing
|
||||
templates are skipped, and no template is auto-created when one with the same name
|
||||
already exists (regardless of version).
|
||||
"""
|
||||
return await asyncio.to_thread(_run_handler_sync, install_images_handler, {})
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ def prune_images_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) -> di
|
||||
|
||||
def install_images_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) -> dict[str, Any]:
|
||||
conn = _get_connector(gns3_ctx)
|
||||
# Returns 204 No Content on success (empty body, no .json())
|
||||
conn.http_call("post", f"{conn.base_url}/images/install")
|
||||
response = conn.http_call("post", f"{conn.base_url}/images/install")
|
||||
if response.content:
|
||||
# the install endpoint reports which templates were created or skipped
|
||||
return response.json()
|
||||
# tolerate an empty body in case an older server still replies with 204
|
||||
return {"message": "Image installation completed"}
|
||||
Reference in new issue
Block a user