Peg base openvino image to 2021.4
Parameterize hard-coded values
Change-Id: I0c3d4866709b5ea98056699818fbac53da979af4
diff --git a/Makefile b/Makefile
index 4341efd..1a24080 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,14 @@
PYTHON = $(VENV)/bin/python3
PIP = $(VENV)/bin/pip
+ROC_USER ?=
+ROC_PASSWD ?=
+ROC_URL ?=
+KEYCLOAK ?=
+ENTERPRISE ?=
+SITE ?=
+DEVICEGROUP ?=
+
all: test
help:
@@ -71,14 +79,20 @@
docker-push:
docker push $(DOCKER_IMAGENAME)
-docker-run:
+docker-run :
docker run \
-itu root:root \
--privileged \
--network host \
--name $(CONTAINER_NAME) \
--rm \
- $(DOCKER_IMAGENAME) --user "user" --password "password"
+ $(DOCKER_IMAGENAME) \
+ --url $(ROC_URL) \
+ --keycloak $(KEYCLOAK) \
+ --enterprise $(ENTERPRISE) \
+ --site $(SITE) \
+ --devicegroup $(DEVICEGROUP) \
+ --user $(ROC_USER) --password $(ROC_PASSWD)
run-native-file: $(VENV)
. ./bin/person_detection.sh -i ./resources/run.mp4
diff --git a/docker/Dockerfile b/docker/Dockerfile
index cf51c5b..0eed995 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,6 +1,5 @@
#python3 docker_openvino.py build -d cpu -os ubuntu18 --distribution runtime --product_version 2021.4
-#FROM ubuntu18_runtime:2021.4
-FROM openvino/ubuntu18_runtime
+FROM openvino/ubuntu18_runtime:2021.4
USER root
diff --git a/person_detection/app.py b/person_detection/app.py
index 2ef9b87..0c15bec 100644
--- a/person_detection/app.py
+++ b/person_detection/app.py
@@ -70,6 +70,18 @@
args.add_argument("--key",
help = "ROC api key",
type = str)
+ args.add_argument("--url",
+ help = "ROC url",
+ type = str)
+ args.add_argument("--keycloak",
+ help = "Keycloak url",
+ type = str)
+ args.add_argument("--enterprise",
+ help = "Enterprise ID",
+ type = str)
+ args.add_argument("--site",
+ help = "Site ID",
+ type = str)
args.add_argument("--user",
help = "ROC username",
type = str)
@@ -86,7 +98,6 @@
type=int)
args.add_argument("--devicegroup",
help="Camera device group",
- default="menlo-4g-cameras",
type=str)
return parser
@@ -106,7 +117,7 @@
key = args.key
if key is None:
if args.user is not None and args.password is not None:
- roc = Roc(config.url, args.user, args.password, config.enterprise, config.site)
+ roc = Roc(args.url, args.keycloak, args.user, args.password, args.enterprise, args.site)
key = roc.get_key()
else:
log.error("Either key or user/password required")
diff --git a/person_detection/base_camera.py b/person_detection/base_camera.py
index e2e85b6..bf849f1 100644
--- a/person_detection/base_camera.py
+++ b/person_detection/base_camera.py
@@ -68,7 +68,7 @@
lock = Lock()
activity_counter = Value('i', 0)
- def __init__(self, device, user, password, mbrlow, mbrhigh, devicegroup, noroc):
+ def __init__(self, device, url, keycloak, enterprise, site, user, password, mbrlow, mbrhigh, devicegroup, noroc):
self.mqttBroker = "localhost"
self.device = device
self.mbrlow = mbrlow
@@ -76,7 +76,7 @@
self.devicegroup = devicegroup
self.noroc = noroc
- self.roc = Roc(config.url, user, password, config.enterprise, config.site)
+ self.roc = Roc(url, keycloak, user, password, enterprise, site)
"""Start the background camera process if it isn't running yet."""
if BaseCamera.cameras[int(self.device)] == 0:
diff --git a/person_detection/config.py b/person_detection/config.py
index 72450c6..f1cb46e 100644
--- a/person_detection/config.py
+++ b/person_detection/config.py
@@ -3,7 +3,4 @@
SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
"""
-cameras = {"0": "Ain's desk", "1": "HungWei's desk", "2": "Shad's desk"}
-url = "https://roc.menlo.aetherproject.org/aether-roc-api/aether/v2.0.0/connectivity-service-v2/"
-enterprise = 'aether-onf'
-site = 'menlo-4g'
+cameras = {"0": "Camera 0", "1": "Camera 1", "2": "Camera 2"}
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 8d49589..13478e0 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -27,7 +27,7 @@
self.is_async_mode = True
self.device = device
self.client = client
- super(Camera, self).__init__(device, args.user, args.password, args.mbrlow, args.mbrhigh, args.devicegroup, args.noroc)
+ super(Camera, self).__init__(device, args.url, args.keycloak, args.enterprise, args.site, args.user, args.password, args.mbrlow, args.mbrhigh, args.devicegroup, args.noroc)
def __del__(self):
# stream.release()
diff --git a/person_detection/roc.py b/person_detection/roc.py
index 35680a4..7c12409 100644
--- a/person_detection/roc.py
+++ b/person_detection/roc.py
@@ -12,8 +12,9 @@
class Roc(object):
- def __init__(self, url, user, password, enterpriseId, siteId):
+ def __init__(self, url, keycloak, user, password, enterpriseId, siteId):
self.url = url
+ self.keycloak = keycloak
self.user = user
self.password = password
self.key = self.get_key()
@@ -64,10 +65,9 @@
response = requests.post(url, headers=self.headers(), json=m)
if response.status_code != 201:
log.error("Failed to set mbr, device_group:{}, mbr:{}, status_code: {}".format(device_group, mbr, response.status_code))
- sys.exit()
+ # sys.exit()
def get_key(self):
- url = "https://keycloak.opennetworking.org/auth/realms/master/protocol/openid-connect/token"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/x-www-form-urlencoded"
data = {
@@ -77,7 +77,7 @@
'password': self.password,
'scope': 'openid profile email groups'
}
- response = requests.post(url, data, headers)
+ response = requests.post(self.keycloak, data, headers)
key = json.loads(response.text)['access_token']
return key
@@ -91,19 +91,20 @@
log.debug("Testing roc...")
# use valid keycloak user/password
- url = "https://roc.menlo.aetherproject.org/aether-roc-api/aether/v2.0.0/connectivity-service-v2/"
+ url = "http://roc.aetherproject.net/aether-roc-api/aether/v2.0.0/connectivity-service-v2/"
user = sys.argv[1]
password = sys.argv[2]
- enterprise = 'aether-onf'
- site = 'menlo-4g'
+ enterprise = 'ase-4g-enterprise'
+ site = 'ase-site-4g'
+ keycloak = "http://keycloak.aetherproject.net/auth/realms/aether/protocol/openid-connect/token"
- roc = Roc(url, user, password, enterprise, site)
+ roc = Roc(url, keycloak, user, password, enterprise, site)
- cameras = "menlo-4g-cameras"
+ cameras = "ase-4g-device-group2"
mbr = roc.get_mbr(cameras)
print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))
- roc.set_mbr(cameras, 7000000)
+ roc.set_mbr(cameras, 6000000)
mbr = roc.get_mbr(cameras)
print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))