Compare commits

..

14 Commits

Author SHA1 Message Date
c769080008 adding a nicer view for some documents 2019-02-06 14:40:34 +01:00
240adda063 adding roadmap 2019-02-06 14:37:00 +01:00
c445531989 fixing type of timestamp 2019-02-06 14:27:22 +01:00
00a35a6080 Adding Contributions to readme 2019-02-06 14:27:22 +01:00
f8d8878561 Coverage badge 2019-02-06 14:27:22 +01:00
f19b0a5b9b Adding vulnerabilities (snyk) badge to README 2019-02-06 14:27:22 +01:00
3c4c34bf1f Better Workaround for Snyk to find requirements.txt 2019-02-06 14:27:22 +01:00
0beeff5ddd Workaround for Snyk to find requirements.txt 2019-02-06 14:27:22 +01:00
a7035a11b3 Revert "Hotfix for the wrong timestamp type"
This reverts commit 04a8929a
2019-02-05 18:51:59 +01:00
8776579926 Revert "Build new contextbroker"
This reverts commit 93ff704d
2019-02-05 18:51:40 +01:00
859f16c218 Revert "Build new contextbroker"
This reverts commit eb72374f
2019-02-05 18:51:28 +01:00
eb72374f89 Build new contextbroker 2019-01-31 14:56:39 +01:00
93ff704df4 Build new contextbroker 2019-01-31 14:40:21 +01:00
04a8929a97 Hotfix for the wrong timestamp type 2019-01-25 15:15:01 +01:00
7 changed files with 32 additions and 152 deletions

View File

@ -12,6 +12,8 @@
![Status](https://nexus.lab.fiware.org/static/badges/statuses/iot-openmtc.svg)
[![](https://img.shields.io/docker/pulls/openmtc/gateway-amd64.svg)](https://hub.docker.com/u/openmtc)
[![Build Status](https://travis-ci.org/OpenMTC/OpenMTC.svg?branch=master)](https://travis-ci.org/OpenMTC/OpenMTC)
[![Known Vulnerabilities](https://snyk.io/test/github/OpenMTC/OpenMTC/badge.svg?targetFile=openmtc-gevent%2Frequirements.txt)](https://snyk.io/test/github/OpenMTC/OpenMTC?targetFile=openmtc-gevent%2Frequirements.txt)
[![Coverage Status](https://coveralls.io/repos/github/OpenMTC/OpenMTC/badge.svg?branch=master)](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
@ -22,12 +24,16 @@ 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)
- [Contributing](#contributing)
- [License](#license)
@ -89,7 +95,11 @@ follows:
---
## Licence
## Contributing
Contribution guidelines are detailed in the [CONTRIBUTIONS](https://github.com/OpenMTC/OpenMTC/blob/master/CONTRIBUTIONS.md) file.
## License
The OpenMTC SDK is licensed under the Eclipse Public License (EPL)
version 1.

View File

@ -1,5 +1,6 @@
from urllib.parse import urljoin
import logging
from datetime import datetime
import requests
@ -89,7 +90,8 @@ class OrionAPI(LoggerMixin):
"type": self._get_type(data_senml["v"]),
"metadata": {
"timestamp": {
"value": data_senml["t"],
"value": datetime.fromtimestamp(float(data_senml["t"])).replace(microsecond=0).isoformat()
if data_senml["t"] != "none" else data_senml["t"],
"type": "String"
},
"bn": {

View File

@ -7,7 +7,7 @@
"default_content_type": "application/json"
},
"database": {
"driver": "openmtc_server.db.mongodb.MongoDB",
"driver": "openmtc_server.db.nodb2.NoDB2",
"dropDB": true
},
"logging": {

View File

@ -0,0 +1 @@
dependencies.txt

15
roadmap.md Normal file
View File

@ -0,0 +1,15 @@
## 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

View File

@ -1,148 +0,0 @@
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

View File

@ -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(self._get(path))
return copy(resource)
def get_collection(self, resource_type, parent, filter_criteria=None):
self.logger.debug("Getting %s children of %s (%s)", resource_type,