mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Remove model validator. Fixes https://github.com/GNS3/gns3-gui/issues/3522
Default port name and port segment size are already set in the code when a new node is created.
This commit is contained in:
parent
b6127af067
commit
722512d851
@ -42,7 +42,7 @@ PORTS = {
|
|||||||
|
|
||||||
class PortFactory:
|
class PortFactory:
|
||||||
"""
|
"""
|
||||||
Factory to create an Port object based on the type
|
Factory to create a Port object based on the type
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __new__(cls, name, interface_number, adapter_number, port_number, port_type, **kwargs):
|
def __new__(cls, name, interface_number, adapter_number, port_number, port_type, **kwargs):
|
||||||
|
@ -134,19 +134,6 @@ class NodeBase(BaseModel):
|
|||||||
first_port_name: Optional[str] = Field(None, description="Name of the first port")
|
first_port_name: Optional[str] = Field(None, description="Name of the first port")
|
||||||
custom_adapters: Optional[List[CustomAdapter]] = None
|
custom_adapters: Optional[List[CustomAdapter]] = None
|
||||||
|
|
||||||
@model_validator(mode='before')
|
|
||||||
@classmethod
|
|
||||||
def set_default_port_name_format_and_port_segment_size(cls, data: Any) -> Any:
|
|
||||||
|
|
||||||
if "port_name_format" not in data:
|
|
||||||
if data.get('node_type') == NodeType.iou:
|
|
||||||
data['port_name_format'] = "Ethernet{segment0}/{port0}"
|
|
||||||
data['port_segment_size'] = 4
|
|
||||||
else:
|
|
||||||
data['port_name_format'] = "Ethernet{0}"
|
|
||||||
data['port_segment_size'] = 0
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
class NodeCreate(NodeBase):
|
class NodeCreate(NodeBase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user