Comments (1)
I managed to reproduce this issue.
The values
map (containing the data to be processed by libyang & sysrepo) is sorted lexicographically on strings. However, there is a list in the mapping (/ietf-routing:routing/ribs/rib/routes/route
) with indexes that are greater or equal to 10 and path /path/to/list[10]
is lexicographically smaller than /path/to/list[1]
. Therefore this list index gets processed first by libyang and the subsequent processing of index 1 breaks everything.
Reproducer:
#include <libyang/Libyang.hpp>
#include <libyang/Tree_Data.hpp>
#include <libyang/Tree_Data.hpp>
#include <map>
#include <sysrepo-cpp/Session.hpp>
void valuesToYang(const std::map<std::string, std::string>& values, std::shared_ptr<::sysrepo::Session> session, std::shared_ptr<libyang::Data_Node>& parent)
{
for (const auto& [propertyName, value] : values) {
std::cout << "Processing node update " << propertyName << " -> " << value << std::endl;
if (!parent) {
parent = std::make_shared<libyang::Data_Node>(
session->get_context(),
propertyName.c_str(),
value.c_str(),
LYD_ANYDATA_CONSTSTRING,
LYD_PATH_OPT_OUTPUT);
} else {
parent->new_path(
session->get_context(),
propertyName.c_str(),
value.c_str(),
LYD_ANYDATA_CONSTSTRING,
LYD_PATH_OPT_OUTPUT);
}
}
}
int main()
{
auto srConn = std::make_shared<sysrepo::Connection>();
auto srSess = std::make_shared<sysrepo::Session>(srConn);
std::map<std::string, std::string> values;
for(int i = 1; i <= 10; i++) {
const auto yangPrefix = "/ietf-routing:routing/ribs/rib[name='ipv4-master']/routes/route[" + std::to_string(i) + "]/ietf-ipv4-unicast-routing";
values[yangPrefix + ":destination-prefix"] = "0.0.0.0/0";
}
libyang::S_Data_Node parent;
valuesToYang(values, srSess, parent);
return 0;
}
from velia.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from velia.