You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
choice test_choice {
case test_case_one {
leaf test_num {
type uint16;
}
}
case test_case_two {
leaf test_range {
type string {
pattern '[0-9]{1,4}';
}
}
}
}
Take a snapshot of YANG model after modification then rerun YANG validation.
admin@bjw-can-3800-1:~$ cat /usr/local/yang-models/sonic-bgp-device-global.yang
module sonic-bgp-device-global {
namespace "http://github.com/Azure/sonic-bgp-device-global";
prefix bgp_device_global;
yang-version 1.1;
organization
"SONiC";
contact
"SONiC";
description
"SONIC Device-specific BGP global data";
revision 2022-06-26 {
description
"Initial revision";
}
container sonic-bgp-device-global {
container BGP_DEVICE_GLOBAL {
container STATE {
description "BGP device-specific global data";
leaf tsa_enabled {
type boolean;
default "false";
description
"When set to true, Traffic is shifted away (TSA), i.e, BGP routes are not advertised to neighboring routers";
}
choice test_choice {
case test_case_one {
leaf test_num {
type uint16;
}
}
case test_case_two {
leaf test_range {
type string {
pattern '[0-9]{1,4}';
}
}
}
}
} /* end of STATE container */
} /* end of BGP_DEVICE_GLOBAL container */
} /* end of top level container */
} /* end of module sonic-bgp-device-global */
admin@bjw-can-3800-1:~$ show run all | grep BGP_DEVICE_GLOBAL -A5
"BGP_DEVICE_GLOBAL": {
"STATE": {
"tsa_enabled": "false"
}
},
"BGP_NEIGHBOR": {
admin@bjw-can-3800-1:~$ python verify_configDB_yang.py
sonic_yang(6):Note: Below table(s) have no YANG models: CONSOLE_SWITCH, DHCP_SERVER, RESTAPI, bgpraw
sonic_yang(3):Data Loading Failed:string indices must be integers
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 1112, in loadData
self._xlateConfigDB(xlateFile=xlateFile)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 730, in _xlateConfigDB
self._xlateConfigDBtoYang(jIn, yangJ)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 716, in _xlateConfigDBtoYang
self._xlateContainer(cmap['container'], yangJ[key][subkey], \
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 670, in _xlateContainer
self._xlateContainerInContainer(ccontainer, yang, configC, table)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 631, in _xlateContainerInContainer
self._xlateContainer(ccontainer, yang[ccName], \
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 677, in _xlateContainer
leafDict = self._createLeafDict(model, table)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 381, in _createLeafDict
cases = choice['case']
TypeError: string indices must be integers
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/admin/verify_configDB_yang.py", line 12, in <module>
sy.loadData(configDbJson )
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 1122, in loadData
raise SonicYangException("Data Loading Failed\n{}".format(str(e)))
sonic_yang_ext.SonicYangException: Data Loading Failed
string indices must be integers
Describe the results you received:
admin@bjw-can-3800-1:~$ python verify_configDB_yang.py
sonic_yang(6):Note: Below table(s) have no YANG models: CONSOLE_SWITCH, DHCP_SERVER, RESTAPI, bgpraw
sonic_yang(3):Data Loading Failed:string indices must be integers
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 1112, in loadData
self._xlateConfigDB(xlateFile=xlateFile)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 730, in _xlateConfigDB
self._xlateConfigDBtoYang(jIn, yangJ)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 716, in _xlateConfigDBtoYang
self._xlateContainer(cmap['container'], yangJ[key][subkey], \
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 670, in _xlateContainer
self._xlateContainerInContainer(ccontainer, yang, configC, table)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 631, in _xlateContainerInContainer
self._xlateContainer(ccontainer, yang[ccName], \
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 677, in _xlateContainer
leafDict = self._createLeafDict(model, table)
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 381, in _createLeafDict
cases = choice['case']
TypeError: string indices must be integers
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/admin/verify_configDB_yang.py", line 12, in <module>
sy.loadData(configDbJson )
File "/usr/local/lib/python3.9/dist-packages/sonic_yang_ext.py", line 1122, in loadData
raise SonicYangException("Data Loading Failed\n{}".format(str(e)))
sonic_yang_ext.SonicYangException: Data Loading Failed
string indices must be integers
Describe the results you expected:
choice statement should not break yang validation.
admin@bjw-can-3800-1:~$ python verify_configDB_yang.py
sonic_yang(6):Note: Below table(s) have no YANG models: CONSOLE_SWITCH, DHCP_SERVER, RESTAPI, bgpraw
admin@bjw-can-3800-1:~$ echo $?
0
Output of show version:
admin@bjw-can-3800-1:~$ show ver
SONiC Software Version: SONiC.20220531.45
SONiC OS Version: 11
Distribution: Debian 11.8
Kernel: 5.10.0-18-2-amd64
Build commit: 1a8426fd17
Build date: Thu Nov 9 20:37:58 UTC 2023
Built by: cloudtest@1b5bef75c000002
Platform: x86_64-mlnx_msn3800-r0
HwSKU: ACS-MSN3800
ASIC: mellanox
ASIC Count: 1
Serial Number: MT2228X04010
Model Number: MSN3800-CS2ROS
Hardware Revision: A3
Uptime: 05:38:49 up 2 days, 1:07, 2 users, load average: 1.13, 1.22, 1.13
Date: Fri 15 Dec 2023 05:38:49
Output of show techsupport:
(paste your output here or download and attach the file here )
Additional information you deem important (e.g. issue happens only occasionally):
The text was updated successfully, but these errors were encountered:
Description
Tried use
choice
to identify different case. But it failed YANG validation if we addchoice
statement in YANG mode except forsonic-acl.yang
.Steps to reproduce the issue:
Add below
choice
statement to YANG model. This is a sample by mimickingsonic-acl.yang
: https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-templates/sonic-acl.yang.j2#L141-L155Take a snapshot of YANG model after modification then rerun YANG validation.
Describe the results you received:
Describe the results you expected:
choice
statement should not break yang validation.Output of
show version
:Output of
show techsupport
:Additional information you deem important (e.g. issue happens only occasionally):
The text was updated successfully, but these errors were encountered: