Versions Compared

Key

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

...

Code Block
languagebash
titleyang_resource@2021-12-13.csv
collapsetrue
name|content|checksum
dmi-registry@2021-12-13.yang|"module dmi-registry {

  yang-version 1.1;

  namespace \"org:onap:cps:ncmp\";

  prefix dmi-reg;

  organization \"Nordix Foundation\";

  contact \"rahul.tyagi@est.tech\";

  revision \"2021-12-13\" {
   description
   \"Added new list of public additonal properties for a Cm-Handle which are exposed to clients of the NCMP interface. \";
  }

  container dmi-registry {

    list cm-handles {

      key \"id\";

      leaf id {
        type string;
      }

      leaf dmi-service-name {
        type string;
      }

      leaf dmi-data-service-name {
        type string;
      }

      leaf dmi-model-service-name {
        type string;
      }

      list additional-properties {
        key \"name\";
        leaf name {
          type string;
        }
        leaf value {
          type string;
        }
      }
      list public-additional-properties {
        key \"name\";
        leaf name {
          type string;
        }
        leaf value {
          type string;
        }
      }
    }
  }
}
"|4899c384835ec48194ab5e3837549d32b844e02cfc81e9205234fa36354f3fe4
Note

Before adding the checksum in the file above, first generate the checksum within the yang_resource table following the step below

...


Generating new Yang Resource

First copy the content from the CSV file above and create a YANG file locally with it with the format 'dmi-registry@<revision>'.

Run the following command to insert a new yang resource into the yang_resource table with the checksum generated.

Note

CPS Application must be deployed from before running this command.

Code Block
languagebash
curl --location --request POST 'http://localhost:8080/cps/api/v1/dataspaces/<dataspace name>/schema-sets' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --form 'file=<path to local file>' --form 'schema-set-name='<schema set name>'

Add the generated checksum into the yang resource csv above.

Once this is done, then add the change-set for yang resource you have created to load the data into the DB.

...

titleLoading newly created yang resource csv into local db directly

...

new yang file and its contents within 'cps-ri/src/main/resources/changelog/db/changes/data/yang-models/' and give it the name format of   'yang_resource_name@<revision>'. eg: dmi-registry@2021-12-13.yang.

Once this is done, within the cps-parent pom file add the yang resource you have just created as an argument as seen below.

Image Added

Then, run a mvn clean install on your machine, and it will generate a csv file in the following directory 'cps-ri/src/main/resources/changelog/db/changes/data/dmi/generated-csv'.

Image Added

Once this is done, then add the change-set for yang resource you have created to load the data into the DB.


Code Block
languageyml
titleYang resource Change set example
collapsetrue
  - changeSet:
      author: cps
      label: dmi-registry-schema-preload
      id: 9.7
      loadUpdateData:
        encoding: UTF-8
        file: 'changelog/db/changes/data/dmi/generated_yang_resource@2021resource_dmi-registry@2021-12-13.csv'
        onlyUpdate: 'false'
        primaryKey: 'id'
        quotchar: '"'
        separator: '|'
        tableName: 'yang_resource'
        columns:
          - column:
              header:  name
              name:  name
              type:  STRING
          - column:
              header:  content
              name: content
              type: STRING
          - column:
              header:  checksum
              name: checksum
              type: STRING
      rollback:
        - sql:
            sql: delete from yang_resource where name = 'dmi-registry@2021-12-13.yang'

...

Yang Resource Schema Set

Data will also need to be inserted into the yang_resource_schema_set table to create a mapping between the new yang resource and the necessary schema set.

...