[NETCONF-367] Error parsing namespace when using YANG PATCH with absolute target path Created: 09/Mar/17  Updated: 31/Jan/22  Resolved: 31/Jan/22

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: 2.0.13

Type: Bug
Reporter: Wenbo Hu Assignee: Samuel Schneider
Resolution: Won't Do Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 7949

 Description   

When we try to create and merge with an absolute target path, it works well.
The namespace can be solved based on the value of the operation.
Request as below:
Request as below:
PATCH http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/iosxrv-7/yang-ext:mount/
Payload as below:
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
<patch-id>VPN-CREATION-1</patch-id>
<comment>Create VPN-1</comment>
<edit>
<edit-id>1</edit-id>
<operation>create</operation>
<target>/Cisco-IOS-XR-infra-rsi-cfg:vrfs/vrf</target>
<value>
<vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-rsi-cfg">
<vrf-name>vpn-78</vrf-name>
<create></create>
<afs>
<af>
<af-name>ipv6</af-name>
<saf-name>unicast</saf-name>
<topology-name>default</topology-name>
<create></create>
</af>
<af>
<af-name>ipv4</af-name>
<saf-name>unicast</saf-name>
<topology-name>default</topology-name>
<create></create>
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">
<import-route-targets>
<route-targets>
<route-target>
<type>as</type>
<as-or-four-byte-as>
<as-xx>0</as-xx>
<as>4804</as>
<as-index>1</as-index>
<stitching-rt>0</stitching-rt>
</as-or-four-byte-as>
</route-target>
</route-targets>
</import-route-targets>
<export-route-targets>
<route-targets>
<route-target>
<type>as</type>
<as-or-four-byte-as>
<as-xx>0</as-xx>
<as>4804</as>
<as-index>1</as-index>
<stitching-rt>0</stitching-rt>
</as-or-four-byte-as>
</route-target>
</route-targets>
</export-route-targets>
</bgp>
</af>
</afs>
<description>vrf for VPN which connects each site from iosxrv-7 and iosxrv-8</description>
<vpn-id>
<vpn-oui>4804</vpn-oui>
<vpn-index>1</vpn-index>
</vpn-id>
</vrf>
</value>
</edit>
<edit>
<edit-id>2</edit-id>
<operation>create</operation>
<target>/Cisco-IOS-XR-ifmgr-cfg:interface-configurations/interface-configuration</target>
<value>
<interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<active>act</active>
<interface-name>Loopback1</interface-name>
<interface-virtual></interface-virtual>
<ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
<addresses>
<primary>
<address>7.7.7.7</address>
<netmask>255.255.255.255</netmask>
</primary>
</addresses>
</ipv4-network>
<vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-rsi-cfg">vpn-78</vrf>
</interface-configuration>
</value>
</edit>
<edit>
<edit-id>3</edit-id>
<operation>merge</operation>
<target>/Cisco-IOS-XR-ipv4-bgp-cfg:bgp/instance/default/instance-as/0/four-byte-as/4804/vrfs/vrf</target>
<value>
<vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">
<vrf-name>vpn-78</vrf-name>
<vrf-global>
<route-distinguisher>
<as-xx>0</as-xx>
<as>4804</as>
<type>as</type>
<as-index>1</as-index>
</route-distinguisher>
<exists></exists>
<vrf-global-afs>
<vrf-global-af>
<af-name>ipv4-unicast</af-name>
<enable></enable>
<connected-routes></connected-routes>
<static-routes></static-routes>
</vrf-global-af>
</vrf-global-afs>
</vrf-global>
</vrf>
</value>
</edit>
</yang-patch>

However, when we try to delete or remove with an absolute target path, restconf returns an error of 400. Message is "Error parsing input: null".
Request as below:
PATCH http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/iosxrv-7/yang-ext:mount/
Payload as below:
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
<patch-id>VPN-DELETION-1</patch-id>
<comment>Delete VPN-1</comment>
<edit>
<edit-id>1</edit-id>
<operation>remove</operation>
<target>/Cisco-IOS-XR-ipv4-bgp-cfg:bgp/instance/default/instance-as/0/four-byte-as/4804/vrfs/vrf/vpn-78</target>
</edit>
</yang-patch>

According to my inspection, it can be located to org.opendaylight.netconf.sal.rest.impl.XmlToPATCHBodyReader:147-154
The namespace is resolved to "netconf:base:1.0" because the request URI is root and there is no value can be used to resolve the namespace.



 Comments   
Comment by Wenbo Hu [ 09/Mar/17 ]

It only happens when parsing xml payload.
Json payload could work properly.

Json payload as below:
{
"ietf-yang-patch:yang-patch": {
"patch-id": "VPN-DELETION-1",
"comment": "Delete VPN-1",
"edit": [

{ "edit-id": "1", "operation": "remove", "target": "/Cisco-IOS-XR-ipv4-bgp-cfg:bgp/Cisco-IOS-XR-ipv4-bgp-cfg:instance[Cisco-IOS-XR-ipv4-bgp-cfg:instance-name='default']/Cisco-IOS-XR-ipv4-bgp-cfg:instance-as[Cisco-IOS-XR-ipv4-bgp-cfg:as='0']/Cisco-IOS-XR-ipv4-bgp-cfg:four-byte-as[Cisco-IOS-XR-ipv4-bgp-cfg:as='4804']/Cisco-IOS-XR-ipv4-bgp-cfg:vrfs/Cisco-IOS-XR-ipv4-bgp-cfg:vrf[Cisco-IOS-XR-ipv4-bgp-cfg:vrf-name='vpn-78']" }

]
}
}

Comment by Samuel Schneider [ 31/Jan/22 ]

Bug-fix for odl-restconf-nb-bierman02 will not be done. 

 

You should use odl-restconf-nb-rfc8040 instead. 

Given examples would looks like this:

PATCH http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=iosxrv-7/yang-ext:mount/

Payload:

<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
    <patch-id>VPN-CREATION-1</patch-id>
    <comment>Create VPN-1</comment>
    <edit>
        <edit-id>1</edit-id>
        <operation>create</operation>
        <target>/Cisco-IOS-XR-infra-rsi-cfg:vrfs/vrf=vpn-78</target>
        <value>
            <vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-rsi-cfg">
                <vrf-name>vpn-78</vrf-name>
                <create></create>
                <afs>
                    <af>
                        <af-name>ipv6</af-name>
                        <saf-name>unicast</saf-name>
                        <topology-name>default</topology-name>
                        <create></create>
                    </af>
                    <af>
                        <af-name>ipv4</af-name>
                        <saf-name>unicast</saf-name>
                        <topology-name>default</topology-name>
                        <create></create>
                        <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">
                            <import-route-targets>
                                <route-targets>
                                    <route-target>
                                        <type>as</type>
                                        <as-or-four-byte-as>
                                            <as-xx>0</as-xx>
                                            <as>4804</as>
                                            <as-index>1</as-index>
                                            <stitching-rt>0</stitching-rt>
                                        </as-or-four-byte-as>
                                    </route-target>
                                </route-targets>
                            </import-route-targets>
                            <export-route-targets>
                                <route-targets>
                                    <route-target>
                                        <type>as</type>
                                        <as-or-four-byte-as>
                                            <as-xx>0</as-xx>
                                            <as>4804</as>
                                            <as-index>1</as-index>
                                            <stitching-rt>0</stitching-rt>
                                        </as-or-four-byte-as>
                                    </route-target>
                                </route-targets>
                            </export-route-targets>
                        </bgp>
                    </af>
                </afs>
                <description>vrf for VPN which connects each site from iosxrv-7 and iosxrv-8</description>
                <vpn-id>
                    <vpn-oui>4804</vpn-oui>
                    <vpn-index>1</vpn-index>
                </vpn-id>
            </vrf>
        </value>
    </edit>
    <edit>
        <edit-id>2</edit-id>
        <operation>create</operation>
        <target>/Cisco-IOS-XR-ifmgr-cfg:interface-configurations/interface-configuration=act,Loopback1</target>
        <value>
            <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
                <active>act</active>
                <interface-name>Loopback1</interface-name>
                <interface-virtual></interface-virtual>
                <ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
                    <addresses>
                        <primary>
                            <address>7.7.7.7</address>
                            <netmask>255.255.255.255</netmask>
                        </primary>
                    </addresses>
                </ipv4-network>
                <vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-rsi-cfg">vpn-78</vrf>
            </interface-configuration>
        </value>
    </edit>
    <edit>
        <edit-id>3</edit-id>
        <operation>merge</operation>
        <target>/Cisco-IOS-XR-ipv4-bgp-cfg:bgp/instance=default/instance-as=0/four-byte-as=4804/vrfs/vrf=vpn-78</target>
        <value>
            <vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">
                <vrf-name>vpn-78</vrf-name>
                <vrf-global>
                    <route-distinguisher>
                        <as-xx>0</as-xx>
                        <as>4804</as>
                        <type>as</type>
                        <as-index>1</as-index>
                    </route-distinguisher>
                    <exists></exists>
                    <vrf-global-afs>
                        <vrf-global-af>
                            <af-name>ipv4-unicast</af-name>
                            <enable></enable>
                            <connected-routes></connected-routes>
                            <static-routes></static-routes>
                        </vrf-global-af>
                    </vrf-global-afs>
                </vrf-global>
            </vrf>
        </value>
    </edit>
</yang-patch>

Remove:

PATCH http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=iosxrv-7/yang-ext:mount/

Payload:

<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
    <patch-id>VPN-DELETION-1</patch-id>
    <comment>Delete VPN-1</comment>
    <edit>
        <edit-id>1</edit-id>
        <operation>remove</operation>
        <target>/Cisco-IOS-XR-ipv4-bgp-cfg:bgp/instance=default/instance-as=0/four-byte-as=4804/vrfs/vrf=vpn-78</target>
    </edit>
</yang-patch>
Generated at Wed Feb 07 20:14:50 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.