Skip to content

Commit 1334c04

Browse files
ayurkiv-nvdajudyjoseph
authored andcommitted
[yang] add yang options for Context object (#10359)
#### Why I did it Need to pass LY_CTX_DISABLE_SEARCHDIR_CWD to Context in order to disable automatically searching for schemas in current working directory (which is by default searched automatically) #### How I did it add additional attribute into YANG context #### How to verify it Create some invalid link on switch : 1) **ln -s /usr/abc xxx** 2) run **spm list** --> There should not be these messages: ``` libyang[1]: Unable to get information about "xxx" file in "/tmp" when searching for (sub)modules (No such file or directory) libyang[1]: Unable to get information about "xxx" file in "/tmp" when searching for (sub)modules (No such file or directory) libyang[1]: Unable to get information about "xxx" file in "/tmp" when searching for (sub)modules (No such file or directory) libyang[1]: Unable to get information about "xxx" file in "/tmp" when searching for (sub)modules (No such file or directory) ```
1 parent b3f42fe commit 1334c04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sonic-yang-mgmt/sonic_yang.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313
class SonicYang(SonicYangExtMixin):
1414

15-
def __init__(self, yang_dir, debug=False, print_log_enabled=True):
15+
def __init__(self, yang_dir, debug=False, print_log_enabled=True, sonic_yang_options=0):
1616
self.yang_dir = yang_dir
1717
self.ctx = None
1818
self.module = None
@@ -46,7 +46,7 @@ def __init__(self, yang_dir, debug=False, print_log_enabled=True):
4646
self.preProcessedYang = dict()
4747

4848
try:
49-
self.ctx = ly.Context(yang_dir)
49+
self.ctx = ly.Context(yang_dir, sonic_yang_options)
5050
except Exception as e:
5151
self.fail(e)
5252

0 commit comments

Comments
 (0)