From 82e51367820e95b6bf6b0679771555b901bc3bdf Mon Sep 17 00:00:00 2001 From: ktimoney Date: Mon, 28 Aug 2023 13:41:45 +0100 Subject: [PATCH] Update pm-rapp to use pmproducer Issue-ID: NONRTRIC-916 Change-Id: Iaaf1159f3f47916805c95927e81d1c7914d75c3a Signed-off-by: ktimoney --- docker-proj/README.md | 34 +++++++++ docker-proj/config/pmrapp/jobDefinition.json | 19 +++++ docker-proj/docker-compose-pmrapp.yaml | 43 ++++++++++++ docker-proj/pmrapp-setup.sh | 81 ++++++++++++++++++++++ docker-proj/pmrapp-tear-down.sh | 26 +++++++ install/helm/nrt-pm-rapp/config/jobDefinition.json | 20 ++++-- pm-rapp/main.go | 9 +-- 7 files changed, 219 insertions(+), 13 deletions(-) create mode 100644 docker-proj/config/pmrapp/jobDefinition.json create mode 100644 docker-proj/docker-compose-pmrapp.yaml create mode 100755 docker-proj/pmrapp-setup.sh create mode 100755 docker-proj/pmrapp-tear-down.sh diff --git a/docker-proj/README.md b/docker-proj/README.md index 1a6cf9e..9a73ef7 100644 --- a/docker-proj/README.md +++ b/docker-proj/README.md @@ -1,3 +1,18 @@ +## License + +Copyright (C) 2023 Nordix Foundation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + ## RANPM project in docker A docker compose project showing pm file flow from simulated network elements to filtered pm data. @@ -54,6 +69,25 @@ To remove run: To update the filter edit and run: `./update-pmlog.sh` +### PM rApp +Additionally you can install PM rApp. + +Build PM rApp + +`cd ranpm/pm-rapp` + +`./build.sh no-push` + +Install PM rApp + +`cd ranpm/docker-proj` + +Example cmd: \ +`./pmrapp-setup.sh` + +To remove run: +`./pmrapp-tear-down.sh` + ### Tools for monitoring diff --git a/docker-proj/config/pmrapp/jobDefinition.json b/docker-proj/config/pmrapp/jobDefinition.json new file mode 100644 index 0000000..95bf18e --- /dev/null +++ b/docker-proj/config/pmrapp/jobDefinition.json @@ -0,0 +1,19 @@ +{ + "info_type_id": "PmData", + "job_owner": "console", + "job_definition": { + "filter": { + "sourceNames": [], + "measObjInstIds": [], + "measTypeSpecs": [ + { + "measuredObjClass": "NRCellDU", + "measTypes": [ + "pmCounterNumber101" + ] + } + ], + "measuredEntityDns": [] + } + } +} diff --git a/docker-proj/docker-compose-pmrapp.yaml b/docker-proj/docker-compose-pmrapp.yaml new file mode 100644 index 0000000..1099184 --- /dev/null +++ b/docker-proj/docker-compose-pmrapp.yaml @@ -0,0 +1,43 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +version: '3.0' +networks: + default: + external: true + name: nonrtric-docker-net + +services: + pm-rapp: + image: $PMRAPP_IMAGE + container_name: pm-rapp + environment: + APPID: pm-rapp + APPNS: 'nonrtric' + KAFKA_SERVER: kafka-1:9097 + ICS: ics:8083 + TOPIC: rapp-topic + LOG_PAYLOAD: '1' + GZIP: '' + CREDS_GRANT_TYPE: client_credentials + CREDS_CLIENT_SECRET: $PMRAPP_CLIENT_SECRET + CREDS_CLIENT_ID: pm-rapp + volumes: + - ./config/pmrapp:/config + labels: + - "ranpm=yes" + - "ranpmrapp=yes" diff --git a/docker-proj/pmrapp-setup.sh b/docker-proj/pmrapp-setup.sh new file mode 100755 index 0000000..88ad22f --- /dev/null +++ b/docker-proj/pmrapp-setup.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +. scripts/get_influxdb2_token.sh +. scripts/populate_keycloak.sh + +print_usage() { + echo "Usage: pmrapp-setup.sh" + exit 1 +} + +check_error() { + if [ $1 -ne 0 ]; then + echo "Failed $2" + echo "Exiting..." + exit 1 + fi +} + +setup_init() { +echo "Cleaning previously started containers..." +./pmrapp-tear-down.sh +} + +check_images(){ +export PMRAPP_IMAGE="pm-rapp:latest" +} + +create_topic() { +TOPIC="rapp-topic" +retcode=1 +rt=43200000 +echo "Creating topic $TOPIC with retention $(($rt/1000)) seconds" +while [ $retcode -ne 0 ]; do + cmd_output=$(docker exec -it common-kafka-1-1 ./bin/kafka-topics.sh \ + --create --topic $TOPIC --config retention.ms=$rt --bootstrap-server kafka-1:9092) + retcode=$? + test_string="Topic 'rapp-topic' already exists" + if [[ $cmd_output == *${test_string}* ]]; then + echo $test_string + retcode=0 + fi +done +} + +setup_pmrapp() { +create_topic + +cid="pm-rapp" +create_clients nonrtric-realm $cid +check_error $? +generate_client_secrets nonrtric-realm $cid +check_error $? + +export PMRAPP_CLIENT_SECRET=$(< .sec_nonrtric-realm_$cid) +envsubst < docker-compose-pmrapp.yaml > docker-compose-pmrapp_gen.yaml +docker-compose -p pmrapp -f docker-compose-pmrapp_gen.yaml up -d +} +## Main ## +setup_init + +check_images + +setup_pmrapp +check_error $? diff --git a/docker-proj/pmrapp-tear-down.sh b/docker-proj/pmrapp-tear-down.sh new file mode 100755 index 0000000..5d02e9d --- /dev/null +++ b/docker-proj/pmrapp-tear-down.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +echo "Stop and remove all pm-rapp containers in the project" + +docker stop $(docker ps -qa --filter "label=ranpmrapp") 2> /dev/null +docker stop $(docker ps -qa --filter "label=ranpmrapp") 2> /dev/null +docker rm -f $(docker ps -qa --filter "label=ranpmrapp") 2> /dev/null + +docker-compose -f docker-compose-pmrapp_gen.yaml -p pmrapp down diff --git a/install/helm/nrt-pm-rapp/config/jobDefinition.json b/install/helm/nrt-pm-rapp/config/jobDefinition.json index 2882533..386744e 100644 --- a/install/helm/nrt-pm-rapp/config/jobDefinition.json +++ b/install/helm/nrt-pm-rapp/config/jobDefinition.json @@ -1,14 +1,20 @@ { - "info_type_id": "json-file-data-from-filestore", + "info_type_id": "PmData", "job_owner": "console", "status_notification_uri": "http://callback.nonrtric:80/post", "job_definition": { - "kafkaOutputTopic": "", - "filterType": "pmdata", "filter": { - "measTypes": [ - "pmCounterNumber101" - ] + "sourceNames": [], + "measObjInstIds": [], + "measTypeSpecs": [ + { + "measuredObjClass": "NRCellDU", + "measTypes": [ + "pmCounterNumber101" + ] + } + ], + "measuredEntityDns": [] } } -} \ No newline at end of file +} diff --git a/pm-rapp/main.go b/pm-rapp/main.go index c718add..86f1b3c 100644 --- a/pm-rapp/main.go +++ b/pm-rapp/main.go @@ -45,10 +45,8 @@ import ( type JobDefinition struct { InfoTypeID string `json:"info_type_id"` JobOwner string `json:"job_owner"` - JobResultURI string `json:"job_result_uri"` + StatusNotificationURI string `json:"status_notification_uri"` JobDefinition struct { - KafkaOutputTopic string `json:"kafkaOutputTopic"` - FilterType string `json:"filterType"` Filter json.RawMessage `json:"filter"` DeliveryInfo struct { Topic string `json:"topic"` @@ -165,13 +163,12 @@ func main() { os.Exit(1) } job_type := job_json.InfoTypeID - job_json.JobDefinition.KafkaOutputTopic = topic job_json.JobDefinition.DeliveryInfo.Topic = topic job_json.JobDefinition.DeliveryInfo.BootStrapServers = bootstrapserver - gid = "pm-rapp-" + job_type + "-" + rapp_id + gid = "pm-rapp-" + job_type + "-" + rapp_id - jobid = "rapp-job-" + job_type + "-" + rapp_id + jobid = "rapp-job-" + job_type + "-" + rapp_id json_bytes, err := json.Marshal(job_json) if err != nil { -- 2.16.6