[NETCONF-767] Unable to fetch mounted device's data when unkeyed and operational list present in device yang Created: 05/Feb/21  Updated: 01/Feb/22

Status: Confirmed
Project: netconf
Component/s: netconf
Affects Version/s: 2.0.13
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: Sarguna Dharani Assignee: Ivan Martiniak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Microsoft Word YANGTOOLS-1221-testcase.docx     Microsoft Word [NETCONF-767] Steps to reproduce.docx     File unkeyed-list-module.yang    

 Description   

Restconf returns "Request could not be completed because the relevant data model content does not exist network-topology:network-topology/topology/topology-netconf/node/{device-name}/yang-ext:mount/Cisco-IOS-XR-mpls-te-oper:mpls-te/tunnel-current-lsp/s2l/resv-rro"

 

container tunnel-current-lsp {
    description "xxxx";
    list s2l {
       description  "xxx";
       list resv-rro {              
         description "yyy";              
          leaf xyz

{ }

       }
    }

}

 

When unkeyed and operational list is present in device yang , we were unable to fetch that particular list.

 



 Comments   
Comment by Robert Varga [ 16/Feb/21 ]

So this needs a stack trace to go with it

Comment by Sarguna Dharani [ 02/Mar/21 ]

Hi Robert,

 

Replicated the issue using the test case
 
When netconf convert xml to Normalized node , we hit getDirectChild of Yangtools to find exact node using path arguments.

 

-------------------

NETCONF

---------------------

package org.opendaylight.netconf.sal.connect.netconf.util;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Optional;
import javax.xml.stream.XMLStreamException;
import org.opendaylight.netconf.api.ModifyAction;
import org.opendaylight.netconf.util.NetconfUtil;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

/**

  • Transforms rpc structures to normalized nodes and vice versa.
    */
    class NetconfRpcStructureTransformer implements RpcStructureTransformer {
    private static final Logger LOG = LoggerFactory.getLogger(NetconfRpcStructureTransformer.class);

private final MountPointContext mountContext;

NetconfRpcStructureTransformer(final MountPointContext mountContext)

{       this.mountContext = mountContext; }

@Override
public Optional<NormalizedNode<?, ?>> selectFromDataStructure(
final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> data,
final YangInstanceIdentifier path) {
        if (data instanceof DOMSourceAnyxmlNode) {
            final NormalizedNodeResult node;
            try

{                 node = NetconfUtil.transformDOMSourceToNormalizedNode(mountContext,                         ((DOMSourceAnyxmlNode)data).getValue());                   *Optional<NormalizedNode<?, ?>> result = NormalizedNodes.findNode(node.getResult(),*                                                   *path.getPathArguments());*                 return result;             }

catch (final XMLStreamException | URISyntaxException | IOException | SAXException e)

{                        LOG.error("Cannot parse anyxml.", e);               return Optional.empty();             }

        } else

{             return NormalizedNodes.findNode(data, path.getPathArguments());            }

       }

  .....

----------------

YANGTOOLS

-----------------

package org.opendaylight.yangtools.yang.data.api.schema;

....

/**

  • A set of utility methods for interacting with {@link NormalizedNode} objects.
    */
    @Beta
    public final class NormalizedNodes {

 

......

public static Optional<NormalizedNode<?, ?>> findNode(final Optional<NormalizedNode<?, ?>> parent,
final Iterable<PathArgument> relativePath) {
         final Iterator<PathArgument> pathIterator = requireNonNull(relativePath, "Relative path must not be null")
                      .iterator();
          Optional<NormalizedNode<?, ?>> currentNode = requireNonNull(parent, "Parent must not be null");
          while (currentNode.isPresent() && pathIterator.hasNext())

{                     *currentNode = getDirectChild(currentNode.get(), pathIterator.next());*            }

         return currentNode;

}

 

PFA for  changes added in test case to replicate UnkeyedListNode issue.

YANGTOOLS-1221-testcase.docx

 

Please let me know if you need more information.

Comment by Robert Varga [ 17/Mar/21 ]

Well, children of UnkeyedListNode are not adressable through PathArgument. They can only be either iterated or selected by offset.

For the code in your test case, this translates to the question: how would NormalizedNodes know to select the child at offset 0 (as opposed to any other offset)?

This needs to be fixed NETCONF-side.

Comment by Robert Varga [ 01/Feb/22 ]

Can you post karaf logs with NETCONF debugs enabled, please?
I believe the problem here is that NETCONF code is trying something funky, i.e. attempting to access a single item by a PathArgument (as per my previous comment).

Generated at Wed Feb 07 20:15:51 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.