Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Comparison of

...

CPS core output before modification to NCMP passthrough operation output

The following details were used to compare and analyze the current CPS core output to NCMP passthrough operation output

Model

 bookstore.yang
Databookstore.json
CPS core endpoint/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node
NCMP Passthrough operation/v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-running


Scenario 1: XPath is pointing to root i.e. '/'

CPS = '/'


NCMP Passthrough operation outputCPS Core output
Response


Code Block
collapsetrue
{
    "stores:bookstore": {
        "bookstore-name": "Chapters",
        "categories": [
      
{
      {
      
"code":
 
"01",
         "
name
code": "
SciFi
02",
        
"books": [
        "books": [
    
{
             
"lang":
 
"en",
  {
          
"price":
 
895,
             "title": "
Feersum
The 
Endjinn
Golden Compass",
         
"authors":
 
[
              "price": "
Iain M. Banks"
699",
           
],
             "pub_year": 
1994
1995,
        
},
           
{
     
"lang": "en",
            
"price": 1099,
            "
title
authors": 
"Far
[
Horizons",
             
"authors":
 
[
              "Philip Pullman"
david

Brin",
               
"Ursula
 
K.
 
Le
 
Guin",
      ]
        
"Rober
 
Silverberg",
           }
   
"Orson
 
Scott
 
Card",
           ],
   
"Greg
 
Bear",
            
"Joe Haldeman",
"name": "kids"
            },
  
"Dan
 
Simmons"
         {
   
],
             "
pub_year
code": 
1999
"01",
          
}
      "books": [
 
]
       
},
       
{
     {
   
"code": "02",
           
"name":
 
"kids",
         "
books
title": 
[
"Feersum Endjinn",
           
{
             "
lang
price": "
en
895",
            
"price":
 
699,
           
"
title
pub_year": 
"The
1994,
Golden
 
Compass",
             
"authors":
 
[
         "lang": "en",
    
"Philip Pullman"
                    "authors": [
             
],
               "
pub_year": 1995
Iain M. Banks"
               
}
         ]
            
}
     
]
   }
}Scenario 2: Container XPath i.e '/bookstore'NCMP Passthrough operation outputCPS Core outputResponse Code Block
collapsetrue
Code Block
collapsetrue
{ "bookstore": { "bookstore-name": "Chapters",
,
                    {
       
"categories":
 
[
       
{
         "
code
title": "
01
Far Horizons",
          
"name": "SciFi",
              "
books
price": 
[
"1099",
           
{
             "
lang
pub_year": 
"en"
1999,

           
"price":
 
1099,
            
"
title
lang": "
Far Horizons
en",
            
"authors": [
            "
david Brin
authors"
,
: [
             
"Ursula
 
K. Le
 
Guin",
             "david 
Brin"
Rober Silverberg"
,
              
"Orson
 
Scott
 
Card",
            "Ursula K. Le Guin"
Greg Bear"
,
              
"Joe
 
Haldeman",
             
"
Dan
Rober 
Simmons
Silverberg",
            
],
             
"pub_year":
 
1999
  "Orson Scott 
Card",
    
},
           
{
             "
lang": "en
Greg Bear",
            
"price": 895,
                "
title": "Feersum Endjinn
Joe Haldeman",
            
"authors":
 
[
               "
Iain M. Banks
Dan Simmons"
            
],
            ]
"pub_year":
 
1994
           
}
        }
]
       
},
       
{
  ],
      
"code":
 
"02",
         "name": "
kids
SciFi"
,

        
"books":
 
[
   }
       
{
 ]
    }
}



Code Block
collapsetrue
{
  "bookstore": {
 
"lang
   "bookstore-name": "
en
Chapters",
    "categories": [
      
"price
{
        "code": 
699
"01",
        
"
title
name": "
The Golden Compass
SciFi",

        "
authors
books": [
          {
   
"Philip
 
Pullman"
        
]
"lang": "en",
            "
pub_year": 1995
price": 895,
            "title": "Feersum Endjinn",
            "authors": [
   
}
           "Iain M. Banks"
]
       
}
     ],
    
} }

Scenario 3: List attributes XPath

'/bookstore/categories[@code='02']'

'/ncmp/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=02'

NCMP Passthrough outputCPS Core outputResponse Code Block
collapsetrue
{ "stores:categories": [ {
        "pub_year": 1994
          },
          {
            "lang": "en",
            "price": 1099,
            "title": "Far Horizons",
            "authors": [
              "david Brin",
              "Ursula K. Le Guin",
              "Rober Silverberg",
              "Orson Scott Card",
              "Greg Bear",
              "Joe Haldeman",
              "Dan Simmons"
            ],
            "pub_year": 1999
          }
        ]
      },
      {
        "code": "02",
        "name": "kids",
        "books": [
          {
            "lang": "en",
            "price": 699,
            "title": "The Golden Compass",
            "authors": [
              "Philip Pullman"
            ],
            "pub_year": 1995
          }
        ]
      }
    ]
  }
}


Scenario 2: Container XPath i.e '/bookstore'

CPS = '/bookstore'

NCMP = '/ncmp/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore'


NCMP Passthrough operation outputCPS Core output
Response


Code Block
collapsetrue



Code Block
collapsetrue
{
  "bookstore": {
    "bookstore-name": "Chapters",
    "categories": [
      {
        "code": "01",
        "name": "SciFi",
        "books": [
          {
            "lang": "en",
            "price": 1099,
            "title": "Far Horizons",
            "authors": [
              "david Brin",
              "Ursula K. Le Guin",
              "Rober Silverberg",
              "Orson Scott Card",
              "Greg Bear",
              "Joe Haldeman",
              "Dan Simmons"
            ],
            "pub_year": 1999
          },
          {
            "lang": "en",
            "price": 895,
            "title": "Feersum Endjinn",
            "authors": [
              "Iain M. Banks"
            ],
            "pub_year": 1994
          }
        ]
      },
      {
        "code": "02",
        "name": "kids",
        "books": [
          {
            "lang": "en",
            "price": 699,
            "title": "The Golden Compass",
            "authors": [
              "Philip Pullman"
            ],
            "pub_year": 1995
          }
        ]
      }
    ]
  }
}


Scenario 3: List attributes XPath

CPS = '/bookstore/categories[@code='02']'

NCMP = '/ncmp/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=02'


NCMP Passthrough outputCPS Core output
Response


Code Block
collapsetrue
{
    "stores:categories": [
        {
            "code": "02",
            "books": [
                {
                    "title": "The Golden Compass",
                    "price": "699",
                    "pub_year": 1995,
                    "lang": "en",
                    "authors": [
                        "Philip Pullman"
                    ]
                }
            ],
            "name": "kids"
        }
    ]
}



Code Block
collapsetrue
{
  "categories": {
    "code": "02",
    "name": "kids",
    "books": [
      {
        "lang": "en",
        "price": 699,
        "title": "The Golden Compass",
        "authors": [
          "Philip Pullman"
        ],
        "pub_year": 1995
      }
    ]
  }
}



Modifying CPS Core output

Parsing a model with prefix

Using the following test the given data above was used to see that prefixed is valid with the current YangTools that CPS uses

Code Block
collapsetrue
    def 'Parsing a valid Json String.'() {
        given: 'a yang model (file)'
            def jsonData = org.onap.cps.TestUtils.getResourceFileContent('bookstore.json')
        and: 'a model for that data'
            def yangResourceNameToContent = TestUtils.getYangResourcesAsMap('bookstore.yang')
            def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext()
        when: 'the json data is parsed'
            NormalizedNode<?, ?> result = YangUtils.parseJsonData(jsonData, schemaContext)
        then: 'the result is a normalized node of the correct type'
            result.nodeType == QName.create('org:onap:ccsdk:sample', '2020-09-15', 'bookstore')
    }

The test above passed for the used data.


The following data wherein the list attribute also contains a prefix was also tested to see if the YangTools parser will fail. The same result as the above test was collected.

Code Block
collapsetrue
{
   "stores:bookstore":{
      "bookstore-name": "Chapters",
      "stores:categories": [
         {
            "code": "01",
            "name": "SciFi",
            "books": [
               {
                  "authors": [
                     "Iain M. Banks"
                  ],
                  "lang": "en",
                  "price": "895",
                  "pub_year": "1994",
                  "title": "Feersum Endjinn"
               },
               {
                  "authors": [
                     "Ursula K. Le Guin",
                     "Joe Haldeman",
                     "Orson Scott Card",
                     "david Brin",
                     "Rober Silverberg",
                     "Dan Simmons",
                     "Greg Bear"
                  ],
                  "lang": "en",
                  "price": "1099",
                  "pub_year": "1999",
                  "title": "Far Horizons"
               }
            ]
         },
         {
            "name": "kids",
            "code": "02",
            "books": [
               {
                  "authors": [
                     "Philip Pullman"
                  ],
                  "lang": "en",
                  "price": "699",
                  "pub_year": "1995",
                  "title": "The Golden Compass"
               }
            ]
         }
      ]
   }
}

Building the data node

DataNodeBuilder class was modified to add the method 'withModuleNamePrefix()' which adds a module name attribute to the DataNode object being built.

When the buildFromAttributes() method is called it sets the DataNode attribute 'moduleNamePrefix'.

When the response is being made from methods such as GetDataNode and QueryNodes it calls DataMapUtils class method toDataMapWithIdentifier().

toDataMapIdentifier() method calls on getNodeIdentifierWithPrefix() method to ensure that the prefix is only added to the top node being requested.


Results of modifying cps core output through DataNodeBuilder and DataMapUtils

XpathResponse
/


Code Block
collapsetrue
{
  "stores:bookstore": {
    "bookstore-name": "Chapters",
    "categories": [
      {
        "code": "02",
        "name": "kids",
        "books": [
          {
            "lang": "en",
            "price": 699,
            "title": "The Golden Compass",
            "
code
authors": 
"02"
[
              "Philip Pullman"
            ],
            "
books
pub_year": 1995
  
[
        }
        
{
]
      },
      {
        "
title
code": "
A Horror book
01",
        "name": "SciFi",
        
"
price
books": 
"2000",
[
          {
            "
pub_year
lang": 
2003
"en",
            "price": 1099,
      
"lang": "English",
      "title": "Far Horizons",
            "authors": [
              "david Brin",
          
"Joe
 
&
 
Rahul"
  "Ursula K. Le Guin",
              "Rober 
]
Silverberg",
              "Orson Scott 
}
Card",
              "Greg Bear",
 
{
             "Joe Haldeman",
      
"title":
 
"A
 
New
 
book
 
in
 
existing
 
category",
  "Dan Simmons"
            ],
    
"price":
 
"2000",
       "pub_year": 1999
          },
 
"pub_year":
 
2003,
        {
            "lang": "
English
en",

            
"authors
"price": 
[
895,
            "title": "Feersum Endjinn",
          
"Joe
 
&
 
Rahul
"authors": [
              "Iain M. Banks"
   
]
         ],
       
}
     "pub_year": 1994
      
],
    }
        
"name": "Horror"
]
      }
  
}
  ]
  
]
}
}


/bookstore/categories[@code='02']


Code Block
collapsetrue
{
  "stores:categories": {
    "code": "02",
    "name": "kids",
    "books": [
      {
        "lang": "en",
        "price": 699,
        "title": "The Golden Compass",
        "authors": [
          "Philip Pullman"
        ],
        "pub_year": 1995
      }
    ]
  }
}

Modifying CPS Core output

Parsing a model prefix

Building the data node

}



The DataNode built for the above tests will now contain a modified xPath containing the module name just like as follows:


Example module namestores
Xpath parameterExpected modified node identifier
/bookstore'stores:bookstore'
/bookstore/categories[@code='02']'stores:categories'


Open Issues

IssueDescriptionResolution
Child The child is in a different module

If the child is in a different module should it have a prefix


Output The output starts with the non-root element

If the output starts with a non-root element should it have a prefix?


Backward incompatibility

Discuss backward incompatibility with stakeholders

    1. WiPro (E2E Slicing)
    2. Ericsson
    3. Bell (Bruno has confirmed that they are not impacted ?)

Can YangTools parse it?

  • if YangTools can parse it then this is not incompatible
As tested , yang tools currently used are able to parse the data
Is this LEGAL YANG data