Default port name and port segment size are already set in the code when a new node is created.
This commit is contained in:
grossmj 2023-10-15 11:16:05 +10:00
parent b6127af067
commit 722512d851
2 changed files with 1 additions and 14 deletions

View File

@ -42,7 +42,7 @@ PORTS = {
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):

View File

@ -134,19 +134,6 @@ class NodeBase(BaseModel):
first_port_name: Optional[str] = Field(None, description="Name of the first port")
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):