X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=solution%2Fdev%2Fves-test-collector%2Fclient-scripts-ves-v7%2FglobalVesEventEmitter.py;fp=solution%2Fdev%2Fves-test-collector%2Fclient-scripts-ves-v7%2FglobalVesEventEmitter.py;h=30d596f11faaee802b5565cd5ddad5c181d65e49;hb=562a65a378c3ce3df48947a1a335b89f59f17940;hp=0000000000000000000000000000000000000000;hpb=0d8a83b634100eb2f07e670ef54b9d0caa0f7a4e;p=oam.git 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