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

Question: Is any sample code available to refer for parsing yang-patch notification #1657

Open
srikanthsubbaramu opened this issue Oct 23, 2024 · 6 comments
Labels
is:enhancement Request for adding new feature or enahncing functionality. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...)

Comments

@srikanthsubbaramu
Copy link

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

@michalvasko michalvasko added the is:question Issue is actually a question. label Oct 23, 2024
@michalvasko
Copy link
Member

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().

@srikanthsubbaramu
Copy link
Author

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

@michalvasko
Copy link
Member

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.

@srikanthsubbaramu
Copy link
Author

srikanthsubbaramu commented Oct 24, 2024

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

michalvasko added a commit to sysrepo/sysrepo that referenced this issue Oct 24, 2024
@michalvasko
Copy link
Member

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.

@michalvasko michalvasko added is:enhancement Request for adding new feature or enahncing functionality. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...) and removed is:question Issue is actually a question. labels Oct 24, 2024
@srikanthsubbaramu
Copy link
Author

Thank you Michal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:enhancement Request for adding new feature or enahncing functionality. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...)
Projects
None yet
Development

No branches or pull requests

2 participants