mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
fix(schemas): one definition of the capabilities payload
GET /computes/{id} answered with only part of the capabilities the compute
reports: the response schema kept a second, private Capabilities class of
its own (it knew ubridge_tc and nothing else), and FastAPI's response model
silently drops fields it does not define — so ubridge_tap and
ubridge_iol_tap never reached clients even though the compute had sent
them and links were already being built on those datapaths.
Import the one definition instead of duplicating it, so the next capability
cannot drift the same way.
This commit is contained in:
2 files changed
+39
-18
No files matched your search
@@ -21,8 +21,11 @@ from typing import Any, List, Optional, Union
|
||||
from pydantic import BaseModel, ConfigDict, Field, SecretStr, model_validator
|
||||
|
||||
from .base import DateTimeModelMixin
|
||||
from .capabilities import UbridgeTcCapabilities
|
||||
from .nodes import NodeType
|
||||
# The capabilities payload has one definition (controller.capabilities): a
|
||||
# second, private copy here silently stripped every field it did not know
|
||||
# about from GET /computes/{id} — which is how ubridge_tap and
|
||||
# ubridge_iol_tap went missing while the compute returned them.
|
||||
from .capabilities import Capabilities
|
||||
|
||||
|
||||
class Protocol(str, Enum):
|
||||
@@ -93,22 +96,6 @@ class ComputeUpdate(ComputeBase):
|
||||
)
|
||||
|
||||
|
||||
class Capabilities(BaseModel):
|
||||
"""
|
||||
Capabilities supported by a compute.
|
||||
"""
|
||||
|
||||
version: str = Field(..., description="Compute version number")
|
||||
node_types: List[NodeType] = Field(..., description="Node types supported by the compute")
|
||||
platform: str = Field(..., description="Platform where the compute is running (Linux, Windows or macOS)")
|
||||
cpus: int = Field(..., description="Number of CPUs on this compute")
|
||||
memory: int = Field(..., description="Amount of memory on this compute")
|
||||
disk_size: int = Field(..., description="Disk size on this compute")
|
||||
ubridge_tc: Optional[UbridgeTcCapabilities] = Field(
|
||||
None, description="uBridge tc-module capabilities; absent when the probe failed or uBridge has no tc module"
|
||||
)
|
||||
|
||||
|
||||
class Compute(DateTimeModelMixin, ComputeBase):
|
||||
"""
|
||||
Data returned for a compute.
|
||||
|
||||
Reference in new issue
Block a user