CESNET / libyang

YANG data modeling language library
BSD 3-Clause "New" or "Revised" License
369 stars 292 forks source link

Errors with ietf-yang-schema-mount when importing configuration from xml file #2316

Open DDavisZhou opened 1 month ago

DDavisZhou commented 1 month ago

Hello, after upgrading to the specified version:

libyang:     3.4.2                      
libnetconf2: 3.5.1      
Sysrepo:     2.11.7
netopeer2:   2.2.31 

I encountered the following issue when installing 3gpp-common-subnetwork.yang:

[INF] Connection 72 created.
[INF] Module "_3gpp-common-subnetwork" was installed.
[ERR] No "ietf-yang-schema-mount" operational data set needed for parsing mounted data.
[ERR] No "ietf-yang-schema-mount" operational data set needed for parsing mounted data.
[INF] File "_3gpp-common-subnetwork@2021-01-16.yang" was installed.
[INF] Connection 72 destroyed.

I referred to "https://github.com/CESNET/netopeer2/issues/1651" to resolve this issue successfully (by using the current libyang development version).

However, when importing the configuration from the XML file, I encountered the following error again:

sysrepocfg --import=/etc/yang_model/3_3gpp/_3gpp-common-subnetwork.xml -d startup -f xml -m _3gpp-common-subnetwork -v3

[INF] Connection 194 created.
[ERR] No "ietf-yang-schema-mount" operational data set needed for parsing mounted data.
libyang error: Ext plugin "ly2 schema mount v1": Callback for getting ext data failed.
sysrepocfg error: Data parsing failed
[INF] Connection 194 destroyed.

Following YANG modules have already been installed or imported successfully.

ietf-inet-types                        | 2013-07-15 |
ietf-yang-types                        | 2013-07-15 |
ietf-yang-schema-mount                 | 2019-01-14 |
_3gpp-common-top                       | 2019-06-17 |
_3gpp-common-yang-extensions           | 2019-06-23 |
_3gpp-common-yang-types                | 2020-11-06 |
_3gpp-common-trace                     | 2024-01-26 |
_3gpp-common-fm                        | 2021-06-02 |
_3gpp-common-measurements              | 2021-07-22 |
_3gpp-common-subscription-control      | 2021-01-16 |
_3gpp-common-measurements              | 2021-07-22 |
_3gpp-common-subnetwork                | 2021-01-16 |

Could you please advise on what actions I can take to resolve this issue?

michalvasko commented 1 month ago

To parse mounted data, you need to provide operational data of ietf-yang-schema-mount in sysrepo. You need to understand all the details from the RFC, which is arguably not simple at all but that is no fault of mine. In short, you can use pull oper data (look at examples/oper_data_pull_example) to provide /ietf-yang-schema-mount:schema-mounts/mount-point. You can also look at the test that performs this.

DDavisZhou commented 1 month ago

Thank you very much for your response.

What do you mean is that (1) After installing the _3gpp-common-subnetwork modules and before importing the default configuration of _3gpp-common-subnetwork, I need to ensure that there is operational data of ietf-yang-schema-mount in sysrepo; (2) I can generate it by examples/oper_data_pull_example ; ?

michalvasko commented 1 month ago
  1. Yes, even according to the RFC specs I referenced before.
  2. No, the example is supposed to help you understand how to populate some operational data. For details look into the docs.
DDavisZhou commented 1 month ago

Thank you again for your reply.

I still feel a bit confused about how to generate operational data of 'ietf-yang-schema-mount' in sysrepo. Should I prepare an ietf-yang-schema-mount.xml file as follows and apply it to the operational data store using a command, or are there other methods I should consider?

ietf-yang-schema-mount.xml:

<schema-mounts xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount">
  <namespace>
    <prefix>subnet3gpp</prefix>
    <uri>urn:3gpp:sa5:_3gpp-common-subnetwork</uri>
  </namespace>
  <mount-point>
    <module>_3gpp-common-subnetwork</module>
    <label>children-of-SubNetwork</label>
    <config>true</config>
    <inline></inline>
    <shared-schema>
      <parent-reference>/subnet3gpp:SubNetwork/ExternalGNBCUCPFunction</parent-reference>
    </shared-schema>
  </mount-point>
</schema-mounts>

Additionally, before upgrading to the latest version, I used the following versions: libyang v2.0.7 sysrepo v2.0.1 libnetconf2 v2.0.1 Netopeer2 v2.0.0 In that process(install 3gpp-common-subnetwork.yang and then import configuration), I did not encounter similar issues. Could this be related to the upgrades made to the versions?

michalvasko commented 1 month ago

I still feel a bit confused about how to generate operational data of 'ietf-yang-schema-mount' in sysrepo.

That is why I have referenced the documentation, I am not going to explain in detail how to populate operational data when it is quite well explained, I think, in the text.

Could this be related to the upgrades made to the versions?

Yes because I do not think the version you have used supported schema-mount at all so the relevant YANG parts were simply silently skipped. I understand that you are confused but these issues are here to provide help with our projects, not with understanding YANG RFCs.

DDavisZhou commented 1 month ago

That is why I have referenced the documentation, I am not going to explain in detail how to populate operational data when it is quite well explained, I think, in the text.

Thank you, I will further study the document you referenced. By the way, may I ask if there is a switch to prevent parsing mounted data if only the yang-schema-mount node is defined in the yang file, but the relevant point is not used in the actual configuration?

michalvasko commented 1 month ago

I believe this is how it works, the data should not be requested unless they are required. But they are not needed only when parsing data with a mount point. I could tell you more only if you provided all the YANGs and data files so I can reproduce it and learn the details of your use-case.

DDavisZhou commented 3 weeks ago

I could tell you more only if you provided all the YANGs and data files so I can reproduce it and learn the details of your use-case.

Hello, I have prepared the _3gpp_common-subnetwork.xml file that I installed when I encountered a problem, and it is here. In fact, I have already installed the required yang module and imported other XML files; However, when importing the _3gpp_common-subnetwork.xml file, the following error was encountered:

[INF] Connection 194 created.
[ERR] No "ietf-yang-schema-mount" operational data set needed for parsing mounted data.
libyang error: Ext plugin "ly2 schema mount v1": Callback for getting ext data failed.
sysrepocfg error: Data parsing failed
[INF] Connection 194 destroyed.

Workflow: Install yang modules; Enable related features; Install configuration XML file;

I would greatly appreciate it if you could provide more information to help me understand and resolve the issues I am encountering.

michalvasko commented 3 weeks ago

Firstly, I am sorry but I must repeat what I said before, I will not be explaining how Schema Mount works in detail because to explain it is the purpose of its RFC. Also, you will have to understand it to use it, anyway, despite even YANG veterans struggling with it. What you need to do exactly is actually mentioned in the docs and it is what I have told you before so I am not sure what else to do.