Replies: 14 comments 2 replies
-
I think I got the general idea but am not sure about the exact functionality you need, maybe try to illustrate on an example. Regarding the XPath functionality, it is all private on purpose but once I understand the use-case some new public functions may be an option. Naturally, some XPath parsing was implemented mainly in sysrepo but having an internal implementation seemed like the better and cleaner solution than adapting libyang API. You can also look at its XPath API. It really simplifies parsing and is nice and easy to use but I have kept it in the API only for backwards compatibility because it is quite inefficient so it is not used by any of our projects. Just another reason why implementing XPath parsing tailored to your needs may be the best solution. |
Beta Was this translation helpful? Give feedback.
-
So, list schema nodes have The list So I have a user input xpath. I use that to obtain schema node set using
That's a generic walk. Now what I'd like to have is a way at each list node to take the opaque entry ptr, the schema node and an xpath parsed object (I guess?) and determine if this entry should be included based on the xpath object and it's position in path (given by schema node). I have Currently we use the user xpath as a prefix to start iterating downward from. So we use To support real user xpaths now all I can think to do is recurse with the |
Beta Was this translation helpful? Give feedback.
-
Perhaps there could be a |
Beta Was this translation helpful? Give feedback.
-
In fact, unless I've missed something, this |
Beta Was this translation helpful? Give feedback.
-
So you have described your solution, which I may have vaguely understood but I am missing the high-level description of the problem, add that please. Only that way I can make certain there is no solution using the existing API or some simple proprietary algorithm. Well, you have described something in the original post but it seems complex and I just do not understand all the details that I need to, you can try describing the input (XPath?) and the expected output. |
Beta Was this translation helpful? Give feedback.
-
OK not sure which part is the confusing part so I'll describe our current process, again and maybe you can tell me where you're losing it. All schema nodes have private FRR data which includes callbacks I mentioned previously Ok so far? Just try and imagine how to build state using callbacks from schema nodes and a path.. there's really no other way to do this. Ok so the process: We get an xpath from the user it points at a node call it First we need to get the nodes on the branch leading to 1 - We call lyd_new_path() - this creates a small data tree. We walk back from 2 - We walk the schema nodes from the root back to 3 - we now are back at This is what we currently have, is that good enough to understand the process? If not, please ask a targeted question on what doesn't make sense. :) |
Beta Was this translation helpful? Give feedback.
-
What I understand from this is that you have a solution that splits a full YANG data tree into individual schema nodes with their private data that allows creating the actual data nodes. The problem you are now having is that when you have an XPath, you somehow need to traverse all the relevant schema nodes and get their data nodes that ultimately create the full data tree selected by the XPath that you can return. Assuming this is correct, my question is why have you chosen this solution? Why are all the data fragmented based on their schema nodes? You have initially mentioned a centralized daemon and that is probably what needs to collect all the operational data chunks from all the managed daemons to satisfy some query. I am still missing the actual use-case, I can only think of a NETCONF (RESTCONF, or whatever) get RPC with an XPath filter and you are trying to provide the data for the reply or something similar. You have mentioned only an XPath and maybe it is not actually relevant. In any case, the first thing that comes to my mind is using sysrepo for this. You have all the daemons subscribed for providing their operational data and when you call |
Beta Was this translation helpful? Give feedback.
-
Yes. The entire point is to obtain the state that matches the xpath, and to do so efficiently (i.e., not by getting all the state and then filtering, but just calling the callbacks for the data that will match the xpath). So basically have an xpath driven walk through the schema tree obtaining the data nodes that correspond.
I don't understand this question, FRR management is based on YANG models (config and oper-state) how else would we organize it than by using the YANG model?
That's correct,
Or CLI, but yes some (frontend) client is requesting state from our YANG models.
We are sysrepo, I mean that Concrete example that works currently:
This is based on the model https://github.com/FRRouting/frr/blob/master/yang/frr-interface.yang which the zebra model augmenting https://github.com/FRRouting/frr/blob/master/yang/frr-zebra.yang This works fine and is very efficient using the process I described previously. What we don't have is if that xpath query is using anything more the explicit keys in the predicates, then that xpath doesn't point at anything specific node we can instantiate and grab the keys from the branch and walk downwards from, we need the xpath itself to help drive the data collection. BTW I mentioned maybe a single function earlier that might drive this process, but this won't work b/c we have to break the iteration up so other code in the daemon can run in between. Again, I think what we need is a function I can pass a partially built data tree to (what i've built so far), a specific schema node from that tree (where I last stopped), and it then tells me which schema nodes I need to collect data from next in order to fulfill the xpath query. |
Beta Was this translation helpful? Give feedback.
-
Here's a concrete example of something we don't support but want to: "show all interfaces in the "default" vrf"
|
Beta Was this translation helpful? Give feedback.
-
Well, you copying the functionality of sysrepo and requiring some new functions to do so does not make me too keen on adding them. And yes, you have described what it is doing exactly, sysrepo has lots of features and specifically for operational data, it supports both push and pull data (mentioned clearly in the docs). Okay, so I think I understand what you are trying to do and sysrepo attempts to do something similar, it also faces the problem of how to effectively collect the operational data without getting filtered-out subtrees. You can look at the function yourself but despite being only text-based, I think it supports a few more use-case than what your solution does. The idea is that whenever a new common XPath is found that does not work efficiently, support for it can be added. Additionally, it relies on the applications to subscribe to small subtrees of data because the only decision that can be made is whether to get data for a subscribed subtree or not. My belief is that what you are attempting (supporting "all" the XPaths) is pretty much impossible and that is the reason we have taken the opposite approach (support only common XPaths and iteratively add to them). XPath is incredibly complex and attempts at algorithms similar to what you described can only end in failure, I have enough experience from libyang. In other words, I will not provide any assistance nor new functions in libyang. So my suggestion is for you to explore sysrepo and try using it instead of your current solution and provide feedback. I see no reason to implement the same thing again when we can rather improve what exists already. |
Beta Was this translation helpful? Give feedback.
-
I mean this answer is really frustrating. Our |
Beta Was this translation helpful? Give feedback.
-
Could you at least elaborate, why sysrepo is not a solution for you and what your And if you are so certain you have described the new function so clearly and is so simple that go ahead and implement it, if the PR looks clear enough I will have no problem merging it. |
Beta Was this translation helpful? Give feedback.
-
I've spent a lot of time describing mgmtd in this thread.. As you aren't interested in helping at this point I don't want to keep doing design presentations. mgmtd is a solution for us that allows us to transition over to it in steps, utilizing our existing YANG infrastructure, supporting our legacy CLIs, and optimized exactly for our use case. I didn't start off asking for anything complex I: |
Beta Was this translation helpful? Give feedback.
-
We have stopped moving towards any solution and I have too much other work to continue this way. So, based on your description, you want to learn what schema nodes are referenced in XPath predicates, so just get the standalone predicates and call |
Beta Was this translation helpful? Give feedback.
-
In FRR we're building a centralize mgmt daemon.. Config for the system is stored in the daemon and sent to the protocol daemons based on matching a path prefix of interest. For oper-state however it's not workable to store operational state in a database as it's constantly changing (and may be quite large). So we need to query for it.
We've got a basic system setup using path prefixes as with config to send xpath queries to the protocol daemons, and in the protocol daemon we have meta-data we attach to the libyang schema nodes that contain callbacks to fetch data. So we walk the query xpath and use a combination of the callbacks
get_elem()
(some leaf value) andget_next()
,get_keys()
(get list elmeents and each elements keys) to build a operational data tree up.It would be nice if there were a way to integrate this sort of thing into libyang though, the primary reason being to better handle xpath queries. We currently only support simple "path" style queries, no wildcards, no functions etc..
The minimum help I think we could use, and it would be very helpful, is some help with xpath parsing and predicate evaluation. So when e.g., we reach a list and the user has specified some predicate we can walk the elements of the list and only use those which match the predicate. This is going to be very important e.g., when we have 1M routes and the user is trying to look at a subset.
Currently the xpath functionality is not public, it would be useful if part of it were made public, and specifically support for the above predicate testing. Maybe also walking the schema tree based on the xpath query would be nice too.
Does any of this sound doable? Has it already been done somewhere else (e.g., sysrepo/netopeer?)
Beta Was this translation helpful? Give feedback.
All reactions