mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 06:30:19 -07:00
nso_config handle data.not_found in exists for nested lists (#35267)
Recent NSO can return data.not_found error on exists when parent list entries does not exist. Handle this and return as false. Fixes: #35264
This commit is contained in:
parent
b8e8fb48a8
commit
b7f815ba89
2 changed files with 38 additions and 2 deletions
|
@ -140,8 +140,16 @@ class JsonRpc(object):
|
|||
|
||||
def exists(self, path):
|
||||
payload = {'method': 'exists', 'params': {'path': path}}
|
||||
resp, resp_json = self._read_call(payload)
|
||||
return resp_json['result']['exists']
|
||||
try:
|
||||
resp, resp_json = self._read_call(payload)
|
||||
return resp_json['result']['exists']
|
||||
except NsoException as ex:
|
||||
# calling exists on a sub-list when the parent list does
|
||||
# not exists will cause data.not_found errors on recent
|
||||
# NSO
|
||||
if 'type' in ex.error and ex.error['type'] == 'data.not_found':
|
||||
return False
|
||||
raise
|
||||
|
||||
def create(self, th, path):
|
||||
payload = {'method': 'create', 'params': {'th': th, 'path': path}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue