cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1630
Views
5
Helpful
17
Replies

YDK not working 17.06.04 - Path is invalid: Cisco-IOS-XE-native:native

vaniat
Beginner
Beginner

On IOS versions 17.06.04 or 17.10.01 I am not able to load the yang modules, I get the following error:

ydk.errors.YInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-native:native

However, version 16.12.08 works without any issues. Seems that Yang models are placed in /root/.ydk/192.168.1.142. If this folder exists and has yang models from 16.12.08 version, and switch gets upgraded to 17.06.04, YDK works as "old" models are kept and not overwritten. If I however remove the folder and start from scratch, I get error. I tested also with 17.10.01 which exhibits the same issue...

I am generating python bindings using ydk-gen, however this seems to be an issue of specific version of models. 

Here are relevant logs (I removed what seemed to be irrelevant):

[INFO    ] Path where models are to be downloaded: /root/.ydk/192.168.1.142
[DEBUG   ] Creating libyang context in path: /root/.ydk/192.168.1.142
[ERROR   ] Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
[ERROR   ] Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
[ERROR   ] Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-vrrp-deviation" failed.
[ERROR   ] Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-vrrp-deviation" parsing failed.
[DEBUG   ] Creating root data node with path '/Cisco-IOS-XE-native:native'
[ERROR   ] Data is invalid according to the yang model. Libyang error: Module not found. Path: '/Cisco-IOS-XE-native'
[ERROR   ] Path 'Cisco-IOS-XE-native:native' is invalid
[CRITICAL] Failed to load grains defined in grain file cisco_ydk.cisco_ydk in function <LoadedFunc name='cisco_ydk.cisco_ydk'>, error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ydk/errors/error_handler.py", line 50, in handle_runtime_error
    yield
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 88, in _crud_read
    read_top_entity = crud_call(provider, top_filters)
RuntimeError: YInvalidArgumentError: Path is invalid: Cisco-IOS-XE-native:native

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/loader/__init__.py", line 943, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/proxy/extmods/1009-cisco/grains/cisco_ydk.py", line 37, in cisco_ydk
    return {"cisco_ydk": proxy["cisco_ydk.get_facts"]()}
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/proxy/extmods/1009-cisco/proxy/cisco_ydk.py", line 316, in get_facts
    result = crud_service.read(dev, read_filter)
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 60, in read
    return _crud_read(provider, read_filter, False, self._crud.read)
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 88, in _crud_read
    read_top_entity = crud_call(provider, top_filters)
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/ydk/errors/error_handler.py", line 69, in handle_runtime_error
    raise _exc
ydk.errors.YInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-native:native

 

1 Accepted Solution

Accepted Solutions

Try to edit file ~/.ydk/<your-device-ip>/Cisco-IOS-XE-native.yang by taking enum values "+" and "-" into double quotes, then rerun your app. Once the YANG module is in the temp repo, it will not be overwritten. If works, I suggest you to save the file(s) from temp repo into some safe place for future reuse.

 

View solution in original post

17 Replies 17

ygorelik
Cisco Employee
Cisco Employee

This is the core error:

[ERROR   ] Data is invalid according to the yang model. Libyang error: Invalid keyword "+".

I wonder what YANG model lines causing that error? Do you have repository of YANG models for IOS versions 17.06.04 or 17.10.01?  If you do, please archive the repository and attach to the discussion. I will try to reproduce the issue to get to the root cause.

Yan

vaniat
Beginner
Beginner

Attached.

I found that the yang models do not correspond to the latest revision that causes the pyang to fail model bundle build. I made some changes and built the bundle. Please check them out in the attachment. Install new bundle and try to run your script.

Unfortunately I do not have XE router with software release 17.06.04 and therefore cannot check the  RPC execution myself.

vaniat
Beginner
Beginner

Unfortunately it does not work. I get exactly the same error...

For your info, I am able to generate my own bundles from models derived from switch but pyang complains:

Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:606): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1582): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1585): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1597): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1744): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1747): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1921): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:2243): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:3945): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4032): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4156): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4450): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5557): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5560): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5573): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5752): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5755): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5942): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:6311): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1603): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1813): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1816): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1819): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1822): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1825): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1828): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1831): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1834): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1837): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1840): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1843): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1846): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1849): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1852): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1855): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1858): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1861): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3167): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3223): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3725): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2499 (at Cisco-IOS-XE-ipv6.yang:447): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ipv6"
Cisco-IOS-XE-native.yang:2499 (at Cisco-IOS-XE-ipv6.yang:471): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ipv6"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:230): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:239): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:668): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:723): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:855): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:917): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1115): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1130): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1163): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1178): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"

running pyang against models you sent me provides same errors:

~/profiles/bundles/yang/xe-1764$ pyang *
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:606): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1582): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1585): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1597): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1744): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1747): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:1921): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:2243): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:3945): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4032): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4156): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:4450): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5557): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5560): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5573): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5752): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5755): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:5942): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2526 (at Cisco-IOS-XE-interfaces.yang:6311): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-interfaces"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1603): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1813): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1816): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1819): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1822): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1825): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1828): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1831): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1834): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1837): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1840): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1843): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1846): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1849): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1852): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1855): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1858): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:1861): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3167): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3223): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2477 (at Cisco-IOS-XE-ip.yang:3725): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ip"
Cisco-IOS-XE-native.yang:2499 (at Cisco-IOS-XE-ipv6.yang:447): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ipv6"
Cisco-IOS-XE-native.yang:2499 (at Cisco-IOS-XE-ipv6.yang:471): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-ipv6"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:230): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:239): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:668): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:723): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:855): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:917): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1115): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1130): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1163): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"
Cisco-IOS-XE-native.yang:2796 (at Cisco-IOS-XE-logging.yang:1178): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-logging"

Those warnings can be ignored. It is obvious that all the yang module parsing issues were eventually resolved.

Could you share your script that gives you the error?

vaniat
Beginner
Beginner

In your last message you said: "I found that the yang models do not correspond to the latest revision that causes the pyang to fail model bundle build. I made some changes and built the bundle". What I meant with above is that I am also able to build the bundle without any changes to the models.

Anyway, here is a script I use:

def get_facts():
    """Return facts of the device."""

    dev = conn()
    facts = {
        "vendor": "Cisco",
        "os_version": "",
        "hostname": "",
        "serial_number": "",
        "model": "",
        "interfaces": [],
        "validate_capable": False
    }

    # Get hardware info
    hw_type = Cisco_IOS_XE_device_hardware_oper.HwType().hw_type_chassis
    hw_info_filter = Cisco_IOS_XE_device_hardware_oper.DeviceHardwareData.DeviceHardware.DeviceInventory()
    hw_info_filter.hw_type = hw_type
    hw_info_filter.hw_dev_index = 1

    # Get all possible interfaces
    native_filter = Cisco_IOS_XE_native.Native()
    fastethernet = native_filter.Interface.FastEthernet()
    fastethernet.name = YFilter.read
    gigabitethernet = native_filter.Interface.GigabitEthernet()
    gigabitethernet.name = YFilter.read
    twogigabitethernet = native_filter.Interface.TwoGigabitEthernet()
    twogigabitethernet.name = YFilter.read
    fivegigabitethernet = native_filter.Interface.FiveGigabitEthernet()
    fivegigabitethernet.name = YFilter.read
    tengigabitethernet = native_filter.Interface.TenGigabitEthernet()
    tengigabitethernet.name = YFilter.read
    twentyfivegige = native_filter.Interface.TwentyFiveGigE()
    twentyfivegige.name = YFilter.read
    fortygigabitethernet = native_filter.Interface.FortyGigabitEthernet()
    fortygigabitethernet.name = YFilter.read
    hundredgige = native_filter.Interface.HundredGigE()
    hundredgige.name = YFilter.read

    # Append all filters
    native_filter.interface.fastethernet.append(fastethernet)
    native_filter.interface.gigabitethernet.append(gigabitethernet)
    native_filter.interface.twogigabitethernet.append(twogigabitethernet)
    native_filter.interface.fivegigabitethernet.append(fivegigabitethernet)
    native_filter.interface.tengigabitethernet.append(tengigabitethernet)
    native_filter.interface.twentyfivegige.append(twentyfivegige)
    native_filter.interface.fortygigabitethernet.append(fortygigabitethernet)
    native_filter.interface.hundredgige.append(hundredgige)

    # Get software info
    native_filter.version = YFilter.read
    native_filter.hostname = YFilter.read

    # Join all filters
    read_filter = Filter(hw_info_filter, native_filter)

    # Get the results
    result = crud_service.read(dev, read_filter)

    # Split the results
    hw_info = result[hw_info_filter]
    native_info = result[native_filter]

    native_info_json = codec.encode(json_provider, native_info)

    facts.update(
        {
            "os_version": native_info.version,
            "hostname": native_info.hostname,
            "model": hw_info.hw_description,
            "serial_number": hw_info.serial_number,
            "interfaces": json.loads(native_info_json),
            "validate_capable": ("urn:ietf:params:netconf:capability:validate:1.1" in dev.get_capabilities())
        }
    )

    return facts

This is how I initialise the connection:

def init(opts):
    """
    Open the connection to the Cisco device, login, and bind to the
    Resource class
    """
    log.debug("Opening connection to cisco device")

    conn_args = copy.deepcopy(opts.get("proxy", {}))

    # This is SSH-based proxy, so it is not safe to enable
    # multiprocessing.
    opts["multiprocessing"] = False

    # Proxy minimum init variables
    if "address" not in conn_args:
        log.critical("No 'address' key found in pillar for this proxy.")
        return False
    if "port" not in conn_args:
        conn_args["port"] = 830
    if "username" not in conn_args:
        log.critical("No 'username' key found in pillar for this proxy.")
        return False
    if "password" not in conn_args:
        log.critical("No 'password' key found in pillar for this proxy.")
        return False
    if "protocol" not in conn_args:
        conn_args["protocol"] = "ssh"

    cisco_device["conn_args"] = conn_args
    cisco_device["conn_args"].pop("proxytype")

    try:
        cisco_device["conn"] = NetconfServiceProvider(**conn_args)
    except Exception as ex:
        log.error("%s : not able to initiate connection to the device", ex)
        cisco_device["initialized"] = False
        cisco_device["conn"] = None
        return

    cisco_device["initialized"] = True

Thanks for your help! 

vaniat
Beginner
Beginner

To try to understand, is this a bug on yang models in Cisco release or is this bug related to YDK kit? 

I have reproduced the issue, but at this point cannot tell you the root cause. The error appears during parsing of YANG model in libyang library, which complicates the debugging as this is third party software. I do not see a workaround and therefore suggest you open issue on the GitHub.

I am happy to report that YDK-0.9.1.1  is working well with the XE 17.6.4 models. That is new YDK release, which supports YANG 1.1. I encourage you to try the docker: ydksolutions/ydk-gen:0.9.1.1.

Please note, that 0.9.1.1 generated API is not compatible with 0.8.6.x, hence the model bundles need to be regenerated. 

Any feedback is greatly appreciated. 

vaniat
Beginner
Beginner

Thanks. I'll try to test it and let you know. I was not using docker in my setup, so not sure how to really migrate it. Is there a way I can use it from "host"? Or I just need to generate bundles which I can then import independently in project?

The release 0.9.1.1 is still in testing, but you can try to clone it with command:

git clone https://github.com/ygorelik/ydk-gen.git -b yang11

 

vaniat
Beginner
Beginner

Thank you. I'll give it a try now and let you know

 

vaniat
Beginner
Beginner

Successfully installed ydk==0.9.1.1 and generated bundle but I still get same error:

[ERROR   ] Ignored Libyang error: Invalid keyword "+".
[ERROR   ] Ignored Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
[ERROR   ] Ignored Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-vrrp-deviation" failed.
[ERROR   ] Ignored Libyang error: Module "Cisco-IOS-XE-vrrp-deviation" parsing failed.
[DEBUG   ] Creating root data node with path '/Cisco-IOS-XE-native:native'
[ERROR   ] Ignored Libyang error: Module not found or not implemented. Path: '/Cisco-IOS-XE-native'
[ERROR   ] Path 'Cisco-IOS-XE-native:native' is invalid
[INFO    ] The following CRITICAL message may not be an error; the proxy may not be completely established yet.
[CRITICAL] Failed to load grains defined in grain file cisco_ydk.cisco_ydk in function <LoadedFunc name='cisco_ydk.cisco_ydk'>, error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ydk/errors/error_handler.py", line 54, in handle_runtime_error
    yield
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 88, in _crud_read
    read_top_entity = crud_call(provider, top_filters)
RuntimeError: YInvalidArgumentError: Path is invalid: Cisco-IOS-XE-native:native

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/loader/__init__.py", line 943, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/proxy/extmods/1009-cisco/grains/cisco_ydk.py", line 37, in cisco_ydk
    return {"cisco_ydk": proxy["cisco_ydk.get_facts"]()}
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/proxy/extmods/1009-cisco/proxy/cisco_ydk.py", line 316, in get_facts
    result = crud_service.read(dev, read_filter)
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 60, in read
    return _crud_read(provider, read_filter, False, self._crud.read)
  File "/usr/local/lib/python3.8/dist-packages/ydk/services/crud_service.py", line 88, in _crud_read
    read_top_entity = crud_call(provider, top_filters)
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/ydk/errors/error_handler.py", line 73, in handle_runtime_error
    raise _exc
ydk.errors.YInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-native:native

 

Try to edit file ~/.ydk/<your-device-ip>/Cisco-IOS-XE-native.yang by taking enum values "+" and "-" into double quotes, then rerun your app. Once the YANG module is in the temp repo, it will not be overwritten. If works, I suggest you to save the file(s) from temp repo into some safe place for future reuse.

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: