CESNET / netopeer2

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

config static-route failed Error "Node "static-routes" not found as a child of "protocol" node" #1540

Open songlinglingpml opened 4 months ago

songlinglingpml commented 4 months ago

Hi @michalvasko

I want to config static route, use openconfig-network-instance.yang and openconfig-local-routing.yang. But when I send netconf xml, it failed with error.

we are using following versions: netopeer v2.1.71, sysrepo v2.2.105, libyang v2.1.111

netconf xml

<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <running/>
  </target>
  <config>
    <network-instances xmlns="http://openconfig.net/yang/network-instance">
      <network-instance>
        <name>DEFAULT</name>
        <config>
          <name>DEFAULT</name>
        </config>
        <protocols>
          <protocol>
            <name>DEFAULT</name>
            <identifier xmlns:openconfig-policy-types="http://openconfig.net/yang/policy-types">openconfig-policy-types:STATIC</identifier>
            <config>
              <name>DEFAULT</name>
              <identifier xmlns:openconfig-policy-types="http://openconfig.net/yang/policy-types">openconfig-policy-types:STATIC</identifier>
            </config>
            <static-routes xmlns="http://openconfig.net/yang/local-routing">
              <static>
                <prefix>11.0.0.1/24</prefix>
                <config>
                  <prefix>11.0.0.1/24</prefix>
                </config>
                <next-hops>
                  <next-hop>
                    <index>1</index>
                    <config>
                      <next-hop>50.1.1.2</next-hop>
                      <metric>20</metric>
                    </config>
                  </next-hop>
                </next-hops>
              </static>
            </static-routes>
          </protocol>
        </protocols>
      </network-instance>
    </network-instances>
  </config>
</edit-config>

The error replay

<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="7">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>unknown-element</error-tag>
    <error-severity>error</error-severity>
    <error-message xml:lang="en">Node "static-routes" not found as a child of "protocol" node. (Data location "/openconfig-network-instance:network-instances/network-instance[name='DEFAULT']/protocols/protocol[identifier='openconfig-policy-types:STATIC'][name='DEFAULT']".)</error-message>
    <error-info>
      <bad-element>static-routes</bad-element>
    </error-info>
  </rpc-error>
</rpc-reply>

https://github.com/openconfig/public/blob/master/release/models/network-instance/openconfig-network-instance.yang 1708506027812

https://github.com/openconfig/public/blob/master/release/models/local-routing/openconfig-local-routing.yang 1708505996348

michalvasko commented 4 months ago

It is a grouping so it inherits the namespace of the uses, not from grouping. So just drop the new namespace declaration from static-routes and it should work.