mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-06-25 00:39:08 +00:00
Compare commits
1 Commits
developmen
...
feature-pe
Author | SHA1 | Date | |
---|---|---|---|
be50e35148 |
57
.travis.yml
57
.travis.yml
@ -1,26 +1,26 @@
|
||||
services:
|
||||
- docker
|
||||
- docker
|
||||
dist: xenial
|
||||
before_script:
|
||||
- sudo apt update
|
||||
- sudo apt install qemu-user-static python3 python3-pip python3-setuptools
|
||||
- sudo pip3 install --upgrade pip
|
||||
- sudo python3 -m pip install --upgrade setuptools
|
||||
- sudo python3 -m pip install --upgrade pyresttest
|
||||
- "./create-binary-docker backend"
|
||||
- "./create-binary-docker backend -a arm"
|
||||
- "./create-binary-docker gateway"
|
||||
- "./create-binary-docker gateway -a arm"
|
||||
- "./create-binary-docker orioncontextbroker"
|
||||
- "./create-binary-docker orioncontextbroker -a arm"
|
||||
- "./create-binary-docker influxdbapp"
|
||||
- "./create-binary-docker influxdbapp -a arm"
|
||||
- "./create-binary-docker cul868ipe"
|
||||
- "./create-binary-docker cul868ipe -a arm"
|
||||
- docker run -d --name backend -p 0.0.0.0:18000:18000 -e "ONEM2M_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" openmtc/backend-amd64 -v
|
||||
- docker logs backend
|
||||
- docker run -d --name gateway -p 0.0.0.0:8000:8000 -e "ONEM2M_HTTP_TRANSPORT_PORT=8000" -e "ONEM2M_CSE_ID=gateway" -e "ONEM2M_REMOTE_CSE_POA=<POA>" -e "ONEM2M_REMOTE_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" -e "ONEM2M_REGISTRATION_DISABLED=false" openmtc/gateway-amd64 -v
|
||||
- docker logs gateway
|
||||
- sudo apt update
|
||||
- sudo apt install qemu-user-static python3 python3-pip python3-setuptools
|
||||
- sudo pip3 install --upgrade pip
|
||||
- sudo python3 -m pip install --upgrade setuptools
|
||||
- sudo python3 -m pip install --upgrade pyresttest
|
||||
- "./create-binary-docker backend"
|
||||
- "./create-binary-docker backend -a arm"
|
||||
- "./create-binary-docker gateway"
|
||||
- "./create-binary-docker gateway -a arm"
|
||||
- "./create-binary-docker orioncontextbroker"
|
||||
- "./create-binary-docker orioncontextbroker -a arm"
|
||||
- "./create-binary-docker influxdbapp"
|
||||
- "./create-binary-docker influxdbapp -a arm"
|
||||
- "./create-binary-docker cul868ipe"
|
||||
- "./create-binary-docker cul868ipe -a arm"
|
||||
- docker run -d --name backend -p 0.0.0.0:18000:18000 -e "ONEM2M_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" openmtc/backend-amd64 -v
|
||||
- docker logs backend
|
||||
- docker run -d --name gateway -p 0.0.0.0:8000:8000 -e "ONEM2M_HTTP_TRANSPORT_PORT=8000" -e "ONEM2M_CSE_ID=gateway" -e "ONEM2M_REMOTE_CSE_POA=<POA>" -e "ONEM2M_REMOTE_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" -e "ONEM2M_REGISTRATION_DISABLED=false" openmtc/gateway-amd64 -v
|
||||
- docker logs gateway
|
||||
script:
|
||||
- docker tag openmtc/orioncontextbroker-amd64 openmtc/orion-context-broker-app-amd64
|
||||
- docker tag openmtc/orioncontextbroker-arm openmtc/orion-context-broker-app-arm
|
||||
@ -35,21 +35,6 @@ after_script:
|
||||
env:
|
||||
matrix:
|
||||
secure: oQe/MxxFrPPArxb6OFzOUwG2ZlA5GYekMR6qn0Y3101v82MdrIVgDILHR41iwykTtk1XpJPV9uabsRsvY4hBmbjYzihYZFOAzFf+/KU7wROtKum0fFfLjCPb8uGV41k1JTquB94FibXboVAP7rNL0Vrpl+FGUvMGatQBtwZnGvha6Ha07qTao+X9+0dJ4YvFlvcba/jfzBZBwHw7KHpRoiyKU0dPmXpHcqnZBFcNqRXhzdVrgx0auP/tghoshW5LQWkpTV11uSx/kYuby4oo8r8nB6L0rW1jYSXs9DHiTQCfCy24xlb9YJjCD9aFcjH0lIkVIqQwJYA67MzKYMK4XV684J/Jr3+jfVOoUt0bpZaTnk+r/uiFCtEsN7q0KUlvHLUAi1YNJhKs6CRrAH3GK25QByh+suzPzZoHP42F2LYP9URlzbDH+/v7CwNuw+9pHSmxEhs18LVmggwkMos3o3ArvzMLRNJ3QG1fdoxL/Ubqxhmvhy4rZi6vGQsiF64oX8PN0sRgXekTU/ma+6CTM6qhgkocMUYzT2r/6qd/9R3jmtxSZnikjkR6Iu9NLzAUY+cqnvvjohAvqYyj+tGlQfOPxAU9H4wXnbQWLBM8yn6yt2Ki+3+Jx4Owdv0oXVJpN0GWjMzIJ1nEus5odkWW+c4wcZb6m3Ak0PrzYPp2BgE=
|
||||
after_success:
|
||||
- if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
|
||||
docker push openmtc/backend-amd64;
|
||||
docker push openmtc/backend-arm;
|
||||
docker push openmtc/gateway-amd64;
|
||||
docker push openmtc/gateway-arm;
|
||||
docker push openmtc/orion-context-broker-app-amd64;
|
||||
docker push openmtc/orion-context-broker-app-arm;
|
||||
docker push openmtc/cul868-ipe-amd64;
|
||||
docker push openmtc/cul868-ipe-arm;
|
||||
docker push openmtc/influxdb-app-amd64;
|
||||
docker push openmtc/influxdb-app-arm;
|
||||
fi
|
||||
after_failure:
|
||||
- docker logs backend
|
||||
- docker logs gateway
|
||||
- coveralls
|
||||
- docker logs gateway
|
@ -1,6 +0,0 @@
|
||||
# Contributors ordered by number of commits
|
||||
|
||||
Ronald Steinke <rst-fokus>
|
||||
<ckl-fokus>
|
||||
Alexander Ortlieb <aor-fokus>
|
||||
Jason Fox <jason-fox>
|
18
README.md
18
README.md
@ -12,8 +12,6 @@
|
||||

|
||||
[](https://hub.docker.com/u/openmtc)
|
||||
[](https://travis-ci.org/OpenMTC/OpenMTC)
|
||||
[](https://snyk.io/test/github/OpenMTC/OpenMTC?targetFile=openmtc-gevent%2Frequirements.txt)
|
||||
[](https://coveralls.io/github/OpenMTC/OpenMTC?branch=master)
|
||||
|
||||
The OpenMTC SDK aims to provide developers with a convenient yet flexible tool
|
||||
to write oneM2M compliant applications. This includes network applications
|
||||
@ -24,16 +22,12 @@ This project is part of [FIWARE](https://www.fiware.org/). For more information
|
||||
check the FIWARE Catalogue entry for the
|
||||
[IoT Agents](https://github.com/Fiware/catalogue/tree/master/iot-agents).
|
||||
|
||||
| :books: [Documentation](https://fiware-openmtc.readthedocs.io) | :page_facing_up: [Site](http://www.openmtc.org) | :whale: [Docker Hub](https://hub.docker.com/u/openmtc) | :dart: [Roadmap](roadmap.md) |
|
||||
|
||||
# Content
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [API](#api)
|
||||
- [Quality Assurance](#quality-assurance)
|
||||
- [Training](#training)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
|
||||
@ -95,18 +89,10 @@ follows:
|
||||
|
||||
---
|
||||
|
||||
## Training
|
||||
|
||||
Some lessons on IPE Sensors, SDK and GUI Sensors can be found in our [Documentation](https://fiware-openmtc.readthedocs.io/en/latest/training/training-ipe-sensors/)
|
||||
|
||||
## Contributing
|
||||
|
||||
Contribution guidelines are detailed in the [CONTRIBUTIONS](https://github.com/OpenMTC/OpenMTC/blob/master/CONTRIBUTIONS.md) file.
|
||||
|
||||
## License
|
||||
## Licence
|
||||
|
||||
The OpenMTC SDK is licensed under the Eclipse Public License (EPL)
|
||||
version 1.
|
||||
|
||||
© 2018-2019 OpenMTC
|
||||
© 2018 OpenMTC
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
from urllib.parse import urljoin
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
|
||||
@ -90,8 +89,7 @@ class OrionAPI(LoggerMixin):
|
||||
"type": self._get_type(data_senml["v"]),
|
||||
"metadata": {
|
||||
"timestamp": {
|
||||
"value": datetime.fromtimestamp(float(data_senml["t"])).replace(microsecond=0).isoformat()
|
||||
if data_senml["t"] != "none" else data_senml["t"],
|
||||
"value": data_senml["t"],
|
||||
"type": "String"
|
||||
},
|
||||
"bn": {
|
||||
|
@ -7,7 +7,7 @@
|
||||
"default_content_type": "application/json"
|
||||
},
|
||||
"database": {
|
||||
"driver": "openmtc_server.db.nodb2.NoDB2",
|
||||
"driver": "openmtc_server.db.mongodb.MongoDB",
|
||||
"dropDB": true
|
||||
},
|
||||
"logging": {
|
||||
|
@ -1 +0,0 @@
|
||||
dependencies.txt
|
15
roadmap.md
15
roadmap.md
@ -1,15 +0,0 @@
|
||||
## Short Term
|
||||
onem2m Release 2a compatibility
|
||||
Group Resource
|
||||
Pub/Sub improvements (rateLimit and batchNotify)
|
||||
Persistence Enhancement
|
||||
|
||||
## Medium Term
|
||||
onem2m Release 3 compatibility
|
||||
Announcements
|
||||
FlexContainer Resource
|
||||
Node Resource
|
||||
|
||||
## Long Term
|
||||
CoAP(s) & MQTTS
|
||||
XML
|
148
server/openmtc-server/src/openmtc_server/db/mongodb.py
Normal file
148
server/openmtc-server/src/openmtc_server/db/mongodb.py
Normal file
@ -0,0 +1,148 @@
|
||||
|
||||
from openmtc_server.db import DBAdapter, Shelve, DBError
|
||||
from openmtc_server.db import BasicSession
|
||||
from copy import copy
|
||||
from collections import defaultdict, OrderedDict
|
||||
from openmtc_server.db.exc import DBConflict, DBNotFound
|
||||
from openmtc_onem2m.model import OneM2MResource, CSEBase, AE, Container, ContentInstance, Subscription, RemoteCSE
|
||||
from pymongo import MongoClient
|
||||
|
||||
res_type = {'2' : AE,
|
||||
'3' : Container,
|
||||
'4' : ContentInstance,
|
||||
'5' : CSEBase,
|
||||
'16' : RemoteCSE,
|
||||
'23' : Subscription}
|
||||
|
||||
class MongoDBSession(BasicSession):
|
||||
|
||||
|
||||
def __init__(self, db, std_type, *args, **kw):
|
||||
|
||||
self.db = db
|
||||
self.std_type = std_type
|
||||
self.resources = db['resources']
|
||||
|
||||
|
||||
|
||||
|
||||
def store(self, resource):
|
||||
|
||||
path = resource.path
|
||||
resource_type = type(resource)
|
||||
document = resource.values
|
||||
document ['path'] = path
|
||||
|
||||
self.logger.debug("Adding resource to db: %s -> %s (%s)",
|
||||
path, resource, resource_type)
|
||||
|
||||
self.resources.insert(document)
|
||||
|
||||
def _get(self, path):
|
||||
pass
|
||||
|
||||
|
||||
def get(self, path):
|
||||
|
||||
document = self.resources.find_one({'path': path}, {'_id': False})
|
||||
if document is None:
|
||||
document = self.resources.find_one({'resourceID':path}, {'_id': False})
|
||||
if document is None:
|
||||
raise DBNotFound
|
||||
res = self.func (document)
|
||||
return res
|
||||
|
||||
def func (self, document):
|
||||
res_type_value = document['resourceType']
|
||||
|
||||
modelclass = res_type[str(res_type_value)]
|
||||
#print modelclass(**document)
|
||||
return modelclass(**document)
|
||||
|
||||
|
||||
def get_collection(self, resource_type, parent, filter_criteria=None):
|
||||
self.logger.debug("Getting %s children of %s (%s)", resource_type,
|
||||
parent, parent.__model_name__)
|
||||
parentID = parent.resourceID
|
||||
find_children = self.resources.find({'parentID':parentID}, {'_id': False})
|
||||
children = map (self.func, find_children)
|
||||
return children
|
||||
|
||||
|
||||
|
||||
def exists(self, resource_type, fields):
|
||||
self.logger.debug("Checking existence of %s with %s", resource_type,
|
||||
fields)
|
||||
pass
|
||||
|
||||
def update(self, resource, fields=None):
|
||||
|
||||
document = resource.values
|
||||
path = resource.path
|
||||
# document ['path'] = path
|
||||
|
||||
#field = document [fields]
|
||||
|
||||
if fields == None or fields == []:
|
||||
document = document
|
||||
else:
|
||||
# change that document
|
||||
pass
|
||||
|
||||
|
||||
modify = self.resources.find_one_and_update({'path': path}, {'$set': document })
|
||||
|
||||
#print doc
|
||||
|
||||
|
||||
#document[fields] = fields
|
||||
|
||||
|
||||
|
||||
def delete(self, resource):
|
||||
document = resource.values
|
||||
self.resources.remove(document)
|
||||
|
||||
def commit(self):
|
||||
pass
|
||||
|
||||
def rollback(self):
|
||||
pass
|
||||
|
||||
|
||||
class MongoDBShelve(dict, Shelve):
|
||||
def commit(self):
|
||||
pass
|
||||
|
||||
def rollback(self):
|
||||
pass
|
||||
|
||||
|
||||
class MongoDB(DBAdapter):
|
||||
def __init__(self, *args, **kw):
|
||||
super(MongoDB, self).__init__(*args, **kw)
|
||||
|
||||
client = MongoClient('localhost', 27017)
|
||||
client.drop_database('mongodb')
|
||||
self.db = client['mongodb']
|
||||
#self.db.drop_collection()
|
||||
|
||||
self.onem2m_resources = None
|
||||
self.shelves = None
|
||||
self.initialized = False
|
||||
|
||||
def initialize(self, force=False):
|
||||
if not force and self.is_initialized():
|
||||
raise Exception("Already initialized")
|
||||
#self.onem2m_resources = None
|
||||
self.shelves = defaultdict(MongoDBShelve)
|
||||
self.initialized = True
|
||||
|
||||
def get_shelve(self, name):
|
||||
return self.shelves[name]
|
||||
|
||||
def start_session(self, std_type):
|
||||
return MongoDBSession(self.db, std_type)
|
||||
|
||||
def is_initialized(self):
|
||||
return self.initialized
|
@ -57,7 +57,7 @@ class NoDB2Session(BasicSession):
|
||||
assert path is not None
|
||||
self.logger.debug("Getting resource: %s", path)
|
||||
resource = self._get(path)
|
||||
return copy(resource)
|
||||
return copy(self._get(path))
|
||||
|
||||
def get_collection(self, resource_type, parent, filter_criteria=None):
|
||||
self.logger.debug("Getting %s children of %s (%s)", resource_type,
|
||||
|
Reference in New Issue
Block a user