[yang] Add support for smart switch in dhcp_server_ipv4 (#17320)

This commit is contained in:
Yaqiang Zhu 2024-01-03 01:08:22 +08:00 committed by GitHub
parent b9e90c2901
commit a25b9d8ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 8 deletions

View File

@ -4,7 +4,7 @@
},
"DHCP_SERVER_IPV4_WITH_INVALID_VLAN": {
"desc": "Configure vlan-id in DHCP_SERVER_IPV4 table which is invalid.",
"eStrKey" : "Pattern"
"eStrKey" : "InvalidValue"
},
"DHCP_SERVER_IPV4_INCORRECT_GATEWAY": {
"desc": "Add gateway which is not in correct ip-prefix format.",
@ -22,6 +22,10 @@
"desc": "Configure wrong value for mode.",
"eStrKey": "InvalidValue"
},
"DHCP_SERVER_IPV4_WITH_NON_EXIST_BRIDGE": {
"desc": "Configure bridge in DHCP_SERVER_IPV4 table which does not exist in MID_PLANE_BRIDGE table.",
"eStrKey": "InvalidValue"
},
"DHCP_SREVER_IPV4_NON_EXIST_OPTION": {
"desc": "Configure option in DHCP_SERVER_IPV4 table which does not exist in DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS table.",
"eStrKey": "LeafRef"
@ -35,6 +39,10 @@
"eStrKey": "InvalidValue",
"eStr": ["type"]
},
"DHCP_SERVER_IPV4_PORT_WITH_NO_EXIST_PORT": {
"desc": "Configure DHCP port in DHCP_SERVER_IPV4_PORT table which is no exist.",
"eStrKey": "InvalidValue"
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_TEXT": {
"desc": "Add text type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},

View File

@ -1,5 +1,13 @@
{
"DHCP_SERVER_IPV4_VALID_FORMAT": {
"sonic-smart-switch:sonic-smart-switch": {
"sonic-smart-switch:MID_PLANE_BRIDGE": {
"GLOBAL": {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
}
},
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [
@ -38,6 +46,14 @@
"option60"
],
"state": "enabled"
},
{
"name": "bridge_midplane",
"gateway": "169.254.200.254",
"lease_time": 3600,
"mode": "PORT",
"netmask": "255.255.255.0",
"state": "enabled"
}
]
},
@ -164,6 +180,30 @@
}
}
},
"DHCP_SERVER_IPV4_WITH_NON_EXIST_BRIDGE": {
"sonic-smart-switch:sonic-smart-switch": {
"sonic-smart-switch:MID_PLANE_BRIDGE": {
"GLOBAL": {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
}
},
"sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": {
"sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": {
"DHCP_SERVER_IPV4_LIST": [
{
"name": "non_exist_bridge_midplane",
"gateway": "192.168.0.1",
"lease_time": 3600,
"mode": "PORT",
"netmask": "255.255.255.0",
"state": "enabled"
}
]
}
}
},
"DHCP_SREVER_IPV4_NON_EXIST_OPTION": {
"sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": {
"sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": {
@ -248,6 +288,41 @@
}
}
},
"DHCP_SERVER_IPV4_PORT_WITH_NO_EXIST_PORT": {
"sonic-smart-switch:sonic-smart-switch": {
"sonic-smart-switch:MID_PLANE_BRIDGE": {
"GLOBAL": {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
}
},
"sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": {
"sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": {
"DHCP_SERVER_IPV4_LIST": [
{
"name": "bridge_midplane",
"gateway": "169.254.200.254",
"lease_time": 3600,
"mode": "PORT",
"netmask": "255.255.255.0",
"state": "enabled"
}
]
},
"sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_PORT": {
"DHCP_SERVER_IPV4_PORT_LIST": [
{
"name": "bridge_midplane",
"port": "non_exit_dpu",
"ips": [
"169.254.200.1"
]
}
]
}
}
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_TEXT": {
"sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": {
"sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": {

View File

@ -27,6 +27,10 @@ module sonic-dhcp-server-ipv4 {
prefix lag;
}
import sonic-smart-switch {
prefix smartswitch;
}
description "DHCP_SERVER_IPV4 YANG module for SONiC OS";
revision 2023-07-19 {
@ -46,12 +50,17 @@ module sonic-dhcp-server-ipv4 {
leaf name {
description "Interface name for DHCP server";
// Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern
// type leafref {
// path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name";
// }
type string {
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
type union {
// Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern
// type leafref {
// path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name";
// }
type string {
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
}
type leafref {
path "/smartswitch:sonic-smart-switch/smartswitch:MID_PLANE_BRIDGE/smartswitch:GLOBAL/smartswitch:bridge";
}
}
}
@ -204,7 +213,7 @@ module sonic-dhcp-server-ipv4 {
}
leaf port {
description "Interface under vlan";
description "Interface under DHCP interface";
type union {
type leafref {
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
@ -212,6 +221,9 @@ module sonic-dhcp-server-ipv4 {
type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
type leafref {
path "/smartswitch:sonic-smart-switch/smartswitch:DPUS/smartswitch:DPUS_LIST/smartswitch:midplane_interface";
}
}
}