cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1455
Views
15
Helpful
20
Replies

How to use ydk-cpp examples?

Mike Fisher
Level 1
Level 1

There are ydk-cpp examples posted at https://github.com/ygorelik/ydk-gen/tree/master/sdk/cpp/samples for Yang Development Kit (ydk) version 0.8.6.4.  The readme file is very vague.  It provides a command line syntax of how to run the application bgp_xr_write.  However, that application doesn't even seem to be an executable target in the CMakeLists.txt file.  Also, it looks like the example applications all require a device ip address to communicate with.  However, there is no example device provided or an explanation of where an example device can be found to use for testing the sample apps.  Can I use a simulated device (i.e. a software program) for trying out/testing these sample apps?  If so, where can I find a simulated device?

1 Accepted Solution

Accepted Solutions

@ygorelik  Thank you so much for your help.  After a few iterations of trial and error, I was able to get the sample apps to build and run per your new README file with a few modifications.  For instance, I did the following different:

  1. Used the provided Docker file to create an image.
  2. Downloaded the Yang Models from https://github.com/YangModels/yang.
  3. Created a container from the image and mounted a host folder containing the Yang Models.
  4. Used your suggestion for building the Openconfig bundle:  "python generate.py --bu profiles/bundles/openconfig_0_1_9.json --cpp -is"
  5. Used the Yang Models folder as the repo for building cisco_ios_xr bundler per your instructions.

Finally, I have a couple of suggestions regarding the YDK C++ sdk.  Where would be an appropriate place to log those?  Similarly, I would like to log my issues with getting the YDK to build on CentOS 8 stream.  Where should I log the build issue?

View solution in original post

20 Replies 20

Alexander Stevenson
Cisco Employee
Cisco Employee

Hello Mike,

You're looking at a forked repo there. I would always recommend checking out the original repo first and then raising an issue there, if necessary, to make sure the authors see it.

https://github.com/CiscoDevNet/ydk-gen/issues

 

Mike Fisher
Level 1
Level 1

I looked at the C++ examples at https://github.com/CiscoDevNet/ydk-gen and they look the same.  The Readme file looks about the same also.  The Readme does not tell you how to setup the server side to connect to in order to use the sample client applications.  I assume that you need a device to connect to or a simulated device.  Anyway, I looked at the issues URL that you suggested and when I tried to create an issue it says this:  "Issue tracker is ONLY used for reporting bugs. Please use the [YDK Community](https://communities.cisco.com/community/developer/ydk) for any support issues.".   When I go to that link it takes me to the community page and I see my original post.  My issue is really a support question not a bug.  Did I post my question to the wrong area?

There is an old thread here https://community.cisco.com/t5/yang-tools/ydk-cpp-installation/td-p/3508747 and these docs also https://hub.docker.com/r/ydkdev/ydk-gen - but we can also tag the owner of that link you share the awesome @yangorelik for more help

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Hello @bigevilbeard

The ydk-cpp last release code was built with ydk-gen 0.8.3. Unfortunately it is no longer maintained. Therefore, as suggested above, you need to switch to ydk-gen official release at https://github.com/CiscoDevNet/ydk-gen, which is 0.8.6.3. This is an open source code. If you need to make changes for your tasks, please make a fork and go ahead. The contribution to the main branch is always welcome. You just need to comply with contributions requirements. My fork under https://github.com/ygorelik/ydk-gen is for my own development and testing only; some of its content might not work.

The samples were developed with assumption that model bundles openconfig, cisco-ios-xr and cisco-ios-xe are generated and installed on your system. You might minimize number of packages required by altering CMakeLists.txt file. You also might consider generating partial bundles just to satisfy the samples need. Please check this method in README.md file.

You also always free to open an issue under https://github.com/CiscoDevNet/ydk-gen/issues if something is not working as designed.

@ygorelik   Thank you for confirming what @Alexander Stevenson had posted.

@bigevilbeard  Thank you for the reply.  I looked at those links and they provide information about building the YDK.  I was able to build the core YDK, the model bundles, etc.  I have also built the sample code applications.  My question is more about how to use the sample applications.  The sample applications all seem to be related to bgp.  I believe that I need a network device like a router to connect the sample applications to.  Unfortunately, I do not yet have a router to connect to.  I think that I could use a simulated router for trying out the sample applications, but I don't know if there is an open source/free router emulator available that would be suitable.   I attempted to use the lighty-netconf-simulator (https://github.com/PANTHEONtech/lighty) , but didn't have any luck.  Maybe I wasn't using it correctly.  Anyway, do you have any suggestions for a simulated router?

@Mike Fisher in the past i ran XR/XE device in via Vagrant locally.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

FYI. I have fixed the C++ samples and documentation. You can find them in my fork here. Feel free to try the sample apps with confd or any XR router.

@ygorelik  Thank you so much for updating the C++ samples and documentation.   From what I have read so far, the documentation looks fantastic.  I will download the updates, give it a try using confd, and report back.  Thanks again.

Mike Fisher
Level 1
Level 1

@ygorelik  I am having trouble building the YDK in my CentOS 8 stream environment.  So, I tried using the docker image with the command "docker run -it ydksolutions/ydk-gen:0.8.6.4", but I get the following error:


[fisher_m@localhost ydk-gen]$ docker run -it ydksolutions/ydk-gen:0.8.6.4
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Resolved "ydksolutions/ydk-gen" as an alias (/home/fisher_m/.cache/containers/short-name-aliases.conf)
Trying to pull docker.io/ydksolutions/ydk-gen:0.8.6.4...
Error: initializing source docker://ydksolutions/ydk-gen:0.8.6.4: reading manifest 0.8.6.4 in docker.io/ydksolutions/ydk-gen: manifest unknown: manifest unknown

Is the Docker run command correct?

The Build 4 of release 0.8.6 is still in development, therefore the docker with tag 0.8.6.4 has not been built.

Regarding CentOS-8 Stream. It supposed to work, at least I have tested it. Please supply more info for the installation failure. This is separate from the discussion subject, so it would be appropriate to move it to new discussion.

Mike Fisher
Level 1
Level 1

@ygorelik  I was able to build a ydk docker image using the provided Dockerfile.  The image runs and the container contains your updates.  I will try out your sample documentation instructions tomorrow.  Thanks for your help.

Mike Fisher
Level 1
Level 1

@ygorelik I followed the new samples README instructions to build the YDK C++ Core, build the Model Bundles, and build the sample apps.  However, when I attempt to build the sample apps in the docker container, I get the following compiler error:

root@07cd6a882237:~/ydk-gen/sdk/cpp/samples/build# make
Scanning dependencies of target bgp_routing_policy_create
[  4%] Building CXX object CMakeFiles/bgp_routing_policy_create.dir/bgp_routing_policy_create.cpp.o
/root/ydk-gen/sdk/cpp/samples/bgp_routing_policy_create.cpp:20:10: fatal error: ydk_openconfig/openconfig_bgp.hpp: No such file or directory
 #include "ydk_openconfig/openconfig_bgp.hpp"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/bgp_routing_policy_create.dir/build.make:62: recipe for target 'CMakeFiles/bgp_routing_policy_create.dir/bgp_routing_policy_create.cpp.o' failed
make[2]: *** [CMakeFiles/bgp_routing_policy_create.dir/bgp_routing_policy_create.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/bgp_routing_policy_create.dir/all' failed
make[1]: *** [CMakeFiles/bgp_routing_policy_create.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
root@07cd6a882237:~/ydk-gen/sdk/cpp/samples/build# 

Also, I noticed that there is a problem with the following command in the instructions:

export REPO="~/yang-models/yang/vendor/cisco/xr/751"

The path that is being assigned to REPO does not exist, even after installing the YDK C++ core.

Am I missing a step?  Where does the above path get created?

Based on the error, you did not install the openconfig bundle.

The REPO setting is an example specific to my computer. You are going to define your on your computer.