Skip to content

Commit

Permalink
[yang][dhcp_server] Add dhcp_server_ipv4 yang model (sonic-net#15955)
Browse files Browse the repository at this point in the history
Add yang model for IPv4 DHCP Server.
Add four new tables: DHCP_SERVER_IPV4, DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS, DHCP_SERVER_IPV4_RANGE, DHCP_SERVER_IPV4_PORT
  • Loading branch information
yaqiangz authored Aug 28, 2023
1 parent 4da72b9 commit 44d52db
Show file tree
Hide file tree
Showing 6 changed files with 1,357 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Table of Contents
* [Device Metadata](#device-metadata)
* [Device neighbor metada](#device-neighbor-metada)
* [DHCP_RELAY](#dhcp_relay)
* [DHCP Server IPV4](#dhcp_server_ipv4)
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
* [FG_NHG](#fg_nhg)
* [FG_NHG_MEMBER](#fg_nhg_member)
Expand Down Expand Up @@ -986,6 +987,50 @@ instance is supported in SONiC.
```

### DHCP_SERVER_IPV4
IPV4 DHPC Server related configuration are defined in **DHCP_SERVER_IPV4**, **DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS**, **DHCP_SERVER_IPV4_RANGE**, **DHCP_SERVER_IPV4_PORT** tables.
```
{
"DHCP_SERVER_IPV4": {
"Vlan100": {
"gateway": "100.1.1.1",
"lease_time": 3600,
"mode": "PORT",
"netmask": "255.255.255.0",
"customized_options": [
"option60"
],
"state": "enabled"
}
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": {
"option60": {
"id": 60,
"type": "text",
"value": "dummy_value"
}
},
"DHCP_SERVER_IPV4_RANGE": {
"range1": {
"ip_start": "100.1.1.3",
"ip_end": "100.1.1.5"
}
},
"DHCP_SERVER_IPV4_PORT": {
"Vlan100|PortChannel0003": {
"ips": [
"100.1.1.10"
]
},
"Vlan100|PortChannel2": {
"ranges": [
"range1"
]
}
}
}
```

### DSCP_TO_TC_MAP
```
{
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def run(self):
'./yang-models/sonic-dscp-fc-map.yang',
'./yang-models/sonic-exp-fc-map.yang',
'./yang-models/sonic-dscp-tc-map.yang',
'./yang-models/sonic-dhcp-server-ipv4.yang',
'./yang-models/sonic-dot1p-tc-map.yang',
'./yang-models/sonic-storm-control.yang',
'./yang-models/sonic-tc-priority-group-map.yang',
Expand Down
39 changes: 39 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,45 @@
"interface_id": "true"
}
},
"DHCP_SERVER_IPV4": {
"Vlan100": {
"gateway": "100.1.1.1",
"lease_time": "3600",
"mode": "PORT",
"netmask": "255.255.255.0",
"customized_options": [
"option60"
],
"state": "enabled"
}
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": {
"option60": {
"id": "60",
"type": "text",
"value": "dummy_value"
}
},
"DHCP_SERVER_IPV4_RANGE": {
"range1": {
"range": [
"100.1.1.3",
"100.1.1.5"
]
}
},
"DHCP_SERVER_IPV4_PORT": {
"Vlan100|Ethernet0": {
"ips": [
"100.1.1.10"
]
},
"Vlan100|Ethernet1": {
"ranges": [
"range1"
]
}
},
"SCHEDULER": {
"TEST@0": {
"cbs": "256",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"DHCP_SERVER_IPV4_VALID_FORMAT": {
"desc": "Add dhcp_server_ipv4 in correct format."
},
"DHCP_SERVER_IPV4_WITH_NON_EXIST_VLAN": {
"desc": "Configure vlan-id in DHCP_SERVER_IPV4 table which does not exist in VLAN table.",
"eStrKey": "LeafRef"
},
"DHCP_SERVER_IPV4_INCORRECT_GATEWAY": {
"desc": "Add gateway which is not in correct ip-prefix format.",
"eStrKey": "Pattern"
},
"DHCP_SERVER_IPV4_INCORRECT_NETMASK": {
"desc": "Add netmask which is not in correct ip-prefix format.",
"eStrKey": "Pattern"
},
"DHCP_SERVER_IPV4_STATE_WRONG_VALUE": {
"desc": "Configure wrong value for state.",
"eStrKey": "InvalidValue"
},
"DHCP_SERVER_IPV4_MODE_WRONG_VALUE": {
"desc": "Configure wrong value for mode.",
"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"
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_WRONG_VALUE": {
"desc": "Configure wrong value for type.",
"eStrKey": "InvalidValue",
"eStr": ["type"]
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_TEXT": {
"desc": "Add text type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_IPV4_ADDRESS": {
"desc": "Add ipv4-address type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT8": {
"desc": "Add uint8 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT16": {
"desc": "Add uint16 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT32": {
"desc": "Add uint32 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS."
},
"DHCP_SERVER_IPV4_RANGE_INVALID_END": {
"desc": "Configure wrong end ip of range.",
"eStrKey": "Pattern"
},
"DHCP_SERVER_IPV4_RANGE_RANGES_WITH_IP": {
"desc": "Configure both ip and ranges in DHCP_SERVER_IPV4_RANGE_RANGES",
"eStr": ["Statement of 'ips' and 'ranges' cannot both exist"]
},
"DHCP_SERVER_IPV4_GATEWAY_ABSENT": {
"desc": "Missing gateway in DHCP_SERVER_IPV4",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_LEASE_TIME_ABSENT": {
"desc": "Missing lease_time in DHCP_SERVER_IPV4",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_MODE_ABSENT": {
"desc": "Missing mode in DHCP_SERVER_IPV4",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_NETMASK_ABSENT": {
"desc": "Missing netmask in DHCP_SERVER_IPV4",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_STATE_ABSENT": {
"desc": "Missing state in DHCP_SERVER_IPV4",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_ID_ABSENT": {
"desc": "Missing id in DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_VALUE_ABSENT": {
"desc": "Missing value in DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS",
"eStrKey" : "Mandatory"
},
"DHCP_SERVER_IPV4_RANGE_RANGE_ABSENT": {
"desc": "Missing ranges in DHCP_SERVER_IPV4_RANGE",
"eStrKey": "Must"
},
"DHCP_SERVER_IPV4_RANGE_SINGLE_IP": {
"desc": "Single ip in DHCP_SERVER_IPV4_RANGE"
},
"DHCP_SERVER_IPV4_RANGE_THREE_IP": {
"desc": "Three ips in DHCP_SERVER_IPV4_RANGE",
"eStrKey": "Must"
}
}
Loading

0 comments on commit 44d52db

Please sign in to comment.