cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1049
Views
10
Helpful
5
Replies

Contributing custom applications for NTP configuration

crhill@cisco.com
Cisco Employee
Cisco Employee

Just got my first YDK contribution merged (thanks for the awesome assistance  saalvare )!  We started with a relatively easy target with NTP.  Contributed two applications.

nc-create-config-ip-ntp-20-ydk.py - IPv4 server

nc-create-config-ip-ntp-22-ydk.py - IPv4 server with source interface and update-calendar knob

You can view them at:

https://git.io/v6KQ2

Give them a try and let me know if you have any comments.  While we tested them on a lab environment, I also tested them to a VIRL XRv router as well that I am using as a sandbox.

To offer some input, one thing I found useful, is viewing the CLI configuration inside an XML format (using a NETCONF client).  This approach provided me a nice visual of the YANG model command hierarchy/tree, including for referencing the YDK API documents.  Give this a try.

One last thing I would add is, I am a 21 year CCIE, so this network programmability is still relatively new (last 18 months or so I have been focusing more), and I would encourage all of the network engineers to start poking around in this stuff, including GitHub.  The YDK developers have done an awesome job in making the use of YANG models much easier with these API's that are generated.  There is always a learning curve of course, and while it is different than CLI, you can see the power of automation and scalable network element changes with this tool set and NC/YANG.  I am hoping to start targeting more YDK contributions that focus on my customer use cases, so this should be one of several applications I plan to contribute.

5 Replies 5

aradford
Cisco Employee
Cisco Employee

Nice job Craig.

saalvare
Cisco Employee
Cisco Employee

Thanks for the contribution.  Very much appreciated.  We're getting close to 200 sample apps! :-)

franklaszlo
Level 1
Level 1

I am very new to YDK and experimenting with configuration in a lab environment. Let me ask a silly question : how do I know if configuration was successful ? I get no error message, however debugging YFW on router displays the below error - well, actually a warning :

RP/0/0/CPU0:Sep 14 10:42:03.565 : netconf[1113]: WRN: YFW: ctx=1000da90,sysdb_find_data returned an error: 'sysdb' detected the 'warning' condition 'A SysDB client tried to access a nonexistent item or list an empty directory', sysdb_path: 'cfg/gl/ip-ntp/peer/default/ipv4/08080808/'

I understand that the configuration I am trying is not valid, but still, how do I find it out only via YDK app ?

All apps have a command line option to enable logging (-v | --verbose).  You bring up a good point of adding more details on how to debug the app and validate the results.  I've created an issue to add more details on that:

Add details on app execution and debugging · Issue #74 · CiscoDevNet/ydk-py-samples · GitHub

If there's any error in your configuration, YDK will raise an exception.  It may do so because local validation of your configuration failed (e.g. your config object is not compliant with the model) or because an error was received form the NETCONF/YANG agent running on the router.

Here's an example of debugging one of Craig's apps:

$ ./nc-create-config-ip-ntp-20-ydk.py -h

usage: nc-create-config-ip-ntp-20-ydk.py [-h] [-v] device

positional arguments:

  device         NETCONF device (ssh://user:password@host:port)

optional arguments:

  -h, --help     show this help message and exit

  -v, --verbose  print debugging messages

$

$

$ ./nc-create-config-ip-ntp-20-ydk.py ssh://xxxx:xxxx@pavarotti -v

2016-09-14 13:06:04,575 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider connected to pavarotti:None using ssh

2016-09-14 13:06:04,586 - ydk.providers.NetconfServiceProvider - DEBUG -

****************************

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:aa9454f8-7ab6-11e6-8c95-081196796e8c">

  <edit-config>

    <target>

      <candidate/>

    </target>

    <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

      <ntp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-cfg">

        <peer-vrfs>

          <peer-vrf>

            <vrf-name>default</vrf-name>

            <peer-ipv4s>

              <peer-ipv4>

                <address-ipv4>10.0.0.1</address-ipv4>

                <peer-type-ipv4>

                  <peer-type>server</peer-type>

                </peer-type-ipv4>

              </peer-ipv4>

            </peer-ipv4s>

          </peer-vrf>

        </peer-vrfs>

      </ntp>

    </config>

  </edit-config>

</rpc>

2016-09-14 13:06:04,701 - ydk.providers.NetconfServiceProvider - DEBUG -

<?xml version="1.0"?>

<rpc-reply message-id="urn:uuid:aa9454f8-7ab6-11e6-8c95-081196796e8c" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<ok/>

</rpc-reply>

2016-09-14 13:06:04,701 - ydk.providers.NetconfServiceProvider - DEBUG -

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

  <commit/>

</rpc>

2016-09-14 13:06:05,016 - ydk.providers.NetconfServiceProvider - DEBUG -

<?xml version="1.0"?>

<rpc-reply message-id="urn:uuid:aa9454f8-7ab6-11e6-8c95-081196796e8c" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<ok/>

</rpc-reply>

****************************

2016-09-14 13:06:05,017 - ydk.services.crud_service - INFO - CREATE operation completed

2016-09-14 13:06:05,247 - ydk.providers.netconf_provider - INFO -

NetconfServiceProvider disconnected from pavarotti:None using ssh

$

Thanks for the answer Santiago.

In fact, the logger shows the below line:

2016-09-15 12:02:14,066 - ydk.services.crud_service - INFO - CREATE operation completed

And got the answer :

<?xml version="1.0"?>

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

<ok />

</rpc-reply>

But in reality the configuration did not complete.

Create request was the following:

1.png

So actually I am unable to detect configuraiton errors.

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: