Near-RT RIC simulator updates 36/2736/1
authorBjornMagnussonXA <bjorn.magnusson@est.tech>
Tue, 10 Mar 2020 15:32:08 +0000 (16:32 +0100)
committerBjornMagnussonXA <bjorn.magnusson@est.tech>
Tue, 10 Mar 2020 15:36:43 +0000 (16:36 +0100)
Added function to read metrics data.

Change-Id: I7f02eab917e3838e50600d6eeaa1027186fdfef9
Issue-ID: NONRTRIC-154
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
near-rt-ric-simulator/ric-plt/a1/main.py

index 48b7f2e..a715f59 100644 (file)
@@ -88,6 +88,18 @@ def set_status_with_reason(policyId, enforceStatus, enforceReason):
   policy_status[policyId] = ps
   return("Status updated for policy: " + policyId, 200)
 
   policy_status[policyId] = ps
   return("Status updated for policy: " + policyId, 200)
 
+#Metrics function
+
+@app.route('/counter/<string:countername>', methods=['GET'])
+def getCounter(countername):
+    if (countername == "num_instances"):
+        return str(len(policy_instances)),200
+    elif (countername == "num_types"):
+        return str(len(policy_types)),200
+    else:
+        return "Counter name: "+countername+" not found.",404
+
+
 port_number = 8085
 if len(sys.argv) >= 2:
   if isinstance(sys.argv[1], int):
 port_number = 8085
 if len(sys.argv) >= 2:
   if isinstance(sys.argv[1], int):