Skip to content

Commit

Permalink
Add SONiC YANGs for Management Port, Management Interface, Management…
Browse files Browse the repository at this point in the history
… VRF and NTP. (sonic-net#7252)

* SONiC YANG model support for Management Port, Management Interface, Management VRF and NTP.
Co-authored-by: Bing Sun <Bing_Sun@dell.com>
  • Loading branch information
bsun-sudo authored and Carl Keene committed Aug 7, 2021
1 parent 9d4ad20 commit 506d4d1
Show file tree
Hide file tree
Showing 15 changed files with 932 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sonic-yang-mgmt/sonic_yang_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ def _revYangConvert(val):
vValue = list()
for v in value:
vValue.append(_revYangConvert(v))
elif leafDict[key]['type']['@name'] == 'boolean':
vValue = 'true' if value else 'false'
else:
vValue = _revYangConvert(value)

Expand Down
4 changes: 4 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
'./yang-models/sonic-flex_counter.yang',
'./yang-models/sonic-interface.yang',
'./yang-models/sonic-loopback-interface.yang',
'./yang-models/sonic-mgmt_interface.yang',
'./yang-models/sonic-mgmt_port.yang',
'./yang-models/sonic-mgmt_vrf.yang',
'./yang-models/sonic-ntp.yang',
'./yang-models/sonic-nat.yang',
'./yang-models/sonic-port.yang',
'./yang-models/sonic-portchannel.yang',
Expand Down
43 changes: 43 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 @@ -252,6 +252,49 @@
"port": "Eth18"
}
},
"MGMT_PORT": {
"eth0": {
"alias": "eth0",
"admin_status": "up",
"speed": "1000",
"autoneg": "off",
"description": "Management port",
"mtu": "3500"
}
},
"MGMT_INTERFACE": {
"eth0|10.11.150.11/16": {
"gwaddr": "10.11.0.1"
},
"eth0|fc00:2::32/64": {
"forced_mgmt_routes": [
"10.3.145.14",
"2001:aa:aa::aa",
"10.0.0.100/31",
"10.255.0.0/28"
],
"gwaddr": "fc00:2::1"
}
},
"MGMT_VRF_CONFIG": {
"vrf_global": {
"mgmtVrfEnabled": "true"
}
},
"NTP": {
"global": {
"vrf": "mgmt",
"src_intf": [
"eth0",
"Loopback0"
]
}
},
"NTP_SERVER": {
"0.debian.pool.ntp.org": {},
"23.92.29.245": {},
"2001:aa:aa::aa": {}
},
"PORT": {
"Ethernet0": {
"alias": "Eth1/1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"MGMT_INTERFACE_TEST": {
"desc": "CONFIGURE MANAGEMENT INTERFACE WITH IP AND GW."
},
"MGMT_INTERFACE_WITH_NON_EXIST_PORT": {
"desc": "CONFIGURE MANAGEMENT INTERFACE WITH NON EXIST MGMT PORT.",
"eStrKey": "LeafRef",
"eStr": ["port", "name"]
},
"MGMT_INTERFACE_WITH_WRONG_PORT": {
"desc": "CONFIGURE MANAGEMENT INTERFACE WITH WRONG MGMT PORT.",
"eStrKey": "LeafRef",
"eStr": ["port", "name"]
},
"MGMT_INTERFACE_IPV4_ADDR_WITH_IPV6_GW": {
"desc": "CONFIGURE MANAGEMENT INTERFACE WITH IPV4 ADDRESS BUT IPV6 GW ADDRESS.",
"eStrKey": "Must"
},
"MGMT_INTERFACE_IPV6_ADDR_WITH_IPV4_GW": {
"desc": "CONFIGURE MANAGEMENT INTERFACE WITH IPV6 ADDRESS BUT IPV4 GW ADDRESS.",
"eStrKey": "Must"
}
}
39 changes: 39 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/mgmt_port.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"MGMT_PORT_TEST": {
"desc": "LOAD MGMT PORT WITH ALIAS AND ADMIN_STATUS SUCCESSFULLY. VERIFY ADMIN_STATUS",
"eStrKey": "Verify",
"verify": {
"xpath": "/sonic-mgmt_port:sonic-mgmt_port/MGMT_PORT/MGMT_PORT_LIST[name='eth0']/name",
"key": "sonic-mgmt_port:admin_status",
"value": "up"
}
},
"MGMT_PORT_INVALID_NAME_PATTERN": {
"desc": "INCORRECT MANAGEMENT PORT NAME",
"eStrKey": "Pattern",
"eStr": ["eth"]
},
"MGMT_PORT_INVALID_SPEED": {
"desc": "INVALID SPEED",
"eStrKey": "Range",
"eStr": ["10|100|1000"]
},
"MGMT_PORT_INVALID_MTU": {
"desc": "INVALID MTU",
"eStrKey": "Range",
"eStr": "1500..9216"
},
"MGMT_PORT_DEFAULT_MTU": {
"desc": "VALIDATE DEFAULT MTU",
"eStrKey": "Verify",
"verify": {
"xpath": "/sonic-mgmt_port:sonic-mgmt_port/MGMT_PORT/MGMT_PORT_LIST[name='eth0']/name",
"key": "sonic-mgmt_port:mtu",
"value": 1500
}
},
"MGMT_PORT_INVALID_AUTONEG": {
"desc": "INVALID AUTONEG CONFIGURATION",
"eStrKey": "Pattern"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"MGMT_VRF_TEST": {
"desc": "LOAD MGMT VRF TABLE WITH mgmtVrfEnabled SET TO TRUE SUCCESSFULLY."
},
"MGMT_VRF_TEST_WITH_DEFAULT_VALUE": {
"desc": "LOAD MGMT VRF TABLE WITH DEFAULT mgmtVrfEnabled SUCCESSFULLY."
}
}
62 changes: 62 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/ntp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"NTP_SERVER_TEST": {
"desc": "LOAD NTP SERVER TABLE WITH ADDRESS WITH IPV4, IPV6 AND HOST NAME AS NTP SERVERS."
},
"NTP_SERVER_1_NEG_TEST": {
"desc": "LOAD NTP SERVER TABLE WITH EMPTY ADDRESS AS NTP SERVER.",
"eStrKey": "InvalidValue",
"eStr": ["server_address"]
},
"NTP_SERVER_2_NEG_TEST": {
"desc": "LOAD NTP SERVER TABLE WITH INVALID IP ADDRESS AS NTP SERVER.",
"eStrKey": "InvalidValue",
"eStr": ["server_address"]
},
"NTP_SERVER_3_NEG_TEST": {
"desc": "LOAD NTP SERVER TABLE WITH INVALID HOST NAME AS NTP SERVER.",
"eStrKey": "InvalidValue",
"eStr": ["server_address"]
},
"NTP_DEFAULT_VRF_TEST": {
"desc": "CONFIGURE NTP IN DEFAULT VRF."
},
"NTP_MGMT_VRF_TEST": {
"desc": "CONFIGURE NTP IN MGMT VRF."
},
"NTP_MGMT_VRF_INVALID_MGMT_VRF_STATE_TEST": {
"desc": "CONFIGURE NTP IN MGMT VRF WITH MGMT VRF DISABLED SHOULD BE REJECTED.",
"eStrKey": "Must"
},
"NTP_MGMT_VRF_WITH_NOEXIST_MGMT_VRF_TEST": {
"desc": "CONFIGURE NTP IN MGMT VRF WITHOUT MGMT VRF CONFIGURED SHOULD BE REJECTED.",
"eStrKey": "Must"
},
"NTP_VRF_INVALID_NAME": {
"desc": "CONFIGURE NTP IN INVALID VRF.",
"eStrKey": "Pattern",
"eStr": ["mgmt|default"]
},
"NTP_SRC_INTF": {
"desc": "CONFIGURE MULTIPLE INTERFACES AS NTP SOURCE INTERFACE."
},
"NTP_SRC_INTF_WITH_NONEXIST_ETH_PORT": {
"desc": "CONFIGURE NON-EXISTING ETHERNET INTERFACE AS NTP SOURCE INTERFACE.",
"eStrKey": "InvalidValue",
"eStr": ["src"]
},
"NTP_SRC_INTF_WITH_NONEXIST_LOOPBACK_INTF": {
"desc": "CONFIGURE NON-EXISTING LOOPBACK INTERFACE AS NTP SOURCE INTERFACE.",
"eStrKey": "InvalidValue",
"eStr": ["src"]
},
"NTP_SRC_INTF_WITH_NONEXIST_PORTCHANNEL_INTF": {
"desc": "CONFIGURE NON-EXISTING PORTCHANNEL INTERFACE AS NTP SOURCE INTERFACE.",
"eStrKey": "InvalidValue",
"eStr": ["src"]
},
"NTP_SRC_INTF_WITH_NONEXIST_MGMT_INTF": {
"desc": "CONFIGURE NON-EXISTING MGMT INTERFACE AS NTP SOURCE INTERFACE.",
"eStrKey": "InvalidValue",
"eStr": ["src"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"MGMT_INTERFACE_TEST": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0"
}
]
}
},
"sonic-mgmt_interface:sonic-mgmt_interface": {
"sonic-mgmt_interface:MGMT_INTERFACE": {
"MGMT_INTERFACE_LIST": [
{
"name": "eth0",
"ip_prefix": "10.11.12.13/16",
"gwaddr": "10.11.12.254"
},
{
"name": "eth0",
"ip_prefix": "2001:aa:aa::aa/64",
"gwaddr": "2001:aa:aa::fe",
"forced_mgmt_routes": [
"10.3.145.14",
"2001:aa:aa::aa",
"10.0.0.100/31",
"10.250.0.8/24"
]
}
]
}
}
},
"MGMT_INTERFACE_WITH_NON_EXIST_PORT": {
"sonic-mgmt_interface:sonic-mgmt_interface": {
"sonic-mgmt_interface:MGMT_INTERFACE": {
"MGMT_INTERFACE_LIST": [
{
"name": "eth0",
"ip_prefix": "2001:aa:aa::aa/64",
"gwaddr": "2001:aa:aa::fe"
}
]
}
}
},
"MGMT_INTERFACE_WITH_WRONG_PORT": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth1"
}
]
}
},
"sonic-mgmt_interface:sonic-mgmt_interface": {
"sonic-mgmt_interface:MGMT_INTERFACE": {
"MGMT_INTERFACE_LIST": [
{
"name": "eth0",
"ip_prefix": "10.11.12.13/16",
"gwaddr": "10.11.12.254"
}
]
}
}
},
"MGMT_INTERFACE_IPV4_ADDR_WITH_IPV6_GW": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0"
}
]
}
},
"sonic-mgmt_interface:sonic-mgmt_interface": {
"sonic-mgmt_interface:MGMT_INTERFACE": {
"MGMT_INTERFACE_LIST": [
{
"name": "eth0",
"ip_prefix": "10.11.12.13/24",
"gwaddr": "2001:aa:aa::aa"
}
]
}
}
},
"MGMT_INTERFACE_IPV6_ADDR_WITH_IPV4_GW": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0"
}
]
}
},
"sonic-mgmt_interface:sonic-mgmt_interface": {
"sonic-mgmt_interface:MGMT_INTERFACE": {
"MGMT_INTERFACE_LIST": [
{
"name": "eth0",
"ip_prefix": "2001:aa:aa::aa/64",
"gwaddr": "10.11.12.13"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"MGMT_PORT_TEST": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"alias": "eth0",
"name": "eth0",
"admin_status": "up",
"speed": 100,
"autoneg": "off",
"description": "management interface",
"mtu": 1500
}
]
}
}
},
"MGMT_PORT_INVALID_NAME_PATTERN": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "ethernet0"
}
]
}
}
},
"MGMT_PORT_INVALID_SPEED": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0",
"speed": 222
}
]
}
}
},
"MGMT_PORT_INVALID_MTU": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0",
"mtu": 500
}
]
}
}
},
"MGMT_PORT_DEFAULT_MTU": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0"
}
]
}
}
},
"MGMT_PORT_INVALID_AUTONEG": {
"sonic-mgmt_port:sonic-mgmt_port": {
"sonic-mgmt_port:MGMT_PORT": {
"MGMT_PORT_LIST": [
{
"name": "eth0",
"autoneg": "true"
}
]
}
}
}
}
Loading

0 comments on commit 506d4d1

Please sign in to comment.