[yang-models]: Default value for leaf-lists and tests. (#6029)

Changes:
-- Add Default value for leaf-lists in ACL and portchannel.
-- Remove members in VLAN.
-- Test modifications.

Signed-off-by: Praveen Chaudhary<pchaudhary@linkedin.com>
This commit is contained in:
Praveen Chaudhary 2020-12-24 01:48:41 -08:00 committed by GitHub
parent 163ed6acff
commit ab0ee0bfae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 60 deletions

View File

@ -129,6 +129,10 @@ class Test_yang_models:
'desc': 'CRM BREAKOUT CFG FLEX COUNTER TABLE.',
'eStr': self.defaultYANGFailure['None']
},
'DEV_META_DEV_NEIGH_VERSION_TABLE': {
'desc': 'DEVICE_METADATA DEVICE_NEIGHBOR VERSION TABLE.',
'eStr': self.defaultYANGFailure['None']
},
'INCORRECT_VLAN_NAME': {
'desc': 'INCORRECT VLAN_NAME FIELD IN VLAN TABLE.',
'eStr': self.defaultYANGFailure['Pattern'] + ["Vlan"]
@ -180,8 +184,7 @@ class Test_yang_models:
'CRM_WITH_HIGH_THRESHOLD_ERR': {
'desc': 'CRM_WITH_HIGH_THRESHOLD_ERR must condition failure \
about high threshold being lower than low threshold.',
'eStr': self.defaultYANGFailure['high_threshold should be more \
than low_threshold']
'eStr': ['high_threshold should be more than low_threshold']
},
'CRM_WITH_CORRECT_USED_VALUE': {
'desc': 'CRM_WITH_CORRECT_USED_VALUE no failure.',
@ -390,6 +393,8 @@ class Test_yang_models:
try:
self.initTest()
self.loadYangModel(self.yangDir)
assert len(self.tests) != 0
print("Tests:{}".format(self.tests))
for test in self.tests:
test = test.strip()
if test in self.ExceptionTests:
@ -399,6 +404,7 @@ class Test_yang_models:
else:
raise Exception("Unexpected Test")
except Exception as e:
ret = FAIL * len(self.tests)
printExceptionDetails()
assert ret == 0

View File

@ -728,6 +728,54 @@
}
},
"DEV_META_DEV_NEIGH_VERSION_TABLE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "64850",
"mac": "00:11:22:33:44:55",
"hostname": "asw.dc",
"type": "ToRRouter",
"docker_routing_config_mode": "separated",
"hwsku": "Stone"
}
}
},
"sonic-device_neighbor:sonic-device_neighbor": {
"sonic-device_neighbor:DEVICE_NEIGHBOR": {
"DEVICE_NEIGHBOR_LIST": [
{
"port": "Eth18",
"name": "dccsw03.nw",
"peer_name": "Ethernet116"
},
{
"port": "Eth18",
"name": "dccsw02.nw",
"peer_name": "Ethernet114"
},
{
"port": "Eth18",
"name": "dccsw01.nw",
"peer_name": "Ethernet112"
},
{
"port": "Eth18",
"name": "dccsw04.nw",
"peer_name": "Ethernet118"
}
]
}
},
"sonic-versions:sonic-versions": {
"sonic-versions:VERSIONS": {
"DATABASE": {
"VERSION": "version_2_10_31"
}
}
}
},
"CRM_WITH_WRONG_PERCENTAGE": {
"sonic-crm:sonic-crm": {
"sonic-crm:CRM": {
@ -1189,44 +1237,7 @@
],
"vlanid": "111",
"mtu": "9216",
"admin_status": "up",
"members": [
"Ethernet8",
"Ethernet3",
"Ethernet0",
"Ethernet1",
"Ethernet6",
"Ethernet4",
"Ethernet5",
"Ethernet9",
"Ethernet2",
"Ethernet7",
"Ethernet32",
"Ethernet30",
"Ethernet31",
"Ethernet36",
"Ethernet34",
"Ethernet33",
"Ethernet35",
"Ethernet29",
"Ethernet21",
"Ethernet20",
"Ethernet23",
"Ethernet22",
"Ethernet27",
"Ethernet26",
"Ethernet18",
"Ethernet19",
"Ethernet14",
"Ethernet15",
"Ethernet16",
"Ethernet17",
"Ethernet10",
"Ethernet11",
"Ethernet12",
"Ethernet13",
"Ethernet28"
]
"admin_status": "up"
},
"Vlan777": {
"description": "pvlan",
@ -1235,15 +1246,7 @@
],
"vlanid": "777",
"mtu": "9216",
"admin_status": "up",
"members": [
"Ethernet9",
"Ethernet2",
"Ethernet8",
"Ethernet27",
"Ethernet14",
"Ethernet35"
]
"admin_status": "up"
}
},
"DEVICE_NEIGHBOR": {

View File

@ -264,7 +264,7 @@ module sonic-acl {
}
leaf-list ports {
/* union of leafref is allowed in YANG 1.1 */
/* union of leafref is allowed in YANG 1.1 */
type union {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
@ -272,7 +272,15 @@ module sonic-acl {
type leafref {
path /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:portchannel_name;
}
type string {
pattern "";
}
}
/* Today in SONiC, we do not delete the list once
* created, instead we set to empty list. Due to that
* below default values are needed.
*/
default "";
}
}
/* end of ACL_TABLE_LIST */

View File

@ -48,9 +48,19 @@ module sonic-portchannel {
leaf-list members {
/* leaf-list members are unique by default */
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
type union {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
}
type string {
pattern "";
}
}
/* Today in SONiC, we do not delete the list once
* created, instead we set to empty list. Due to that
* below default values are needed.
*/
default "";
}
leaf min_links {

View File

@ -155,14 +155,6 @@ module sonic-vlan {
leaf admin_status {
type stypes:admin_status;
}
leaf-list members {
/* leaf-list members are unique by default */
type leafref {
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:port_name";
}
}
}
/* end of VLAN_LIST */
}