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