Fix multiple client connect
Change-Id: I7b177d6d827ac2a19a228611e8298589e4026125
diff --git a/person_detection/roc.py b/person_detection/roc.py
new file mode 100644
index 0000000..96f2fe0
--- /dev/null
+++ b/person_detection/roc.py
@@ -0,0 +1,40 @@
+"""
+SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
+"""
+
+import requests
+import json
+from requests.structures import CaseInsensitiveDict
+
+TOKEN = '### A VALID TOKEN ###'
+
+#URL = "https://roc.aetherproject.org/aether-roc-api/aether/v4.0.0/connectivity-service-v4/"
+URL = "https://roc.staging.aether.onlab.us/aether-roc-api/aether/v4.0.0/connectivity-service-v4/"
+
+roc_headers = CaseInsensitiveDict()
+roc_headers["Content-Type"] = "application/json"
+roc_headers["Authorization"] = "Bearer " + TOKEN
+
+
+def get_mbr(device_group):
+ url = URL + "vcs/vcs/vcs-{}/slice/mbr".format(device_group)
+ response = requests.get(url, headers=roc_headers)
+ assert response.status_code == 200, "Failed to get mbr"
+ mbr = json.loads(response.text)
+ return mbr
+
+
+def set_mbr(device_group, mbr):
+ url = URL + "vcs/vcs/vcs-{}/slice/mbr".format(device_group)
+ response = requests.post(url, headers=roc_headers, json=mbr)
+ assert response.status_code == 201, "Failed to set mbr"
+
+
+if __name__ == '__main__':
+ mbr = get_mbr("cameras-4g")
+ print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))
+ mbr={'downlink':mbr["downlink"],'uplink':mbr["uplink"]}
+ set_mbr("cameras-4g", mbr)
+ mbr = get_mbr("cameras-4g")
+ print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))