CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
290 stars 186 forks source link

unable to edit-config #1575

Closed pdafv closed 1 month ago

pdafv commented 1 month ago

Hey there! I was using a netconfd's implementationf from yuma123 and ncclient to do some edit-config's on a model I created. Now I started using a Netopeer2 implementation and the same code does not seem to work anymore. I use lxml to create the XML payload. ncclient gives me an error saying "Missing XML namespace.". The payload I am sending is:

<config>
    <containername
        xmlns="urn:example:config2">
        <leafname>value</leafname>
    </containername>
</config>

I also tried adding "xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:example:config2"", which also does not work

I looked into the logs from the server, which gives me this error:

[ERR]: LY: Missing XML namespace. (path "/ietf-netconf:edit-config")

I saw somewhere that installed models are not "enabled" by default in sysrepo, so I tried running "application_changes_example" form sysrepo/examples" and passing my "mymodel" model as argument, and I am able to see the yang model's leafs.

I also tried doing an edit-config straight from netopeer2-cli using the plain XML payload shown before, which yields this:

> edit-config --target running --config=Desktop/payload.xml
ERROR
    type:     application
    tag:      unknown-element
    severity: error
    message:  Node "config" not found in the "config2" module. (path "/")
    info:
<bad-element xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">config</bad-element>

Any idea on how to solve this? Am fairly new to netconf/netopeer2

michalvasko commented 1 month ago

The original error is most likely the fault of the client. You can run netopeer2 as netopeer2-server -d -c MSG, which will print all the received NETCONF messages and you will most likely see that the edit-config element comes without a namespace, which is required.

The other error you see is because of the redundant config element in the payload.xml. Just remove it, and it should work.

pdafv commented 1 month ago

Hi Michal! I was able to edit-config using netopeer2-cli by removing the redundant config element and changing the NACM permissions beforehand.

However, with ncclient I still cannot do it. Without the config element, I get an error. But with it I receive the following XML in the server:

<?xml version="1.0" encoding="UTF-8"?>
<nc:rpc
    xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:706d8a75-1094-4326-b497-4423bd277379">
    <nc:edit-config>
        <nc:target>
            <nc:candidate/>
        </nc:target>
        <config>
            <containername
                xmlns="urn:example:config2">
                <leafname>value</leafname>
            </containername>
        </config>
    </nc:edit-config>
</nc:rpc>

And I get the "Missing XML namespace". I do not understand where the XML namespace is missing, because I receive both the xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" and the xmlns="urn:example:config2"

Again, I'm not sure if this is an ncclient issue or if it might be because I lack some knowledge in NETCONF in general. Glad if you could help in any way

pdafv commented 1 month ago

OK, I figured that the config element does not have the nc prefix, thus the Missing XML namespace error. The problem seems to be on ncclient's side, since I discovered several similar issues related to this (libyang issue 535). I will now close this issue. Thanks!

michalvasko commented 1 month ago

Oh, right, I have actually not noticed it and thought there is a problem with the prefixed nodes, we generally use only default namespaces.