Skip to content

Commit 62d3c24

Browse files
authored
[sonic-yang] Backlinks are none when there is 0 backlinks (#8187)
Backlinks are none when there is 0 backlinks. without this change backlinks.number() throws an exception when backlinks==None.
1 parent 604becd commit 62d3c24

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/sonic-yang-mgmt/sonic_yang.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def find_data_dependencies(self, data_xpath):
526526

527527
schema_node = ly.Schema_Node_Leaf(data_node.schema())
528528
backlinks = schema_node.backlinks()
529-
if backlinks.number() > 0:
529+
if backlinks is not None and backlinks.number() > 0:
530530
for link in backlinks.schema():
531531
node_set = node.find_path(link.path())
532532
for data_set in node_set.data():

src/sonic-yang-mgmt/tests/libyang-python-tests/test_SonicYang.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@
5959

6060
"dependencies":[
6161
{"xpath":"/test-port:port/PORT/PORT_LIST[port_name='Ethernet8']/port_name",
62-
"dependencies":
63-
["/test-acl:acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='PACL-V6']/ports[.='Ethernet8']",
64-
"/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='10.1.1.64/26']/interface",
65-
"/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='2000:f500:40:a749::/126']/interface"]}
62+
"dependencies":
63+
["/test-acl:acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='PACL-V6']/ports[.='Ethernet8']",
64+
"/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='10.1.1.64/26']/interface",
65+
"/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='2000:f500:40:a749::/126']/interface"]},
66+
{"xpath":"/test-port:port/PORT/PORT_LIST[port_name='Ethernet8']/alias",
67+
"dependencies":[]}
6668
],
6769
"schema_dependencies":[
6870
{"xpath":"/test-port:port/test-port:PORT/test-port:PORT_LIST/test-port:port_name",

0 commit comments

Comments
 (0)