mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-05-08 19:38:07 +00:00
fixes docker container building issues
This commit is contained in:
parent
692f55f6af
commit
aecf7c0c02
@ -1,6 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from flask import Flask, Response, request
|
from flask import Flask, Response, request
|
||||||
from gevent import wsgi
|
from gevent.pywsgi import WSGIServer
|
||||||
|
|
||||||
from openmtc_app.onem2m import ResourceManagementXAE
|
from openmtc_app.onem2m import ResourceManagementXAE
|
||||||
from orion_api import OrionAPI
|
from orion_api import OrionAPI
|
||||||
@ -10,7 +10,7 @@ class OrionContextBroker(ResourceManagementXAE):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
orion_host="http://localhost:1026",
|
orion_host="http://localhost:1026",
|
||||||
orion_api="v2",
|
orion_api="v2",
|
||||||
labels=["openmtc:sensor_data"],
|
labels=None,
|
||||||
accumulate_address="http://localhost:8080",
|
accumulate_address="http://localhost:8080",
|
||||||
*args,
|
*args,
|
||||||
**kw):
|
**kw):
|
||||||
@ -19,11 +19,12 @@ class OrionContextBroker(ResourceManagementXAE):
|
|||||||
self.labels = {labels}
|
self.labels = {labels}
|
||||||
elif hasattr(labels, '__iter__'):
|
elif hasattr(labels, '__iter__'):
|
||||||
self.labels = set(labels)
|
self.labels = set(labels)
|
||||||
|
elif labels is None:
|
||||||
|
self.labels = ["openmtc:sensor_data"]
|
||||||
else:
|
else:
|
||||||
self.labels = None
|
self.labels = None
|
||||||
self._entity_names = {}
|
self._entity_names = {}
|
||||||
self._subscriptions = {}
|
self._subscriptions = {}
|
||||||
self.logger.critical(accumulate_address)
|
|
||||||
self.orion_api = OrionAPI(
|
self.orion_api = OrionAPI(
|
||||||
orion_host=orion_host,
|
orion_host=orion_host,
|
||||||
api_version=orion_api,
|
api_version=orion_api,
|
||||||
@ -38,8 +39,8 @@ class OrionContextBroker(ResourceManagementXAE):
|
|||||||
methods=["POST"])
|
methods=["POST"])
|
||||||
accumulate_ip, accumulate_port = accumulate_address.split('//')[
|
accumulate_ip, accumulate_port = accumulate_address.split('//')[
|
||||||
1].split(':')
|
1].split(':')
|
||||||
self.server = wsgi.WSGIServer(("0.0.0.0", int(accumulate_port)),
|
self.server = WSGIServer(("0.0.0.0", int(accumulate_port)),
|
||||||
self.app)
|
self.app)
|
||||||
self.server.start()
|
self.server.start()
|
||||||
|
|
||||||
def process_notification(self):
|
def process_notification(self):
|
||||||
@ -59,7 +60,8 @@ class OrionContextBroker(ResourceManagementXAE):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_entity_name(self, sensor_info):
|
@staticmethod
|
||||||
|
def _get_entity_name(sensor_info):
|
||||||
device_type = "sensor" if sensor_info.get("sensor_labels",
|
device_type = "sensor" if sensor_info.get("sensor_labels",
|
||||||
None) else "actuator"
|
None) else "actuator"
|
||||||
try:
|
try:
|
||||||
@ -113,6 +115,6 @@ class OrionContextBroker(ResourceManagementXAE):
|
|||||||
self.orion_api.update_attributes(
|
self.orion_api.update_attributes(
|
||||||
entity_name, data_dummy, fiware_service=fiware_service)
|
entity_name, data_dummy, fiware_service=fiware_service)
|
||||||
|
|
||||||
subscriptionId = self.orion_api.subscribe(
|
subscription_id = self.orion_api.subscribe(
|
||||||
entity_name, fiware_service=fiware_service)
|
entity_name, fiware_service=fiware_service)
|
||||||
self._subscriptions[subscriptionId] = actuator_info['ID']
|
self._subscriptions[subscription_id] = actuator_info['ID']
|
||||||
|
@ -260,6 +260,14 @@ rm -f "${target_docker_binary}"
|
|||||||
rm -f "${docker_tmp}/${name}-dependencies.txt"
|
rm -f "${docker_tmp}/${name}-dependencies.txt"
|
||||||
${docker_cmd} rm -f ${build_container_name} &> /dev/null
|
${docker_cmd} rm -f ${build_container_name} &> /dev/null
|
||||||
printf "done\n"
|
printf "done\n"
|
||||||
|
|
||||||
|
# remove dangling images
|
||||||
|
separator_line
|
||||||
|
printf "### Removing dangled images..."
|
||||||
|
for image in $(${docker_cmd} images -qa -f "dangling=true"); do
|
||||||
|
${docker_cmd} rmi -f ${image} > /dev/null
|
||||||
|
done
|
||||||
|
printf "done\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup SIGINT SIGTERM
|
trap cleanup SIGINT SIGTERM
|
||||||
@ -391,7 +399,7 @@ printf "%s\n" $(get_requirements_from_setup_file) | tr " " "\n" > \
|
|||||||
separator_line
|
separator_line
|
||||||
printf "### Building %s-%s container...\n" ${name} ${machine}
|
printf "### Building %s-%s container...\n" ${name} ${machine}
|
||||||
|
|
||||||
${docker_cmd} build -t ${target_docker_name} \
|
${docker_cmd} build --force-rm -t ${target_docker_name} \
|
||||||
-f ${target_docker_file} ${docker_path}
|
-f ${target_docker_file} ${docker_path}
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
printf "### Building %s-%s container failed. Exiting now.\n" \
|
printf "### Building %s-%s container failed. Exiting now.\n" \
|
||||||
@ -405,15 +413,6 @@ printf "### Base %s-%s container built successfully.\n" ${name} ${machine}
|
|||||||
# cleanup
|
# cleanup
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# remove dangling images
|
|
||||||
separator_line
|
|
||||||
printf "### Removing dangled images..."
|
|
||||||
for image in $(${docker_cmd} images -qa -f "dangling=true"); do
|
|
||||||
${docker_cmd} rmi -f ${image} > /dev/null
|
|
||||||
done
|
|
||||||
printf "done\n"
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# example to run the docker file
|
# example to run the docker file
|
||||||
#${docker_cmd} run --name test -d \
|
#${docker_cmd} run --name test -d \
|
||||||
|
@ -10,6 +10,9 @@ ENV MOD_NAME=sdk
|
|||||||
# Set the file maintainer
|
# Set the file maintainer
|
||||||
MAINTAINER rst/tgu
|
MAINTAINER rst/tgu
|
||||||
|
|
||||||
|
# update pip to latest version
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
# install openmtc dependencies
|
# install openmtc dependencies
|
||||||
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
|
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
|
||||||
RUN pip install --upgrade --requirement /tmp/requirements.txt
|
RUN pip install --upgrade --requirement /tmp/requirements.txt
|
||||||
|
@ -10,6 +10,9 @@ ENV MOD_NAME=sdk
|
|||||||
# Set the file maintainer
|
# Set the file maintainer
|
||||||
MAINTAINER rst/tgu
|
MAINTAINER rst/tgu
|
||||||
|
|
||||||
|
# update pip to latest version
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
# install openmtc dependencies
|
# install openmtc dependencies
|
||||||
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
|
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
|
||||||
RUN pip install --upgrade --requirement /tmp/requirements.txt
|
RUN pip install --upgrade --requirement /tmp/requirements.txt
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# or $ sudo pip install --requirement dependencies.txt
|
# or $ sudo pip install --requirement dependencies.txt
|
||||||
|
|
||||||
urllib3
|
urllib3
|
||||||
gevent>=1.0
|
gevent>=1.1
|
||||||
iso8601>=0.1.5
|
iso8601>=0.1.5
|
||||||
werkzeug>=0.9
|
werkzeug>=0.9
|
||||||
funcy
|
funcy
|
||||||
|
@ -6,7 +6,7 @@ from operator import itemgetter
|
|||||||
from socket import AF_INET, AF_INET6, getaddrinfo, SOCK_STREAM, inet_pton
|
from socket import AF_INET, AF_INET6, getaddrinfo, SOCK_STREAM, inet_pton
|
||||||
|
|
||||||
from funcy import pluck
|
from funcy import pluck
|
||||||
from gevent.wsgi import WSGIHandler, WSGIServer
|
from gevent.pywsgi import WSGIHandler, WSGIServer
|
||||||
from werkzeug.wrappers import (BaseRequest, CommonRequestDescriptorsMixin,
|
from werkzeug.wrappers import (BaseRequest, CommonRequestDescriptorsMixin,
|
||||||
UserAgentMixin, AcceptMixin, Response)
|
UserAgentMixin, AcceptMixin, Response)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user