The goal
To be able to handle CM event in SDN-R you have to create locally VES Collector image containing schema files that will be needed for CM validation. Then you will be able to send the CM event and persist it to the Elasticsearch or MariaDB database. The choice of database will depend on your configuration.
Create custom VES-collector
Get current VES-collector project
Clone it from the repository
To make it possible for VES-collector to handle CM messages there are required some changes in the project.
Copy files from 3GPP OpenAPI and paste them to the proper directory in the project
ves/etc/externalRepo/3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI$ ls comDefs.yaml faultMnS.yaml fileDataReportingMnS.yaml heartbeatNtf.yaml perfMnS.yaml provMnS.yaml
Edit provMns.yaml file
Remove few references from components → schemas → Resource
user@computer:~/ves_files$ diff provMns_old.yaml provMns_new.yaml 415,419d414 < - anyOf: < - $ref: 'genericNrm.yaml#/components/schemas/resources-genericNrm' < - $ref: 'nrNrm.yaml#/components/schemas/resources-nrNrm' < - $ref: '5gcNrm.yaml#/components/schemas/resources-5gcNrm' < - $ref: 'sliceNrm.yaml#/components/schemas/resources-sliceNrm'
Update schema-map.json file
[ { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/faultMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/faultMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/heartbeatNtf.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/heartbeatNtf.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/PerDataFileReportMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/PerDataFileReportMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/provMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/provMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/faultMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI/faultMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/heartbeatNtf.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI/heartbeatNtf.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/fileDataReportingMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI/fileDataReportingMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/perfMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI/perfMnS.yaml" }, { "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml", "localURL": "3gpp/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml" } ]
Build project and create docker image
Use below command:
mvn clean package docker:build
If tests are failing use different branch or skip them:
mvn clean package docker:build -D"maven.test.skip=true"
In the docker images there should be a new image:
nexus3.onap.org:10003/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest
Update oam project to use new VES-collector
To add new VES-collector and connect it with the SDN-R use OAM project.
Swap VES-collector image
In directory oam/solution/dev of OAM project edit VES Collector configuration in .env file change image to newly created one.
## VES Collector VES_COLLECTOR_IMAGE=nexus3.onap.org:10003/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest VES_COLLECTOR_IP=172.40.0.27
Edit collector.properties file
Find in OAM project file oam/solution/dev/ves-collector/collector.properties and make change like below
diff collector_old.properties collector.properties 65c65 < collector.dmaapfile=./etc/DmaapConfig.json --- > collector.dmaapfile=etc/ves-dmaap-config.json
Send CM event
To verify if everything is correct send sample CM message:
{ "event": { "commonEventHeader": { "version": "4.1", "vesEventListenerVersion": "7.2", "domain": "stndDefined", "stndDefinedNamespace": "3GPP-Provisioning", "eventId": "cm0004012", "eventName": "ves_stdnDefined_3GPP-Provisioning", "nfNamingCode": "NFNC", "nfVendorName": "POC", "nfcNamingCode": "NFC", "priority": "Medium", "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", "reportingEntityName": "samsung", "sequence": 0, "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", "sourceName": "samsung", "startEpochMicrosec": 1547037007722752, "lastEpochMicrosec": 1547037028498530, "timeZoneOffset": "UTC-05:30" }, "stndDefinedFields": { "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiChanges", "data": { "href": "href1", "notificationId": 1, "notificationType": "notifyMOIChanges", "eventTime": "2021-08-23T11:52:10.6Z", "systemDN": "xyz", "moiChanges": [ { "notificationId": 123, "correlatedNotifications": [], "additionalText": "AdditionalTextDetails", "sourceIndicator": "MANAGEMENT_OPERATION", "path":"https://samsung.com/3GPP/simulation/network-function/ves=1", "operation": "REPLACE", "value": { "pnf-registration": "true", "faults-enabled": "true" } } ] }, "stndDefinedFieldsVersion": "1.0" } } }
Using below command, where "cm.json" points to proper CM message.
curl -k -X POST "https://localhost:8443/eventListener/v7" -H 'Authorization: Basic c2FtcGxlMTpzYW1wbGUx' -H 'content-type: application/json' -H 'X-MinorVersion: 1' --data-binary "@cm.json"
To check if it works check SDN-R logs.
docker exec -ti sdnr tail -f data/log/karaf.log
You should see there:
2021-11-23T09:17:09,628 | INFO | Thread-47 | DMaaPCMVESMsgConsumer | 229 - org.onap.ccsdk.features.sdnr.wt.sdnr-wt-mountpoint-registrar-provider - 1.2.4.SNAPSHOT | - | Read CM message from DMaaP topic that is moiChanges type
If you don't see such message in the logs try to send CM (or fault or pnf) several times more.
Database
A couple of months ago SDN-R migrate from Elasticsearch to MariaDB. Currently it supports both stores, depending on provided configuration. Our implementation support both scenarios.
Elasticsearch
The default database for SDN-R is Elasticsearch. To check if the CM event has been persisted correctly in the database, do the following steps:
- In project OAM project go to oam/solution/dev and in docker-compose.yaml in persistence service add ports mapping:
persistence: image: ${PERSISTENCE_IMAGE} container_name: persistence ports: - 9200:9200 - 9300:9300
Also in the sdnr service change:
- SDNRINIT=false
2. Run docker-compose.
3. Run the following commands:
- get all Elasticsearch indexes
curl -sS -X GET http://localhost:9200/_cat/indices\?v
- displaying the cmlog index
curl -sS -X GET http://localhost:9200/cmlog/_search \ -H 'content-type: application/json' \ -d '{ "query": { "match_all": {} } }'| jq .
MariaDB
To change your database configuration to MariaDB follow the steps in Migration to MariaDB paragraph.
Migration to MariaDB
- In project OAM project go to oam/solution/dev and in docker-compose.yaml add the following configuration:
- in services add
sdnrdb: image: ${SDNRDB_IMAGE} container_name: sdnrdb ports: - 3306:3306 environment: - MARIADB_ROOT_USER=${MARIADB_USER} - MARIADB_ROOT_PASSWORD=${MARIADB_PASSWORD} - MARIADB_GALERA_MARIABACKUP_PASSWORD=${MARIADB_BACKUP_PASSWORD} - MARIADB_DATABASE=${MARIADB_DATABASE} networks: oam: ipv4_address: ${SDNRDB_IP}
- add new code changes to sdnr service
sdnr: image: ${SDNC_IMAGE} container_name: sdnr ports: - ${SDNC_REST_PORT}:8181 - 8101:8101 - 8383:8383 environment: - SDNC_CONFIG_DIR=/opt/onap/ccsdk/data/properties - ODL_CERT_DIR=${SDNC_CERT_DIR} - ENABLE_ODL_CLUSTER=false - SDNC_REPLICAS=0 - CCSDK_REPLICAS=0 - DOMAIN="" - SDNRWT=true - SDNRINIT=false - SDNRONLY=true # - SDNRDBURL=http://persistence:9200 - SDNRDBUSERNAME=${MARIADB_USER} - SDNRDBPASSWORD=${MARIADB_PASSWORD} - A1_ADAPTER_NORTHBOUND=false - ODL_ADMIN_PASSWORD=${ADMIN_PASSWORD} - JAVA_OPTS= -Xms256m -Xmx4g -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8383 volumes: - ./sdnr/mountpoint-registrar.properties:/opt/opendaylight/etc/mountpoint-registrar.properties - ./sdnr/dataprovider.properties:/opt/opendaylight/etc/dataprovider.properties - ./sdnr/certs/certs.properties:${SDNC_CERT_DIR}/certs.properties - ./sdnr/certs/keys0.zip:${SDNC_CERT_DIR}/keys0.zip networks: oam: ipv4_address: ${SDNC_IP} depends_on: - persistence - sdnrdb
2. In the same folder in the .env file add the following configuration:
You have to specify MariaDB version from ranges 10.2.7 to 10.6.8. The range of currently supported MariaDB versions can be found in the project ccsdk/features in path: sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java.
# SDNRDB (MariaDB) SDNRDB_IMAGE=docker.io/bitnami/mariadb-galera:10.5.8 SDNRDB_IP=172.40.0.28 MARIADB_USER=sdnradmin MARIADB_PASSWORD=fly2sky MARIADB_BACKUP_PASSWORD=fly2sky MARIADB_DATABASE=sdnrdb
3. Go to oam/solution/dev/sdnr directory and create new file: dataprovider.properties that contains:
dbType=MARIADB [mariadb] url=jdbc:mysql://sdnrdb:3306/sdnrdb username=sdnradmin password=fly2sky
4. In the same location change file permissions for dataprovider.properties and mountpoint-registrar.properties to chmod 777.
5. Go back to oam/solution/dev and run docker-compose with command:
docker-compose up -d
6. Init MariaDB databases in sdnr container. Log in to sdnr bash with command:
docker exec -ti sdnr bash
7. Set SDNRDBURL:
export SDNRDBURL="jdbc:mysql://sdnrdb:3306/sdnrdb"
8. Run Data Migration Tool with command:
java -jar /opt/opendaylight/current/system/org/onap/ccsdk/features/sdnr/wt/sdnr-wt-data-provider-setup/1.3.0-SNAPSHOT/sdnr-wt-data-provider-setup-1.3.0-SNAPSHOT.jar -c init -db $SDNRDBURL -dbu $SDNRDBUSERNAME -dbp $SDNRDBPASSWORD -dbt mariadb
Note that you can have different version of sdnr-wt-data-provider-setup project. For more information about Data Migration Tool.
9. Scale sdnr container with commands:
docker-compose scale sdnr=0 docker-compose scale sdnr=1
10. Log in to MariaDB container with command:
docker exec -ti sdnrdb bash -c '/opt/bitnami/mariadb/bin/mysql -u"$MARIADB_ROOT_USER" -p"$MARIADB_ROOT_PASSWORD"'
11. Now you can use sdnrdb database and perform SQL operation. To check if the CM event has been persisted correctly in the database, use the following commands:
use sdnrdb; select * from cmlog;
Switch to Elasticsearch
If you want to get back to Elasticsearch configuration do the following steps:
1. In dataprovider.properties change dbType to:
dbType=ELASTICSEARCH
2. In docker-compose.yaml uncomment SDNRDBURL line:
- SDNRDBURL=http://persistence:9200
3. Run docker-compose.