1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-23 23:38:21 +00:00

Fix Ethernet switch and Ethernet hub port validations. Fixes #2334

This commit is contained in:
grossmj 2024-01-11 22:40:38 +11:00
parent b4edbbbaa7
commit 13d9afd8bc
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD
2 changed files with 64 additions and 116 deletions

View File

@ -17,28 +17,30 @@
import copy
ETHERNET_HUB_PORT_SCHEMA = {
"description": "Ethernet port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
},
"required": ["name", "port_number"],
"additionalProperties": False
}
ETHERNET_HUB_CREATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to create a new Ethernet hub instance",
"type": "object",
"definitions": {
"EthernetHubPort": {
"description": "Ethernet port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
},
"required": ["name", "port_number"],
"additionalProperties": False
},
"EthernetHubPort": ETHERNET_HUB_PORT_SCHEMA
},
"properties": {
"name": {
@ -57,12 +59,9 @@ ETHERNET_HUB_CREATE_SCHEMA = {
},
"ports_mapping": {
"type": "array",
"items": [
{"type": "object",
"oneOf": [
{"$ref": "#/definitions/EthernetHubPort"}
]},
]
"items": {
"$ref": "#/definitions/EthernetHubPort"
}
},
},
"additionalProperties": False,
@ -74,23 +73,7 @@ ETHERNET_HUB_OBJECT_SCHEMA = {
"description": "Ethernet hub instance",
"type": "object",
"definitions": {
"EthernetHubPort": {
"description": "Ethernet port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
},
"required": ["name", "port_number"],
"additionalProperties": False
},
"EthernetHubPort": ETHERNET_HUB_PORT_SCHEMA
},
"properties": {
"name": {
@ -114,12 +97,9 @@ ETHERNET_HUB_OBJECT_SCHEMA = {
},
"ports_mapping": {
"type": "array",
"items": [
{"type": "object",
"oneOf": [
{"$ref": "#/definitions/EthernetHubPort"}
]},
]
"items": {
"$ref": "#/definitions/EthernetHubPort"
}
},
"status": {
"description": "Node status",

View File

@ -17,40 +17,42 @@
import copy
ETHERNET_SWITCH_PORT_SCHEMA = {
"description": "Ethernet switch port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
"type": {
"description": "Port type",
"enum": ["access", "dot1q", "qinq"],
},
"vlan": {"description": "VLAN number",
"type": "integer",
"minimum": 1
},
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
},
"required": ["name", "port_number", "type"],
"additionalProperties": False
}
ETHERNET_SWITCH_CREATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to create a new Ethernet switch instance",
"type": "object",
"definitions": {
"EthernetSwitchPort": {
"description": "Ethernet port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
"type": {
"description": "Port type",
"enum": ["access", "dot1q", "qinq"],
},
"vlan": {"description": "VLAN number",
"type": "integer",
"minimum": 1
},
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
},
"required": ["name", "port_number", "type"],
"additionalProperties": False
},
"EthernetSwitchPort": ETHERNET_SWITCH_PORT_SCHEMA
},
"properties": {
"name": {
@ -79,12 +81,9 @@ ETHERNET_SWITCH_CREATE_SCHEMA = {
},
"ports_mapping": {
"type": "array",
"items": [
{"type": "object",
"oneOf": [
{"$ref": "#/definitions/EthernetSwitchPort"}
]},
]
"items": {
"$ref": "#/definitions/EthernetSwitchPort"
}
},
},
"additionalProperties": False,
@ -96,35 +95,7 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = {
"description": "Ethernet switch instance",
"type": "object",
"definitions": {
"EthernetSwitchPort": {
"description": "Ethernet port",
"properties": {
"name": {
"description": "Port name",
"type": "string",
"minLength": 1,
},
"port_number": {
"description": "Port number",
"type": "integer",
"minimum": 0
},
"type": {
"description": "Port type",
"enum": ["access", "dot1q", "qinq"],
},
"vlan": {"description": "VLAN number",
"type": "integer",
"minimum": 1
},
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
},
"required": ["name", "port_number", "type"],
"additionalProperties": False
},
"EthernetSwitchPort": ETHERNET_SWITCH_PORT_SCHEMA
},
"properties": {
"name": {
@ -148,12 +119,9 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = {
},
"ports_mapping": {
"type": "array",
"items": [
{"type": "object",
"oneOf": [
{"$ref": "#/definitions/EthernetSwitchPort"}
]},
]
"items": {
"$ref": "#/definitions/EthernetSwitchPort"
}
},
"status": {
"description": "Node status",