mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: accept the 'local' compute id in compute tools
The compute_get/compute_images MCP tools typed compute_id as a UUID, so passing 'local' (the actual id of the built-in compute, which the compute_images description itself pointed to) was rejected by schema validation. Both tools now take a string defaulting to 'local', and the compute_get REST route resolves 'local' through the controller since the local compute has no database entry.
This commit is contained in:
5 files changed
+63
-16
No files matched your search
@@ -54,8 +54,12 @@ class ComputesService:
|
||||
self._controller.notification.controller_emit("compute.created", compute.asdict())
|
||||
return db_compute
|
||||
|
||||
async def get_compute(self, compute_id: Union[str, UUID]) -> models.Compute:
|
||||
async def get_compute(self, compute_id: Union[str, UUID]) -> Union[models.Compute, dict]:
|
||||
|
||||
if str(compute_id) == "local":
|
||||
# the built-in local compute only lives in the controller, not in the database;
|
||||
# drop unset fields (e.g. user) as the response schema types them as str
|
||||
return {k: v for k, v in self._controller.get_compute("local").asdict().items() if v is not None}
|
||||
db_compute = await self._computes_repo.get_compute(compute_id)
|
||||
if not db_compute:
|
||||
raise ControllerNotFoundError(f"Compute '{compute_id}' not found")
|
||||
|
||||
Reference in new issue
Block a user