Versions Compared

Key

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

...

Jira
serverONAP Jira
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-508

Background

Currently CPS only supports creating a schema set by uploading the complete set of all yang resources (as a zip file). The purpose of this story is to create a special java api method that allows sending only part of the schema set. 

High level overview of what is to be done

In CPS to create an anchor the following conditions need to be satisfied. 

  1. A dataspace must be defined
  2. A schemaset must be created in the defined dataspace

Then an anchor can now be created using the dataspace and schemaset defined above

Implementation Proposal

Each subheading in this implementation proposal section will be taken from the high level overview stated above.

A dataspace must be defined

A dataspace is already defined as part of CPS-352, the dataspace we are using is NCMP-Admin

A schemaset must be created in the defined dataspace

CPS service provides a method to create a schemaset

  • createSchemaSet method in the CpsModuleService

This method takes three parameters:

  • schemasetName : The value for this parameter is going to be based on the cm handle id provided from NCMP
  • dataspaceName : NCMP-Admin
  • yangResourcesNameToContentMap : The value for this parameter will be discussed in more details below.
YangResourceNameToContentMap parameter value

From NCMP we have a map of new yang resources and also a list of ModuleReference objects needed to create a full schema set.

The map of new yang resources will come in the following format:

  • Map<String, String> newYangResourcesModuleNameToContentMap 

The list of ModuleReferences will contain the following information:

  • moduleName
  • revision

Note: This list is a list of ModuleReferences for the yang resources that are already stored in the yang_resources table in the DB that the node requires.

Approach 1

We now have to retrieve yang resources using the list of ModuleReferences. To do this the following needs to happen.

  1. Create a new method in the YangResourceRepository interface
  2. Use this method to retrieve the yang resources
  3. Add the yang resources to a list

With a list of the yang resources, we can now add the missing yang resources to the map from above newYangResourcesModuleNameToContentMap

Code Block
languagejava
themeMidnight
titleYangResourcesMap
// We have the list of yang resources retrieved from the db, exisitingYangResourcesForTheGivenCmHandle
allYangResourcesModuleNameToContentMap = exisitingYangResourcesForTheGivenCmHandle.forEach(yangResource -> newYangResourcesModuleNameToContentMap.put(yangResource.getModuleName(), yangResource.getContent()));

Now the allYangResourcesModuleNameToContentMap Map is a complete map that contains the new and existing resources for the cm handle and can now be passed as a parameter to the createSchemaSet method in the CpsModuleService.

The method will now create a new schema set and we can now use this to create the anchor.

Approach 2

In this approach, instead of retrieving the yang resource we will do something different.

We will call the createSchemaSet method and pass the newYangResourcesModuleNameToContentMap  and create the schema set. We will then update the schema_set_yang_resources table. To do this, the following needs to happen.

  1.  Create a new method in the YangResourceRepository interface to retrieve the ids of the yang resources using the moduleName and revision got from the list of ModuleReferences.
  2. Then we will need to create a new repository, SchemaSetYangResourcesRepository, this interface will have one method, insertSchemaSetIdYangResourceId(Integer SchemaId, List<Long> yangResourceIds)
  3. This method will then be used to create a relation between the schemaSetId and the YangResourceId

Now we can create the anchor.

Create an Anchor using the schemaset created above

CPS service provides a method to create an anchor.

  • createAnchor method in the CpsAdminService

This method takes three parameters:

  • dataspaceName : NCMP-Admin
  • schemasetName 
  • anchorName

The value for schemasetName and anchorName is going to be based on the cm handle id provided from NCMP. 

Decisions