From: demx8as6 Date: Tue, 30 Mar 2021 08:56:02 +0000 (+0200) Subject: Init version X-Git-Tag: 2.2.0~25 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=562a65a378c3ce3df48947a1a335b89f59f17940;p=oam.git Init version IssueID: OAM-183 Signed-off-by: demx8as6 Change-Id: I4522cbdbf4b1cb56d2359c3e27e69765c96a3ade --- diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/READMEpy.md b/solution/dev/ves-test-collector/client-scripts-ves-v7/READMEpy.md new file mode 100644 index 0000000..182129d --- /dev/null +++ b/solution/dev/ves-test-collector/client-scripts-ves-v7/READMEpy.md @@ -0,0 +1,78 @@ +# VES Events + +VES: Virtual Event Streaming (HTTP1.1/json-schema) + +This document describes sending of VES events according to +[VES 7.2.1](https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/ves.git;a=blob;f=etc/CommonEventFormat_30.2.1_ONAP.json) +as expected by O-RAN Operation and Maintenance Interface Specification. + +## Prerequisites + +Python3 is expected to run the scripts. + +``` +pip3 install requests +``` + +## VES Domains + +The syntax of a single VES event is devices into a common header and an event +specific body. + +The event specific bodies are are identified by the VES domain. + +### VES Domain "fault" + +tbd. + +### VES Domain "heartbeat", + +tbd. + +### VES Domain "measurement", + +tbd. + +### VES Domain "mobileFlow", + +tbd. + +### VES Domain "notification", + +tbd. + +### VES Domain "other", + +tbd. + +### VES Domain "perf3gpp", + +tbd. + +### VES Domain "pnfRegistration", + +tbd. + +### VES Domain "sipSignaling", + +tbd. + +### VES Domain "stateChange", + +tbd. + +### VES Domain "stndDefined", + +tbd. + +### VES Domain "syslog", + +tbd. + +### VES Domain "thresholdCrossingAlert", + +tbd. + +### VES Domain "voiceQuality" + +tbd. diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/__pycache__/globalVesEventEmitter.cpython-38.pyc b/solution/dev/ves-test-collector/client-scripts-ves-v7/__pycache__/globalVesEventEmitter.cpython-38.pyc new file mode 100644 index 0000000..02f9dba Binary files /dev/null and b/solution/dev/ves-test-collector/client-scripts-ves-v7/__pycache__/globalVesEventEmitter.cpython-38.pyc differ diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/config.yml b/solution/dev/ves-test-collector/client-scripts-ves-v7/config.yml new file mode 100644 index 0000000..4ba069b --- /dev/null +++ b/solution/dev/ves-test-collector/client-scripts-ves-v7/config.yml @@ -0,0 +1,109 @@ +################################################################################ +# Copyright 2021 highstreet technologies GmbH +# +# 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. +# + +################################################################################ +# Configuration for interface tests + +################################################################################ +# DCAE VES Collector communication end point +vesEndpoint: + url: https://localhost:8443/eventListener/v7 + username: sample1 + password: sample1 + verify: False + +################################################################################ +# common generated event settings, please don't touch + +settings: + eventType: O_RAN_COMPONENT + sequence: 357 + +################################################################################ +# Information from document: SDN-R System Requirements +# +# a. VendorA 1234 BestInClass (1234) +# b. VendorA FancyNextGeneration (FYNG) +# c. VendorB R2D2 NewFuture (R2D2) +# d. VendorB 7200DEV (7DEV) +# e. VendorC TheSkyIsTheLimit (nSky) +# f. VendorC OpenSourceFirst (1OSF) + +# g. VendorA PNF5G (NO5G) +# h. VendorB PNF5G (VB5G) +# i. VendorC NGCell (NGCE) +# j. VendorC O-RU (SCRU) +# +# z. SDN-R Controller itself (SDNR) + +pnfType: + a234: + id: f2030d4a-8f0e-11eb-8dcd-0242ac130003 + model: "a234 BestInClass" + oamIpv4: 10.10.10.11 + vendor: VendorA + fyng: + id: f2030f70-8f0e-11eb-8dcd-0242ac130003 + model: FancyNextGeneration + oamIpv4: 10.10.10.11 + vendor: VendorA + r2d2: + id: f203111e-8f0e-11eb-8dcd-0242ac130003 + model: R2D2 NewFuture + oamIpv4: 10.10.10.11 + vendor: VendorB + 7dev: + id: f203136c-8f0e-11eb-8dcd-0242ac130003 + model: 7200DEV + oamIpv4: 10.10.10.11 + vendor: VendorB + nsky: + id: f203143e-8f0e-11eb-8dcd-0242ac130003 + model: TheSkyIsTheLimit + oamIpv4: 10.10.10.11 + vendor: VendorC + 1OSF: + id: f20317e0-8f0e-11eb-8dcd-0242ac130003 + model: OpenSourceFirst + oamIpv4: 10.10.10.11 + vendor: VendorC + no5g: + id: f20318b2-8f0e-11eb-8dcd-0242ac130003 + model: PNF5G + oamIpv4: 10.10.10.11 + vendor: VendorA + vb5g: + id: f2031966-8f0e-11eb-8dcd-0242ac130003 + model: PNF5G + oamIpv4: 10.10.10.11 + vendor: VendorB + ngce: + id: f2031a2e-8f0e-11eb-8dcd-0242ac130003 + model: NGCell + oamIpv4: 10.10.10.11 + vendor: VendorC + scru: + id: 4365333e-8f0f-11eb-8dcd-0242ac130003 + model: O-RU + oamIpv4: 10.10.10.11 + vendor: VendorC + interface: LP-MWPS-RADIO + sdnr: + id: 4365360e-8f0f-11eb-8dcd-0242ac130003 + model: "ONAP SDN Controller for Radio" + oamIpv4: 127.0.0.1 + vendor: ONAP + interface: northbound-interface diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/globalVesEventEmitter.py b/solution/dev/ves-test-collector/client-scripts-ves-v7/globalVesEventEmitter.py new file mode 100644 index 0000000..30d596f --- /dev/null +++ b/solution/dev/ves-test-collector/client-scripts-ves-v7/globalVesEventEmitter.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +################################################################################ +# Copyright 2021 highstreet technologies GmbH +# +# 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. +# + +################################################################################ +# A selection of common methods + +import datetime +import json +import os +import socket +import yaml +from pathlib import Path + +def getInitData(domain): + currentTime = datetime.datetime.utcnow() + dir = os.path.dirname(os.path.realpath(__file__)) + + result = {} + result['domain']= domain + result['directory']= dir + result['outdir']= dir + '/json/examples' + result['fqdn']= socket.getfqdn() + result['timestamp']= int(currentTime.timestamp()*1000000) + result['eventTime']= currentTime.isoformat() + 'Z' + + # Read config + with open('config.yml', 'r') as stream: + try: + result['config']= yaml.safe_load(stream) + except yaml.YAMLError as exc: + print(exc) + + # Read template body + templateFileName = dir + '/json/templates/' + domain + '.json' + with open(templateFileName) as f: + result['body']= json.load(f) + + + Path(result["outdir"]).mkdir(parents=True, exist_ok=True) + return result diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesHeartbeat.py b/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesHeartbeat.py new file mode 100644 index 0000000..4e1ff2d --- /dev/null +++ b/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesHeartbeat.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +################################################################################ +# Copyright 2021 highstreet technologies GmbH +# +# 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. +# + +################################################################################ +# Send a VES event for domain 'heartbeat' + +# importing the datetime, json, requests, os socket and yaml library +import json +import requests +from globalVesEventEmitter import getInitData + +# Globals +domain = 'heartbeat' +initData = getInitData(domain) + +print('################################################################################') +print('# send SDN-Controller ' + domain) + +initData['body']['event']['commonEventHeader']['domain'] = initData['domain'] +initData['body']['event']['commonEventHeader']['eventId'] = initData['fqdn'] + '_' + initData['eventTime'] +initData['body']['event']['commonEventHeader']['eventName'] = initData['domain'] + '_' + initData['config']['settings']['eventType'] +initData['body']['event']['commonEventHeader']['eventType'] = initData['config']['settings']['eventType'] +initData['body']['event']['commonEventHeader']['sequence'] = initData['config']['settings']['sequence'] +initData['body']['event']['commonEventHeader']['reportingEntityName'] = initData['fqdn'] +initData['body']['event']['commonEventHeader']['sourceName'] =initData['fqdn'] +initData['body']['event']['commonEventHeader']['startEpochMicrosec'] = initData['timestamp'] +initData['body']['event']['commonEventHeader']['lastEpochMicrosec'] = initData['timestamp'] +initData['body']['event']['commonEventHeader']['nfNamingCode'] = 'SDN-Controller' +initData['body']['event']['commonEventHeader']['nfVendorName'] = 'O-RAN-SC OAM' + +initData['body']['event']['heartbeatFields']['additionalFields']['eventTime'] = initData['eventTime'] + +# Save example body +outputFileName = initData['directory'] + '/json/examples/' + domain + '.json' +with open(outputFileName, 'w') as f: + json.dump(initData['body'], f, indent=2, sort_keys=True) + +# Send VES Event +url = initData['config']['vesEndpoint']['url'] +username = initData['config']['vesEndpoint']['username'] +password = initData['config']['vesEndpoint']['password'] +verify = initData['config']['vesEndpoint']['verify'] +response = requests.post(url, json=initData['body'], auth=(username, password), verify=verify) +print(response) diff --git a/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesNotification.py b/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesNotification.py new file mode 100644 index 0000000..d6d0adc --- /dev/null +++ b/solution/dev/ves-test-collector/client-scripts-ves-v7/sendVesNotification.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +################################################################################ +# Copyright 2021 highstreet technologies GmbH +# +# 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. +# + +################################################################################ +# Send a VES event for domain 'notification' + +# importing the datetime, json, requests, os socket and yaml library +import datetime +import json +import requests +import os +import socket +import yaml +from pathlib import Path + +# Globals +dir = os.path.dirname(os.path.realpath(__file__)) +domain = "heartbeat" +fqdn = socket.getfqdn() + +# time formats +currentTime = datetime.datetime.utcnow() +timestamp = int(currentTime.timestamp()*1000000) +eventTime = currentTime.isoformat() + "Z" + +# Create output path +Path(dir + "/json/examples").mkdir(parents=True, exist_ok=True) + +# Read settings +with open("config.yml", 'r') as stream: + try: + cfg = yaml.safe_load(stream) + except yaml.YAMLError as exc: + print(exc) + +print("################################################################################") +print("# send SDN-Controller " + domain) + +# Read template body +templateFileName = dir + "/json/templates/" + domain + ".json" +with open(templateFileName) as f: + data = json.load(f) + +data["event"]["commonEventHeader"]["domain"] = domain +data["event"]["commonEventHeader"]["eventId"] = fqdn + "_" + eventTime +data["event"]["commonEventHeader"]["eventName"] = domain + \ + "_" + cfg["settings"]["eventType"] +data["event"]["commonEventHeader"]["eventType"] = cfg["settings"]["eventType"] +data["event"]["commonEventHeader"]["sequence"] = cfg["settings"]["sequence"] +data["event"]["commonEventHeader"]["reportingEntityName"] = fqdn +data["event"]["commonEventHeader"]["sourceName"] = fqdn +data["event"]["commonEventHeader"]["startEpochMicrosec"] = timestamp +data["event"]["commonEventHeader"]["lastEpochMicrosec"] = timestamp +data["event"]["commonEventHeader"]["nfNamingCode"] = "SDN-Controller" +data["event"]["commonEventHeader"]["nfVendorName"] = "O-RAN-SC OAM" + +data["event"]["heartbeatFields"]["additionalFields"]["eventTime"] = eventTime + +# save example body +outputFileName = dir + "/json/examples/" + domain + ".json" +with open(outputFileName, 'w') as f: + json.dump(data, f, indent=2, sort_keys=True) + +# Send VES Event +url = cfg["vesEndpoint"]["url"] +username = cfg["vesEndpoint"]["username"] +password = cfg["vesEndpoint"]["password"] +verify = cfg["vesEndpoint"]["verify"] +response = requests.post(url, json=data, auth=(username, password), verify=verify) +print(response)