jdiff should support multiple ref key anchoring
lvrfrc87 opened this issue · 1 comments
As per json below, we might have multiple vrf and for each vrf multiple peer IPs - which are unique within each vrf. In the example below, we want to anchor global and 192.168.0.0. So regex would look like: $*$.peers.$*$.*.*.[accepted_prefixes,received_prefixes,sent_prefixes]
{
"global": {
"router_id": "10.255.255.1",
"peers": {
"192.168.0.0": {
"description": "",
"remote_id": "10.255.255.240",
"address_family": {
"ipv6": {
"received_prefixes": -1,
"sent_prefixes": -1,
"accepted_prefixes": -1
},
"ipv4": {
"received_prefixes": -1,
"sent_prefixes": -1,
"accepted_prefixes": -1
}
},
"remote_as": 30000,
"is_up": true,
"local_as": 30001,
"is_enabled": true,
"uptime": 699262
After analyzing the current code-base such pinning of the VRF key won't be possible without changing the current implementation of ref_key processing.
The proposal in this issue is to allow to use multi ref_keys like that:
"$*$.peers.$*$.*.*.[accepted_prefixes,received_prefixes,sent_prefixes]"
|-------------^
One for vrf one for peer IPs, but look where the peers key is pinned ... and yes this is a very intuitive way IMO.
However when you look at our unittest, for the same data structure when we want to assign the ref_key for peer IPs it's currently done like that:
"global.$peers$.*.*.ipv4.[accepted_prefixes,received_prefixes,sent_prefixes]"
|-----------^
Which returns this data:
[{'10.1.0.0': {'accepted_prefixes': 1000,
'received_prefixes': 1000,
'sent_prefixes': 1000}},
{'10.2.0.0': {'accepted_prefixes': 1000,
'received_prefixes': 1000,
'sent_prefixes': 1000}},
{'10.64.207.255': {'accepted_prefixes': 1000,
'received_prefixes': 1000,
'sent_prefixes': 1000}},
{'7.7.7.7': {'accepted_prefixes': 1000,
'received_prefixes': 1000,
'sent_prefixes': 1000}}]
Conclusion:
Current implementation to pin the ref_key for peer IPs expects that the $$ markers are used on the preceding key/path element "peers" and not on the exact key location, like proposed in this issue.
If you look at vrf in this case global, that's the first key in the data structure and there is no preceding key to pin it.
To implement multi-ref_key support we need to change the current behavior.
The process would look like this:
- re-implement
ref_keyprocessing to stick to the element which in fact needs to be pinned. - update
ref_keys in unittests, output data should not change, only theref_keymarkers will be moved right.