[NETCONF-696] Invoking Yang 1.1 Action on ODL fails for Yang Model containing yang action under augmentation hierarchy. Created: 29/May/20  Updated: 17/Jul/20  Resolved: 17/Jul/20

Status: Resolved
Project: netconf
Component/s: None
Affects Version/s: None
Fix Version/s: Aluminium, Magnesium SR2, Sodium SR4

Type: Bug Priority: Highest
Reporter: Ajay Deep Singh Assignee: Ajay Deep Singh
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot from 2020-05-28 14-23-23.png     File augment-main-a@2014-01-21.yang     File main@2014-01-21.yang    
Issue Links:
Relates
relates to INTTEST-107 add CSIT test cases to cover rpc action In Progress
relates to NETCONF-702 Regression in NETCONF ACTION Test Resolved

 Description   

While Executing yang action requests on ODL via  POST request failes for augmented yang actions see attached screenshot

By going through ODL wiki , it says that QName for augmented yang model would not be supported.

 
 Running into issue  its related to invocation of Yang 1.1 Action on Odl.
 
When I am invoking action on Yang Model having Augmentations like below it fails with Exception : "Augmentation node has no Qname" ** 
 
It occurs at time of getting  :  QName getNodeType() >> path.getNodeType() as shown in below code snippet.
 
In Class : RestconfInvokeOperationsUtil.java     in Restconf Module.
 
private static DOMDataTreeIdentifier prepareDataTreeId(final YangInstanceIdentifier yangIId,
final SchemaPath schemaPath) {
final List<PathArgument> pathArg = new ArrayList<>();
for (PathArgument path : yangIId.getPathArguments()) {
if (path.getNodeType().getLocalName().equals(schemaPath.getLastComponent().getLocalName()))

{ break; }

pathArg.add(path);
}
YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.builder().append(pathArg).build();
DOMDataTreeIdentifier domDataTreeIdentifier = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
yangInstanceIdentifier);
return domDataTreeIdentifier;
}
 
 
Yang Model : 
 
module er-module 

  yang-version 1.1;
  namespace "https://example.com/ns/er-module";
  prefix rcsswm;
 
  import er-managed-element

{     prefix emael;   }

  import er-yang-extensions

{     prefix yexte;   }

 
  revision 2019-12-06

{     yexte:version "3";     yexte:release "4";     yexte:correction "1";  }

 
augment "/emael:ManagedElement/emael:SystemFunctions";
augment "/emael:ManagedElement/emael:SystemFunctions" {

    list SwM {
      key "id";
      leaf id

{         type string;       }

      yexte:is-system-created;
      container attributes 

{         uses *SwMGrp*;      }

    }
 }
grouping SwMGrp {
    action createUpgradePackage {
      input {
        leaf uri

{           type string;        }

    }
   }
 }
}
 



 Comments   
Comment by Jamo Luhrsen [ 02/Jun/20 ]

rovarga, this might belong in yangtools?

Comment by Robert Varga [ 02/Jun/20 ]

ah,  nope, related but I think this is RESTCONF's failure to take handle the NormalizedNode addressing complexities.

Comment by Ajay Deep Singh [ 03/Jun/20 ]

Hi Robert,

Thanks for commenting on JIRA.

I have checked-in code changes for issue please can you review/merge on master branch, also I need to merge it on stable/sodium, stable/magnesium once its reviewed on master branch will cherrypick on other branches hope that should work.

Issue details : Earlier code was iteration and  trying to get QName for augment node in data model hierarchy. 

Gerrit link : https://git.opendaylight.org/gerrit/c/netconf/+/90225

Regards,

Ajay

Comment by Ajay Deep Singh [ 03/Jun/20 ]

Hi All,

Tested Code against Yang Model attached in JIRA.

Detail:

Restend Point : http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/main:cont/cont1/reset

JSon Body :

<?xml version="1.0" encoding="UTF-8"?>
<input xmlns="ns:augment:main:a">
 <delay>600</delay>
</input>

RPC Message:

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-0">
 <action xmlns="urn:ietf:params:xml:ns:yang:1">
     <cont xmlns="ns:main">
           <cont1 xmlns="ns:augment:main:a">
                 <reset>
                       <delay>600</delay>
                 </reset>
           </cont1>
      </cont>
 </action>
</rpc>
Comment by Jamo Luhrsen [ 08/Jul/20 ]

rovarga, we can assign this to nikhil.soni.lumina unless you already have some progress on it. I'll assign it now, but
feel free to take it back if you have work done already.

Comment by Ajay Deep Singh [ 08/Jul/20 ]

Hi Jamo,

Cant follow up  on this Jira can see now code is reverted on braches, whats the issue here...? 

In one Jira it was commented that Code works for XML input but not for JSON is that the case...?

Please can you provide some details in it will debug and find the failure scenario.

Regards,

Ajay

Comment by Jamo Luhrsen [ 08/Jul/20 ]

Thanks for taking this up ajay_dp001... the short story is that your fix did work for
the augmentation action case, but it broke an existing case where the action was not in
an augmentation if we used JSON to access it. the XML version worked.

a few more details are here: https://jira.opendaylight.org/browse/NETCONF-702

I did spend some cycles in the debugger trying to figure it out, but I'm just not
expert enough in this to get it figured out before moving on to other things. I did
take some notes down and here is what I saw.

In the JSON case, the yangIId.getParent() looked like this:

/(ns:main?revision=2014-01-21)cont/AugmentationIdentifier{childNames=[(ns:augment:main:a?revision=2014-01-21)cont1]}/(ns:augment:main:a?revision=2014-01-21)cont1/reset

and XML case, it was:

/(ns:main?revision=2014-01-21)cont/AugmentationIdentifier{childNames=[(ns:augment:main:a?revision=2014-01-21)cont1]}/(ns:augment:main:a?revision=2014-01-21)cont1

Maybe that difference (/reset in JSON) is helpful to understanding why?

kailashkhalasi is almost done with automating the augmentation action case in our CSIT so we can
easily test all four cases of JSON/XML + augmented/not-augmented really quickly.

Let me know how I can help.

Comment by Ajay Deep Singh [ 09/Jul/20 ]

Hi Jamo,

Thanks for details.

Figured root casue, fixed issue with Json Input, I have created new Pull Request: https://git.opendaylight.org/gerrit/c/netconf/+/91274

Please can you get it tested against all 4 Yang 1.1 Action CRUD  CSIT.

Regards,

Ajay

Comment by Jamo Luhrsen [ 13/Jul/20 ]

ajay_dp001, rovarga, our new CSIT to cover this is failing. It looks like the testtool is not happy with
with the RPC that comes in. It's giving an rpc-error reply with "Mapping not found"

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-2">
    <rpc-error>
        <error-type>application</error-type>
        <error-tag>operation-not-supported</error-tag>
        <error-severity>error</error-severity>
        <error-message>Mapping not found &lt;rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-2"&gt;
    &lt;action xmlns="urn:ietf:params:xml:ns:yang:1"&gt;
        &lt;cont xmlns="ns:main"&gt;
            &lt;cont1 xmlns="ns:augment:main:a"&gt;
                &lt;reset&gt;
                    &lt;delay&gt;600&lt;/delay&gt;
                &lt;/reset&gt;
            &lt;/cont1&gt;
        &lt;/cont&gt;
    &lt;/action&gt;
&lt;/rpc&gt;
</error-message>
    </rpc-error>
</rpc-reply>

we are putting the two yang models attached to this ticket in the schemas dir used by the testtool and the log seems
to show that they are loaded fine.

karaf.log

I wonder if there is something basic we are missing.

Comment by Ajay Deep Singh [ 14/Jul/20 ]

Hi Jamo,

Thanks for updates. 

I have tested against all 4 (Normal+Augument(XML+JSON)) cases locally and seems to be working fine.

Please can you share details if below are the only check-in made to cover Augmentation Action(XML+JSON) then i guess its incomplete, that's the reason the Old CSIT is passing and the new CSIT for Augmentation is failing.

https://git.opendaylight.org/gerrit/c/integration/test/+/90879

https://git.opendaylight.org/gerrit/c/integration/test/+/90969

I will request to have acheck on initial CSIT added for testing action: https://git.opendaylight.org/gerrit/c/integration/test/+/84858

Looking at karaf.log looks  like Input Mapping for rpc in testtool is not provided due to which its failing.

 

Regards,

Ajay

Comment by Kailash Khalasi [ 14/Jul/20 ]

HI Ajay,

 

Here is the data i'm posting to test the augmentation action - 

 
curl --location --request PUT '
http://10.1.97.74:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=netconf-test-device/yang-ext:mount/main:cont/cont1/reset
' \
--header 'Content-Type: application/xml' \
--header 'Accept: application/xml' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '<?xml version="1.0" encoding="UTF-8"?>
<input xmlns="ns:augment:main:a">
<delay>600</delay>
</input>'

Comment by Ajay Deep Singh [ 14/Jul/20 ]

Hi Kailash,

  1. Using HTTP PUT is incorrect for Yang Action it should be HTTP POST. 

I doubt if you have followed  CSIT action: https://git.opendaylight.org/gerrit/c/integration/test/+/84858

Let me know if we can synch on whatsApp there after will iniiate Zoom Call 

Regards,

Ajay

Comment by Kailash Khalasi [ 14/Jul/20 ]

sorry it was a POST call. i copied an older request i was doing but then corrected it.

 

And yes I do have all those actions in CSIT. I cloned the entire repo and pointed to all those schemas. 

Comment by Jamo Luhrsen [ 14/Jul/20 ]

ajay_dp001what is the full command line you are using to start the testtool?

here is ours in CSIT:

java -Xmx1G -jar netconf-testtool-1.9.0-20200712.191255-249-executable.jar  --device-count 1 --debug true --schemas-dir ./schemas --rpc-config /tmp/customaction.xml --md-sal true
Comment by Ajay Deep Singh [ 14/Jul/20 ]

Hi Jamo,

I had a chat with Kailash, and we are able to figure out issue the mapping was missing for Augument usecase.

I have requested Kailash to update csit/variables/netconf/CRUD/customaction/customaction.xml file with below input data it should work thereafter.

<rpc>
 <input>
 <action xmlns="urn:ietf:params:xml:ns:yang:1">
 <cont xmlns="ns:main">
 <cont1 xmlns="ns:augment:main:a">
 <reset>
 <delay>600</delay>
 </reset>
 </cont1>
 </cont>
 </action>
 </input>
 <output>
 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:sys="ns:augment:main:a">
 <ok />
 </rpc-reply>
 </output>
 </rpc>

Thanks kailashkhalasi for your time.

Regards,

Ajay

Comment by Kailash Khalasi [ 14/Jul/20 ]

Thanks Ajay! After updating the custom action with the needed rpc, the test cases are passing - https://jenkins.opendaylight.org/sandbox/view/All/job/netconf-csit-1node-gate-userfeatures-all-aluminium/5/

 

This was tested on this build - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/netconf/karaf/0.13.0-SNAPSHOT/karaf-0.13.0-20200712.074149-237.zip

Comment by Jamo Luhrsen [ 14/Jul/20 ]

Thanks for all the work kailashkhalasi and ajay_dp001. I gave a note in gerrit to rovarga that our CSIT is good now
and he can merge. I also made cherry picks to both Mg and Na branches.

Comment by Ajay Deep Singh [ 15/Jul/20 ]

Hi Jamo, Kailash,

Thank you for sharing details and efforts added for JIRA.

Request rovarga to please review/merge there after we can close JIRA.

Regards,

Ajay

Comment by Ajay Deep Singh [ 17/Jul/20 ]

 Hi rovarga, jluhrsen,

Request you to please review/merge changes for this Jira on Master branch.

Regards,

Ajay

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