Fix multiple client connect
Change-Id: I7b177d6d827ac2a19a228611e8298589e4026125
diff --git a/person_detection/mqtt.py b/person_detection/mqtt.py
index 89bed3f..ce40411 100644
--- a/person_detection/mqtt.py
+++ b/person_detection/mqtt.py
@@ -11,9 +11,6 @@
timer = {}
timestamp = {}
-def init(device):
- set_resolution(device, "low")
-
def person_detected(device, num):
timestamp[device] = time.time()
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 15c4e82..92a5e4a 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -38,8 +38,6 @@
self.device = device
- mqtt.init(device)
-
super(Camera, self).__init__(device, args.idle)
def __del__(self):
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"]))