Create VES client example for domain 'stateChange'
[oam.git] / solution / dev / ves-test-collector / client-scripts-ves-v7 / globalVesEventEmitter.py
index 30d596f..1776b96 100644 (file)
@@ -36,6 +36,7 @@ def getInitData(domain):
   result['fqdn']= socket.getfqdn()
   result['timestamp']= int(currentTime.timestamp()*1000000)
   result['eventTime']= currentTime.isoformat() + 'Z'
+  result['interface']= "urn:ietf:params:xml:ns:yang:ietf-interfaces:interfaces/interface/name='O-RAN-SC-OAM'"
 
   # Read config
   with open('config.yml', 'r') as stream:
@@ -52,3 +53,14 @@ def getInitData(domain):
   
   Path(result["outdir"]).mkdir(parents=True, exist_ok=True)
   return result
+
+def saveExample(data):
+  if 'directory' in data and 'domain' in data and 'body' in data:
+    name = data['domain']
+    if 'pnfId' in data: name = '-'.join( (data['pnfId'], data['domain']) )
+    outputFileName = data['directory'] + '/json/examples/' + name + '.json'
+    with open(outputFileName, 'w') as f:
+      json.dump(data['body'], f, indent=2, sort_keys=True)
+  else:
+    print("Example could not been saved:\n" + json.dump(data, f, indent=2, sort_keys=True)) 
+  
\ No newline at end of file