Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c++ generation of mulpile versions of a yang model #1070

Open
ericjmonson opened this issue Oct 3, 2022 · 0 comments
Open

c++ generation of mulpile versions of a yang model #1070

ericjmonson opened this issue Oct 3, 2022 · 0 comments

Comments

@ericjmonson
Copy link

ericjmonson commented Oct 3, 2022

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Expected Behavior

It would be nice to be able to write an application that can talk to multple version of yang models. For example, we are using yang to talk to NCS55A2 devices, and a recent firmware update to one box caused our system to have some devices with an IOS version of 7.0.2 and some to have 7.3.2. These boxes are in different locations around the world, and updating all boxes at the same time is not always feasible.

We ran ydkgen on the following sents of yang models:
https://github.com/YangModels/yang/tree/main/vendor/cisco/xr/702
https://github.com/YangModels/yang/tree/main/vendor/cisco/xr/732

Using the following commands:
python3 ./generate.py --bundle <path_to_bundles>/cisco-ios-xr-702.json -cpp
python3 ./generate.py --bundle <path_to_bundles>/cisco-ios-xr-732.json -cpp

Where each of the bundles had the following name defined:
"name": "cisco-ios-xr-702",
"name": "cisco-ios-xr-732",

This worked well. After running through the build process, it created separate include paths and .a files to link against for each version. However, the one thing that doesn't work well, if a single source file in our application tries to reference a ydkgen include file from both of the versions that were generated, the build doesn't work due to the #ifndef at the beginning of the file being identical:

% head -n2 ydk_cisco_ios_xr_702/Cisco_IOS_XR_l2vpn_cfg.hpp
#ifndef CISCO_IOS_XR_L2VPN_CFG
#define CISCO_IOS_XR_L2VPN_CFG

% head -n2 ydk_cisco_ios_xr_732/Cisco_IOS_XR_l2vpn_cfg.hpp
#ifndef CISCO_IOS_XR_L2VPN_CFG
#define CISCO_IOS_XR_L2VPN_CFG

If the define in the ydkgen output also included the namespace as well as the name of the file, then both files could correctly be included from the same source file (ie something line this):

% head -n2 ydk_cisco_ios_xr_702/Cisco_IOS_XR_l2vpn_cfg.hpp
#ifndef CISCO_IOS_XR_702_CISCO_IOS_XR_L2VPN_CFG
#define CISCO_IOS_XR_702_CISCO_IOS_XR_L2VPN_CFG

% head -n2 ydk_cisco_ios_xr_732/Cisco_IOS_XR_l2vpn_cfg.hpp
#ifndef CISCO_IOS_XR_732_CISCO_IOS_XR_L2VPN_CFG
#define CISCO_IOS_XR_732_CISCO_IOS_XR_L2VPN_CFG

Current Behavior

Output of ydkgen ifndef at the beinging of each file is always identical no matter with version of the yang models you run it against.

Steps to Reproduce

See the expected behavior section above.

Your Script

Create a source file that includes and tries to use the output from two yang versions of ydkgen.
#include <ydk_cisco_ios_xr_702/Cisco_IOS_XR_l2vpn_cfg.hpp>
#include <ydk_cisco_ios_xr_732/Cisco_IOS_XR_l2vpn_cfg.hpp>
...

Logs

Compile fails

System Information

gcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant