2 ################################################################################
3 # Copyright 2021 highstreet technologies GmbH
5 # Licensed under the Apache License, Version 2.0 (the 'License');
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # https://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an 'AS IS' BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 ################################################################################
19 # Send a VES event for domain 'stndDefined' with 3gpp fault body
20 # https://raw.githubusercontent.com/onap/testsuite/master/robot/assets/dcae/ves_stndDefined_3GPP-FaultSupervision.json
21 # https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/faultMnS.yaml
23 # importing the sys, json, requests library
28 from globalVesEventEmitter import getInitData, saveExample, sendVesEvent
30 # Construct VES body and send
31 def performJob(domain, pnfId, stdnBody):
32 initData = getInitData(domain, stdnBody)
33 initData['pnfId'] = pnfId
35 print('################################################################################')
36 print(' '.join( ('# send VES', domain, stdnBody) ) )
38 initData['body']['event']['commonEventHeader']['domain'] = initData['domain']
39 initData['body']['event']['commonEventHeader']['eventId'] = initData['fqdn'] + \
40 '_' + initData['eventTime']
41 initData['body']['event']['commonEventHeader']['eventName'] = initData['domain'] + \
42 '_' + initData['config']['settings']['eventType']
43 initData['body']['event']['commonEventHeader']['eventType'] = initData['config']['settings']['eventType']
44 initData['body']['event']['commonEventHeader']['sequence'] = initData['config']['settings']['sequence']
45 initData['body']['event']['commonEventHeader']['reportingEntityName'] = initData['fqdn']
46 initData['body']['event']['commonEventHeader']['sourceName'] = initData['pnfId']
47 initData['body']['event']['commonEventHeader']['startEpochMicrosec'] = initData['timestamp']
48 initData['body']['event']['commonEventHeader']['lastEpochMicrosec'] = initData['timestamp']
49 initData['body']['event']['commonEventHeader']['nfNamingCode'] = initData['pnfId']
50 initData['body']['event']['commonEventHeader']['nfVendorName'] = 'O-RAN-SC OAM'
52 initData['body']['event']['stndDefinedFields']['data']['eventTime'] = initData['eventTime']
53 initData['body']['event']['stndDefinedFields']['data']['eventTime'] = initData['interface']
59 sendVesEvent(initData)
62 # Analysing command line parameters
64 domain = 'stndDefined'
65 usage = 'sendVesStndDefined.py --pnfId <physical-network-function-nwuid> --body <3gpp-Fault | 3GPP-Heartbeat | 3GPP-PerformanceAssurance | 3GPP-Provisioning>'
69 opts, args = getopt.getopt(argv, "hi:o:", ["pnfId=", "body="])
70 except getopt.GetoptError:
74 if opt in ('-h', '--help'):
77 elif opt in ("-p", "--pnfId"):
79 elif opt in ("-b", "--body"):
82 performJob(domain, pnfId, stdnBody)
85 if __name__ == "__main__":