[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)
```
This commit is contained in:
Andriy Yurkiv 2022-05-02 19:51:30 +03:00 committed by Judy Joseph
parent b3f42feeaf
commit 1334c0447f

View File

@ -12,7 +12,7 @@ i.e. it is mixin not parent class.
"""
class SonicYang(SonicYangExtMixin):
def __init__(self, yang_dir, debug=False, print_log_enabled=True):
def __init__(self, yang_dir, debug=False, print_log_enabled=True, sonic_yang_options=0):
self.yang_dir = yang_dir
self.ctx = None
self.module = None
@ -46,7 +46,7 @@ class SonicYang(SonicYangExtMixin):
self.preProcessedYang = dict()
try:
self.ctx = ly.Context(yang_dir)
self.ctx = ly.Context(yang_dir, sonic_yang_options)
except Exception as e:
self.fail(e)