You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 5
Next »
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 |
---|
Data | bookstore.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 output | CPS Core output |
---|
Response |
{
"stores:bookstore": {
"bookstore-name": "Chapters",
"categories": [
{
"code": "02",
"books": [
{
"title": "The Golden Compass",
"price": "699",
"pub_year": 1995,
"lang": "en",
"authors": [
"Philip Pullman"
]
}
],
"name": "kids"
},
{
"code": "01",
"books": [
{
"title": "Feersum Endjinn",
"price": "895",
"pub_year": 1994,
"lang": "en",
"authors": [
"Iain M. Banks"
]
},
{
"title": "Far Horizons",
"price": "1099",
"pub_year": 1999,
"lang": "en",
"authors": [
"david Brin",
"Ursula K. Le Guin",
"Rober Silverberg",
"Orson Scott Card",
"Greg Bear",
"Joe Haldeman",
"Dan Simmons"
]
}
],
"name": "SciFi"
}
]
}
}
|
{
"bookstore": {
"bookstore-name": "Chapters",
"categories": [
{
"code": "01",
"name": "SciFi",
"books": [
{
"lang": "en",
"price": 895,
"title": "Feersum Endjinn",
"authors": [
"Iain M. Banks"
],
"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 output | CPS Core output |
---|
Response | |
{
"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 output | CPS Core output |
---|
Response |
{
"stores:categories": [
{
"code": "02",
"books": [
{
"title": "The Golden Compass",
"price": "699",
"pub_year": 1995,
"lang": "en",
"authors": [
"Philip Pullman"
]
}
],
"name": "kids"
}
]
}
|
{
"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
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.
{
"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 'withModuleName()' which adds a module name attribute to the DataNode object being built.
When the buildFromAttributes() method is called it then calls the added method addModulePrefixToXpath(moduleName).
addModulePrefixToXpath(moduleName) contains the following logic
if xpath contains '['
insert module name prefix after the last '/'
else
insert module name prefix after the first character ('/')
Results of modifying cps core output through DataNodeBuilder
Xpath | Response |
---|
/ |
{
"stores:bookstore": {
"bookstore-name": "Chapters",
"categories": [
{
"code": "02",
"name": "kids",
"books": [
{
"lang": "en",
"price": 699,
"title": "The Golden Compass",
"authors": [
"Philip Pullman"
],
"pub_year": 1995
}
]
},
{
"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
}
]
}
]
}
}
|
/bookstore/categories[@code='02'] |
{
"stores:categories": {
"code": "02",
"name": "kids",
"books": [
{
"lang": "en",
"price": 699,
"title": "The Golden Compass",
"authors": [
"Philip Pullman"
],
"pub_year": 1995
}
]
}
}
|
The DataNode built for the above tests will now contain a modified xPath containing the module name just like as follows:
Example module name | stores |
Xpath parameter | Expected modified XPath set as data node XPath attribute |
---|
/bookstore | /stores:bookstore |
/bookstore/categories[@code='02'] | /bookstore/stores:categories[@code='02'] |
Open Issues
Issue | Description | Resolution |
---|
Child is in a different module | If the child is in a different module should it have a prefix |
|
Output starts with non-root element | If the output starts with non-root element should it have a prefix |
|
Backward incompatibility | Discuss backward incompatibility with stakeholders - WiPro (E2E Slicing)
- Ericsson
- Bell (Bruno has confirmed that they are not impacted ?)
Can YangTools parse it? - if YangTools can parse it then this is not incompatible
|
|
Is this LEGAL YANG data |
|
|