cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
521
Views
3
Helpful
13
Replies
Beginner

Pointers on how to test YDK app on some opensource router with NETCONF support ?

I am completely out of my wits now :(.

I was trying to use YDK on a GNS3 virtual set-up based on Cisco 15.2 IoS image. But looks like 15.2 IoS doesnt support the YDK (https://communities.cisco.com/thread/84989).

Is there any way for me to for e.g configure bgp or anyother openconfig modules using some virtual router environment ? Basically looking for any virtual environment that supports NETCONF and on which I can test my ydk apps ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi Roshan,

If you are looking for a management agent which supports netconf, you could look at the free version of confd:

Cisco DevNet: ConfD - Downloads

View solution in original post

13 REPLIES 13
Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi Roshan,

If you are looking for a management agent which supports netconf, you could look at the free version of confd:

Cisco DevNet: ConfD - Downloads

View solution in original post

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi,

I have been trying confd and tried to load mpls yang module using confd command and copying the .fxs file.

I am getting the below error when I run the sample mpls script. Any pointers as to what I have missed ?

show netconf-state shows that the module has got loaded.

tcs-ThinkCentre-M92p# show netconf-state | include mpls

netconf-state capabilities capability http://openconfig.net/yang/ldp?module=mpls-ldp&revision=2014-07-07

netconf-state capabilities capability http://openconfig.net/yang/mpls?module=mpls&revision=2014-12-12

netconf-state capabilities capability http://openconfig.net/yang/mpls-types?module=mpls-types&revision=2015-02-01

netconf-state capabilities capability http://openconfig.net/yang/rsvp?module=mpls-rsvp&revision=2014-07-07

netconf-state capabilities capability http://openconfig.net/yang/sr?module=mpls-sr&revision=2014-07-07

mpls                        2014-12-12  yang    http://openconfig.net/yang/mpls                         [ NETCONF ] 

mpls-igp                    2014-07-07  yang    http://openconfig.net/yang/mpls                         [ NETCONF ] 

mpls-ldp                    2014-07-07  yang    http://openconfig.net/yang/ldp                          [ NETCONF ] 

mpls-rsvp                   2014-07-07  yang    http://openconfig.net/yang/rsvp                         [ NETCONF ] 

mpls-sr                     2014-07-07  yang    http://openconfig.net/yang/sr                           [ NETCONF ] 

mpls-static                 2015-02-01  yang    http://openconfig.net/yang/mpls                         [ NETCONF ] 

mpls-te                     2014-07-07  yang    http://openconfig.net/yang/mpls                         [ NETCONF ] 

mpls-types                  2015-02-01  yang    http://openconfig.net/yang/mpls-types                   [ NETCONF ] 

tcs-ThinkCentre-M92p#

<session-id>64</session-id></hello>

2017-09-08 11:29:45,957 - ydk - INFO - Path where models are to be downloaded: /home/tcs/.ydk/0.0.0.0:2022

2017-09-08 11:29:45,957 - ydk - DEBUG - Creating libyang context in path: /home/tcs/.ydk/0.0.0.0:2022

2017-09-08 11:29:45,962 - ydk - DEBUG - Module 'ydk' Revision '2016-02-26'

2017-09-08 11:29:45,962 - ydk - DEBUG - Getting module ydk submodule none

2017-09-08 11:29:45,962 - ydk - DEBUG - Looking for file in folder: /home/tcs/.ydk/0.0.0.0:2022

2017-09-08 11:29:45,962 - ydk - DEBUG - Opening file /home/tcs/.ydk/0.0.0.0:2022/ydk@2016-02-26.yang

2017-09-08 11:29:45,962 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2017-09-08 11:29:45,968 - ydk - DEBUG - Module 'ietf-netconf' Revision '2011-06-01'

2017-09-08 11:29:45,968 - ydk - DEBUG - Getting module ietf-netconf submodule none

2017-09-08 11:29:45,969 - ydk - DEBUG - Looking for file in folder: /home/tcs/.ydk/0.0.0.0:2022

2017-09-08 11:29:45,969 - ydk - DEBUG - Opening file /home/tcs/.ydk/0.0.0.0:2022/ietf-netconf@2011-06-01.yang

2017-09-08 11:29:45,969 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'yang'

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'ietf-inet-types'

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'ietf-yang-types'

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'ietf-yang-library'

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'ydk'

2017-09-08 11:29:45,974 - ydk - DEBUG - Populating new module schema 'ietf-netconf'

2017-09-08 11:29:45,974 - ydk - INFO - Connected to 0.0.0.0 on port 2022 using ssh

2017-09-08 11:29:45,983 - ydk - INFO - Executing CRUD create operation

2017-09-08 11:29:45,983 - ydk - DEBUG - Creating root data node with path '/openconfig-mpls:mpls'

2017-09-08 11:29:45,983 - ydk - ERROR - Libyang ERROR: Module not found. Path: '/openconfig-mpls'

2017-09-08 11:29:45,983 - ydk - ERROR - Path 'openconfig-mpls:mpls' is invalid

Traceback (most recent call last):

  File "mpls.py", line 94, in <module>

    crud.create(provider, mpls)

  File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 112, in helper

    return func(self, provider, entity, *args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 30, in create

    return self._crud.create(provider, entity)

  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error

    _raise(_exc)

  File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 56, in _raise

    raise exc

ydk.errors.YPYInvalidArgumentError:  Path is invalid: openconfig-mpls:mpls

2017-09-08 11:29:45,992 - ydk - INFO - Disconnected from device

2017-09-08 11:29:45,993 - ydk - DEBUG - libnetconf TRACE: Writing message (session 64): <?xml version="1.0" encoding="UTF-8"?>

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">

  <close-session/>

</rpc>

2017-09-08 11:29:45,993 - ydk - DEBUG - libnetconf TRACE: Received message (session 64): <?xml version="1.0" encoding="UTF-8"?>

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"><ok/></rpc-reply>

Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Based on the error, I'm not sure if the openconfig-mpls model is being downloaded correctly. YDK uses the get-schema RPC to download models. Can you make sure you have correctly set up this? See this for details:

How to set up ConfD for NETCONF's get-schema rpc call to work? - Other Northbound Interfaces - ConfD User Community

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Got it working fine now with confd. I had to clean up all yang modules from confd directory and again manually create fxs file from yang modules and copy the same into etc/confd.

Thanks all for your help.

Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Great! Glad it is working now.

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Extremely sorry to be asking again but as a next step, I tried creating my own yang file as shown below.

module rosh {

    container rosh {

        uses config;

    }

   

    grouping config {

        leaf version {

            ...

        }

        ....

        container ospf {

            container graceful-restart {

                ....

            }

        }

    }

}

I generated the ydk libraries using ydk-gen and installed the same. Now when I am trying to execute the script which uses the python libraries I am getting the below error.  Looks like some issue with the yang file I created.

Ydk-gen creates the python attribute "_perform_setattr". When I compared it with the openconfig library I see the func not present as part of the mpls lib.

My ydk lib :

    def __setattr__(self, name, value):

        self._perform_setattr(Configuration, ['version'], name, value)

Openconfig MPLS ydk lib :

                def __setattr__(self, name, value):

                self._check_monkey_patching_error(name, value)

                with _handle_type_error():

                    if name in self.__dict__ and isinstance(self.__dict__[name], YList):

                        raise YPYModelError("Attempt to assign value of '{}' to YList ldata. "

                                            "Please use list append or extend method."

                                            .format(value))

Couple of questions from my side :

1) Can I use ydk-gen to create libraries for custom yang files ? ( I beleive yes, pls correct me)

2) Under what conditions does _perform_setattr gets created ? I checked file :printer/python/class_inits_printer.py:_print_class_setattr_body" but didnt quiet understand it.

3) Do I have to implement the func _perform_setattr ?

Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi Roshan,

This is caused by a mismatch between the ydk core and the bundle versions. Please reinstall the ydk core from your ydkgen repository. To do this:

pip uninstall ydk -y

cd ydk-gen/sdk/python/core

python setup.py sdist

pip install dist/ydk*.tar.gz

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi Abhirame,

Thanks for your input. I am trying to generate the source and install as suggested by you but getting error when installing the new ydk core. Installing ydk core from ydk-py works fine but when done from ydk-gen it gives error.

Below are the steps I followed :

1) $ sudo apt-get install libcurl4-openssl-dev libpcre3-dev libssh-dev libxml2-dev libxslt1-dev libtool-bin cmake python3-dev python-dev ===========> Works fine

2)./generate.py --python --core ===========> Works fine

3)pip install gen-api/python/ydk/dist/ydk*.tar.gz  ===========> Gives the below error

4) generate and install bundle ===========> Works fine

   $ ./generate.py --python --bundle profiles/<name-of-profile>.json

   $ pip install gen-api/python/<name-of-bundle>-bundle/dist/ydk*.tar.gz

I was going through the below thread but not able to make out how exactly it was resolved ?

https://communities.cisco.com/thread/84511?start=0&tstart=0

Error:

======

   Scanning dependencies of target ydk_

    [ 50%] Building CXX object CMakeFiles/ydk_.dir/python.cpp.o

    /tmp/pip-cDhU42-build/python.cpp:22:35: fatal error: ydk/restconf_client.hpp: No such file or directory

    compilation terminated.

    CMakeFiles/ydk_.dir/build.make:62: recipe for target 'CMakeFiles/ydk_.dir/python.cpp.o' failed

    make[2]: *** [CMakeFiles/ydk_.dir/python.cpp.o] Error 1

    CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ydk_.dir/all' failed

    make[1]: *** [CMakeFiles/ydk_.dir/all] Error 2

    Makefile:83: recipe for target 'all' failed

    make: *** [all] Error 2

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "/tmp/pip-cDhU42-build/setup.py", line 157, in <module>

        zip_safe=False,

      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup

        dist.run_commands()

      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands

        self.run_command(cmd)

      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command

        cmd_obj.run()

      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/install.py", line 61, in run

        return orig.install.run(self)

      File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run

        self.run_command('build')

      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command

        self.distribution.run_command(command)

      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command

        cmd_obj.run()

      File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run

        self.run_command(cmd_name)

      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command

        self.distribution.run_command(command)

      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command

        cmd_obj.run()

      File "/tmp/pip-cDhU42-build/setup.py", line 69, in run

        self.build_extension(ext)

      File "/tmp/pip-cDhU42-build/setup.py", line 94, in build_extension

        subprocess.check_call(['cmake', '--build', '.'], cwd=self.build_temp)

      File "/usr/lib/python2.7/subprocess.py", line 541, in check_call

        raise CalledProcessError(retcode, cmd)

    subprocess.CalledProcessError: Command '['cmake', '--build', '.']' returned non-zero exit status 2

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi Abhirame,

Please dont bother I got it fixed.

I had to update clang on my ubuntu machine and than compile both cpp core and python core to be able to install the same.

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Hi,

Any pointers as to how can I debug NetconfServiceProvider.

When from my application script I execute the below netconf api I get the error as shown.

But the same thing works well with ssh as in "ssh -p 830 test@172.16.172.128 -s netconf".

Tried the same with non-default port using both ssh and app.

>>>provider = NetconfServiceProvider(address='172.16.172.128', port=830, username='test', password='test123', protocol='ssh')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

RuntimeError: YCPPClientError: Could not connect to 172.16.172.128

Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Can you make sure you are specifying the correct port when connecting to the device?

Highlighted
Beginner

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

Yes, the port numbers are correct. I tried to capture packets for both ssh and netconfserviceprovider transaction and I see only one difference.

For ssh case one of the the TCP ACK from my machine to the DUT shows up as "SSH-2. 0-OpenSSH_7.2" and for ydk case it shows as "SSH-2. 0-libssh-0.6.3"

Could this be the cause of the issue ? Is there a way for me to change the ssh for netconfserviceprovider from libssh to openssh ?

Highlighted
Cisco Employee

Re: Pointers on how to test YDK app on some opensource router with NETCONF support ?

You may want to try the YDK sandbox on dcloud.cisco.com.  Look for "Cisco IOS XR YANG Development Kit Sandbox" in the catalog.  When you instantiate the sandbox, you get a Linux host acting as controller for two IOS XR devices connected back to back.  The controller has YDK pre-installed with hundreds of sample apps.  Note that dcloud also supports SSL VPN connections, so you can connect remotely to the sandbox and run the apps from your own development environment.  If you're new to dcloud, check out the dCloud YouTube channel.