clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
215 stars 72 forks source link

RESTConf GET for a specific list instance retrieves data from other submodules that have same list name and key value #244

Closed DeekshaBhandary closed 3 years ago

DeekshaBhandary commented 3 years ago

yang defintion:

module mainmodule{
include module1;
include module2;
}

submodule module1{

    list list1{
        key 'name';

        leaf name {
            type string;
        }   
        leaf value1 {
            type int32;
        }   
    }   
}

submodule module2{
    container cont1{
        list list1{
            key 'name';

            leaf name {
                type string;
            }   
            leaf value2 {
                type int32;
            }   
        }   
    }   
}

Configuration:

cli>set list1 list1name
cli>set list1 value1 10
cli1>set cont1 list1 list1name
cli1>set cont1 list1 list1name value2 20
cli1> 

rest GET for the entire configuration returns correct data:

supervisor@test:~ $curl -i --request GET http://localhost:8040/restconf/data/--header 'Content-Type: application/yang-data+json'
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: application/yang-data+json
Status: 200 OK
Date: Tue, 06 Jul 2021 06:09:00 GMT
Transfer-Encoding: chunked

 {
  "data": {
     "mainmodule:list1": [
      {
        "name": "list1name",
        "value1" : 10
      }
    ],

    "mainmodule:cont1": {
        "list1": [
          {
            "name": "list1name",
            "value2" : 20
          }
        ]
      }
    }
}
supervisor@test:~ $ 

Rest GET by using a specific list key when there is a similar list in another submodule with same key value retrieves that data too

supervisor@test:~ $ curl -i --request GET http://localhost:8040/restconf/data/mainmodule:list1=list1name --header 'Content-Type: application/yang-data+json'
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: application/yang-data+json
Status: 200 OK
Date: Tue, 06 Jul 2021 06:09:00 GMT
Transfer-Encoding: chunked

{
    "mainmodule:list1": [
      {
        "name": "list1name",
        "value1": 10
      }
    ],
    "mainmodule:list1": [
      {
        "name": "list1name",                <----------- This data does not belong to this instance of list1
        "value2" : 20
      }
    ]
 }
supervisor@test:~ $
DeekshaBhandary commented 3 years ago

With this commit the issue is fixed. Thank You.