Question: Is any sample code available to refer for parsing yang-patch notification
srikanthsubbaramu opened this issue · 6 comments
Hi Michal,
We are trying to use establish push on change notification. We are receiving yang patch notification properly on our application, we want to refer sample code to understand this yang patch parsing.
Thanks,
Srikanth
There is no specific sample code, YANG data manipulation is performed fully by libyang so I am not sure what exactly are you asking. You are probably not using libnetconf2 so just parse the received notification yourself, using lyd_parse_op()
.
Thanks Michal, we are looking for a way to get the patch in xml to provide to consuming applications, so since the data may have multiple edits, we are looking to see if we can extract changes and provide as single xml
You can do anything you want using libyang parse and print functions. Unless you ask a more specific question, I cannot give you a more precise answer.
Hi Michal,
Thanks for helping,
we are doing a establish push subscription for a XPATH /ManagedElement/GNBCUCPFunction,
we added a Cell object for this XPath, the resulting notification in yangpatch data had both parent with create , and edits for child as well.
For example
<ManagedElement xmlns="urn:3gpp:sa5:_3gpp-common-managed-element">
<id>100</id>
<GNBCUCPFunction xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-gnbcucpfunction">
<id>100</id>
<NRCellCU xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellcu">
<id>10</id>
<attributes>
<cellLocalId>1010</cellLocalId>
<pLMNInfoList>
<mcc>289</mcc>
<mnc>101</mnc>
<sd>ff:ff:ff</sd>
<sst>57</sst>
</pLMNInfoList>
</attributes>
<NRCellCUConfig xmlns="urn:3gpp:sa5:_ran-nr-nrm-nrcellcu">
<PDCPConfigRef>1</PDCPConfigRef>
</NRCellCUConfig>
<NRCellRelation xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellrelation">
<id>1</id>
<attributes>
<nRTCI>10</nRTCI>
<cellIndividualOffset>
<rsrpOffsetSsb>0</rsrpOffsetSsb>
<rsrqOffsetSsb>0</rsrqOffsetSsb>
<sinrOffsetSsb>0</sinrOffsetSsb>
<rsrpOffsetCsiRs>0</rsrpOffsetCsiRs>
<rsrqOffsetCsiRs>0</rsrqOffsetCsiRs>
<sinrOffsetCsiRs>0</sinrOffsetCsiRs>
</cellIndividualOffset>
</attributes>
</NRCellRelation>
</NRCellCU>
</GNBCUCPFunction>
</ManagedElement>
When this block is added, we have about 53 edits, having both parent and child (repeated ) in yang patch,
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-push">
<patch-id>patch-1</patch-id>
<edit>
<edit-id>edit-1</edit-id>
<operation>create</operation>
<target>/_3gpp-common-managed-element:ManagedElement[id='100']/_3gpp-nr-nrm-gnbcucpfunction:GNBCUCPFunction[id='100']/_3gpp-nr-nrm-nrcellcu:NRCellCU[id='10']</target>
<value>
<NRCellCU xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellcu">
<id>10</id>
<attributes>
<cellLocalId>1010</cellLocalId>
<pLMNInfoList>
<mcc>289</mcc>
<mnc>101</mnc>
<sd>ff:ff:ff</sd>
<sst>57</sst>
</pLMNInfoList>
</attributes>
<NRCellRelation xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellrelation">
<id>1</id>
<attributes>
<nRTCI>10</nRTCI>
<cellIndividualOffset>
<rsrpOffsetSsb>0</rsrpOffsetSsb>
<rsrqOffsetSsb>0</rsrqOffsetSsb>
<sinrOffsetSsb>0</sinrOffsetSsb>
<rsrpOffsetCsiRs>0</rsrpOffsetCsiRs>
<rsrqOffsetCsiRs>0</rsrqOffsetCsiRs>
<sinrOffsetCsiRs>0</sinrOffsetCsiRs>
</cellIndividualOffset>
<NRCellCUConfig xmlns="urn:3gpp:sa5:_ran-nr-nrm-nrcellcu">
<PDCPConfigRef>1</PDCPConfigRef>
</NRCellCUConfig>
</NRCellCU>
</value>
</edit>
<edit>
<edit-id>edit-2</edit-id>
<operation>create</operation>
<target>/_3gpp-common-managed-element:ManagedElement[id='100']/_3gpp-nr-nrm-gnbcucpfunction:GNBCUCPFunction[id='100']/_3gpp-nr-nrm-nrcellcu:NRCellCU[id='10']/id</target>
<value>
<id xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellcu">10</id>
</value>
</edit>
<edit>
<edit-id>edit-3</edit-id>
<operation>create</operation>
<target>/_3gpp-common-managed-element:ManagedElement[id='100']/_3gpp-nr-nrm-gnbcucpfunction:GNBCUCPFunction[id='100']/_3gpp-nr-nrm-nrcellcu:NRCellCU[id='10']/attributes</target>
<value>
<attributes xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellcu">
<cellLocalId>1010</cellLocalId>
<pLMNInfoList>
<mcc>289</mcc>
<mnc>101</mnc>
<sd>ff:ff:ff</sd>
<sst>57</sst>
</pLMNInfoList>
</attributes>
</value>
</edit>
<edit>
<edit-id>edit-4</edit-id>
<operation>create</operation>
<target>/_3gpp-common-managed-element:ManagedElement[id='100']/_3gpp-nr-nrm-gnbcucpfunction:GNBCUCPFunction[id='100']/_3gpp-nr-nrm-nrcellcu:NRCellCU[id='10']/attributes/cellLocalId</target>
<value>
<cellLocalId xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcellcu">1010</cellLocalId>
</value>
</edit>
So we wanted to know what is the best mechanism to obtain this patch information without multiple edit for same objects,
Thanks,
Srikanth
Actually, these nested changes should probably not be reported so I have modified sysrepo this way. Unfortunately, delete
cannot be change because it has no value
node and only the node identifiers for each deleted node are reported.
Thank you Michal