Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added feature config groups #1375

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Add /iot/configGroups API endpoints (as equivalent to /iot/services) (#752)
- Add: log and return device/group information when EntityGenericError, TypeNotFound, DeviceNotFound, BadTimestamp, BadGeocoordinates, CommandNotFound, GroupNotFound, MissingAttributes, DuplicateDeviceId and DuplicateGroup errors (iotagent-json#815)
- Hardening: simplify implementation so typeInformation contains global config values (#1515)
- Add: `POST /iot/op/delete` operation to delete multiple devices at once (#1578)
Expand Down
14 changes: 7 additions & 7 deletions doc/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ the `mongob` section (as described bellow). E.g.:

It configures the MongoDB driver for those repositories with 'mongodb' type. If the `host` parameter is a list of
comma-separated IPs, they will be considered to be part of a Replica Set. In that case, the optional property
`replicaSet` should contain the Replica Set name. If the database requires authentication, username (`user`),
password (`password`) and authSource (`authSource`) can be set. If the database requires TLS/SSL connection but any
validation of the certificate chain is not mandatory, all you need is to set the ssl (`ssl`) option as `true` to connect
the database. If you need to add more complex option(s) such as `retryWrites=true` or `w=majority` when connection
database, extraArgs (`extraArgs`) can be used to perform it. For The MongoBD driver will retry the connection at startup
time `retries` times, waiting `retryTime` seconds between attempts, if those attributes are present (default values are
5 and 5 respectively). E.g.:
`replicaSet` should contain the Replica Set name. If the database requires authentication, username (`user`), password
(`password`) and authSource (`authSource`) can be set. If the database requires TLS/SSL connection but any validation of
the certificate chain is not mandatory, all you need is to set the ssl (`ssl`) option as `true` to connect the database.
If you need to add more complex option(s) such as `retryWrites=true` or `w=majority` when connection database, extraArgs
(`extraArgs`) can be used to perform it. For The MongoBD driver will retry the connection at startup time `retries`
times, waiting `retryTime` seconds between attempts, if those attributes are present (default values are 5 and 5
respectively). E.g.:

```javascript
{
Expand Down
24 changes: 12 additions & 12 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ Config group is represented by a JSON object with the following fields:

The following actions are available under the config group endpoint:

#### Retrieve config groups `GET /iot/services`
#### Retrieve config groups GET `/iot/configGroups` or `GET /iot/services`

List all the config groups for the given `fiware-service` and `fiware-servicepath`. The config groups that match the
`fiware-servicepath` are returned in any other case.
Expand All @@ -1282,14 +1282,14 @@ Successful operations return `Content-Type` header with `application/json` value

_**Response payload**_

A JSON object with a services field that contains an array of services that match the request. See the
A JSON object with a configGroups or services field that contains an array of services that match the request. See the
[config group datamodel](#service-group-datamodel) for more information.

Example:

```json
{
"services": [
"configGroups": [
{
"resource": "/deviceTest",
"apikey": "801230BJKL23Y9090DSFL123HJK09H324HV8732",
Expand Down Expand Up @@ -1326,7 +1326,7 @@ Example:
}
```

#### Create config group `POST /iot/services`
#### Create config group `POST /iot/configGroups` or `POST /iot/services`

Creates a set of config groups for the given service and service path. The service and subservice information will taken
from the headers, overwritting any preexisting values.
Expand All @@ -1340,14 +1340,14 @@ _**Request headers**_

_**Request payload**_

A JSON object with a `services` field. The value is an array of config groups objects to create. See the
[config group datamodel](#service-group-datamodel) for more information.
A JSON object with a `configGroups` or `services` field. The value is an array of config groups objects to create. See
the [config group datamodel](#service-group-datamodel) for more information.

Example:

```json
{
"services": [
"configGroups": [
{
"resource": "/deviceTest",
"apikey": "801230BJKL23Y9090DSFL123HJK09H324HV8732",
Expand Down Expand Up @@ -1381,11 +1381,11 @@ _**Response headers**_

Successful operations return `Content-Type` header with `application/json` value.

#### Modify config group `PUT /iot/services`
#### Modify config group `PUT /iot/configGroups` or `PUT /iot/services`

Modifies the information of a config group, identified by the `resource` and `apikey` query parameters. Takes a service
group body as the payload. The body does not have to be complete: for incomplete bodies, just the attributes included in
the JSON body will be updated. The rest of the attributes will remain unchanged.
Modifies the information of a config group, identified by the `resource` and `apikey` query parameters. Takes a
configuration/service group body as the payload. The body does not have to be complete: for incomplete bodies, just the
attributes included in the JSON body will be updated. The rest of the attributes will remain unchanged.

_**Request query parameters**_

Expand Down Expand Up @@ -1421,7 +1421,7 @@ _**Response code**_
- 400 MISSING_HEADERS if any of the mandatory headers is not present.
- 500 SERVER ERROR if there was any error not contemplated above.:

#### Remove config group `DELETE /iot/services`
#### Remove config group `DELETE /iot/configGroups` or `DELETE /iot/services`

Removes a config group, identified by the `resource` and `apikey` query parameters.

Expand Down
40 changes: 26 additions & 14 deletions doc/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ product:
- cgroup literal in configuration groups management API (community)
- Refactor Append Mode & initial entity ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413))
- Native support for NGSI-v2 and LD ingestion ([#1451](https://github.com/telefonicaid/iotagent-node-lib/issues/1451))
- Remove plugins structure (bidirectional plugin) ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413))
- Remove plugins structure (bidirectional plugin)
([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413))
- Add init and improve log traces ([#1452](https://github.com/telefonicaid/iotagent-node-lib/issues/1452))
- Remove InMemory registry for Devices and Groups ([#1429](https://github.com/telefonicaid/iotagent-node-lib/issues/1429))
- Remove InMemory registry for Devices and Groups
([#1429](https://github.com/telefonicaid/iotagent-node-lib/issues/1429))

### Medium term

The following list of features are planned to be addressed in the medium term, typically within the subsequent
release(s) generated in the next 9 months after the next planned release:

- Allow to add metadata to attributes from measures ([#1453](https://github.com/telefonicaid/iotagent-node-lib/issues/1453))
- Allow to add metadata to attributes from measures
([#1453](https://github.com/telefonicaid/iotagent-node-lib/issues/1453))
- Cache support ([#1467](https://github.com/telefonicaid/iotagent-node-lib/issues/1467))
- MQTT per group advanced configuration (MQTT broker, topics) ([#1454](https://github.com/telefonicaid/iotagent-node-lib/issues/1454))
- MQTT per group advanced configuration (MQTT broker, topics)
([#1454](https://github.com/telefonicaid/iotagent-node-lib/issues/1454))
- Subscription based commands ([#1455](https://github.com/telefonicaid/iotagent-node-lib/issues/1455))
- Remove registration support ([#1456](https://github.com/telefonicaid/iotagent-node-lib/issues/1456))

Expand All @@ -49,29 +53,37 @@ The following list of features are proposals regarding the longer-term evolution
development of these features has not yet been scheduled for a release in the near future. Please feel free to contact
us if you wish to get involved in the implementation or influence the roadmap:

- Use the lightweight ingestion mechanism for connection oriented updates implemented in Context Broker (testing pending) ([#1457](https://github.com/telefonicaid/iotagent-node-lib/issues/1457))
- Add support to other transport protocols (BacNET, Modbus, etc) ([#1458](https://github.com/telefonicaid/iotagent-node-lib/issues/1458))
- Dynamic attribute generation (based on values array) ([#1459](https://github.com/telefonicaid/iotagent-node-lib/issues/1459))
- Use the lightweight ingestion mechanism for connection oriented updates implemented in Context Broker (testing
pending) ([#1457](https://github.com/telefonicaid/iotagent-node-lib/issues/1457))
- Add support to other transport protocols (BacNET, Modbus, etc)
([#1458](https://github.com/telefonicaid/iotagent-node-lib/issues/1458))
- Dynamic attribute generation (based on values array)
([#1459](https://github.com/telefonicaid/iotagent-node-lib/issues/1459))
- Incremental introduccion of ECMAScript6 syntax (previous analysis of which sub-set of interesting aspect we want to
take)

### Features already completed

The following list contains all features that were in the roadmap and have already been implemented.

- Refactor entities-NGSI-v2.js module ([#1166](https://github.com/telefonicaid/iotagent-node-lib/issues/1166)) ([3.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/3.0.0))
- Accept JEXL Expressions for entity name in autoprovisioned devices (entityNameExp) ([#1145](https://github.com/telefonicaid/iotagent-node-lib/issues/1145)) ([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
- Improve command functionalities (binary data + expression + mapping) ([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
- Refactor entities-NGSI-v2.js module ([#1166](https://github.com/telefonicaid/iotagent-node-lib/issues/1166))
([3.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/3.0.0))
- Accept JEXL Expressions for entity name in autoprovisioned devices (entityNameExp)
([#1145](https://github.com/telefonicaid/iotagent-node-lib/issues/1145))
([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
- Improve command functionalities (binary data + expression + mapping)
([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
- Support for "delta" measures (i.e. "temperature _increased_ in 5 degress" instead of "temperature _is_ 25")
- Allow to handle binary messages ([iota-ul#530](https://github.com/telefonicaid/iotagent-ul/issues/530))
- Removal support for NGSIv1 ([#966](https://github.com/telefonicaid/iotagent-node-lib/issues/966)) ([2.18.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.18.0))
- Removal support for NGSIv1 ([#966](https://github.com/telefonicaid/iotagent-node-lib/issues/966))
([2.18.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.18.0))
- Selectively ignore measure in the southbound interface
([iotagent-json#416](https://github.com/telefonicaid/iotagent-json/issues/416),
[iotagent-ul#372](https://github.com/telefonicaid/iotagent-ul/issues/372))
([2.13.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.13.0))
- JEXL support in expressions ([#801](https://github.com/telefonicaid/iotagent-node-lib/issues/801),
[#687](https://github.com/telefonicaid/iotagent-node-lib/issues/687),
[#868](https://github.com/telefonicaid/iotagent-node-lib/issues/868))
- JEXL support in expressions ([#801](https://github.com/telefonicaid/iotagent-node-lib/issues/801),
[#687](https://github.com/telefonicaid/iotagent-node-lib/issues/687),
[#868](https://github.com/telefonicaid/iotagent-node-lib/issues/868))
([2.13.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.13.0))
- Add MongoDB authentication support ([#844](https://github.com/telefonicaid/iotagent-node-lib/issues/844))
([2.12.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.12.0))
24 changes: 13 additions & 11 deletions docker/Mosquitto/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Thi directory containts the Dockerfile (and associated files) for a container of [mosquitto MQTT broker](https://mosquitto.org).
This container is provide as a help for users to test with MQTT, but it is just an auxiliary material in this repository.
Thi directory containts the Dockerfile (and associated files) for a container of
[mosquitto MQTT broker](https://mosquitto.org). This container is provide as a help for users to test with MQTT, but it
is just an auxiliary material in this repository.

The following releases matches with eclipse-mosquitto version:
- 2.1.0 uses mosquitto-2.0.11 from Debian 12
- 2.0.0 uses mosquitto-2.0.11 from Debian 11
- 1.6.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64 (from Centos7)
- 1.2.0 uses mosquitto-1.6.7-1.el7.x86_64 (from Centos7)
- 1.1.0 uses mosquitto-1.5.8-1.el7.x86_64 (from Centos7)
- 1.0.0 uses mosquitto-1.4.8-1.el7.x86_64 (from Centos7)

- 2.1.0 uses mosquitto-2.0.11 from Debian 12
- 2.0.0 uses mosquitto-2.0.11 from Debian 11
- 1.6.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
- 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64 (from Centos7)
- 1.2.0 uses mosquitto-1.6.7-1.el7.x86_64 (from Centos7)
- 1.1.0 uses mosquitto-1.5.8-1.el7.x86_64 (from Centos7)
- 1.0.0 uses mosquitto-1.4.8-1.el7.x86_64 (from Centos7)
2 changes: 2 additions & 0 deletions lib/fiware-iotagent-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ exports.setCommandHandler = contextServer.setCommandHandler;
exports.setMergePatchHandler = contextServer.setMergePatchHandler;
exports.setDataQueryHandler = contextServer.setQueryHandler;
exports.setConfigurationHandler = contextServer.setConfigurationHandler;
exports.setGroupConfigurationHandler = contextServer.setGroupConfigurationHandler;
exports.setRemoveConfigurationHandler = contextServer.setRemoveConfigurationHandler;
exports.setRemoveGroupConfigurationHandler = contextServer.setRemoveGroupConfigurationHandler;
exports.setProvisioningHandler = contextServer.setProvisioningHandler;
exports.setUpdatingHandler = contextServer.setUpdatingHandler;
exports.setRemoveDeviceHandler = contextServer.setRemoveDeviceHandler;
Expand Down
2 changes: 1 addition & 1 deletion lib/services/common/iotManagerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function register(callback) {
}

function getServices(callback) {
config.getGroupRegistry().list(null, null, null, function (error, results) {
config.getGroupRegistry().list(null, null, null, null, function (error, results) {
if (error) {
callback(error);
} else {
Expand Down
35 changes: 24 additions & 11 deletions lib/services/groups/groupRegistryMemory.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function getConfigurationsByService(service) {
* @param {Number} limit Maximum number of entries to return.
* @param {Number} offset Number of entries to skip for pagination.
*/
function listGroups(service, limit, offset, callback) {
function listGroups(endpoint, service, limit, offset, callback) {
const result = [];
let skipped = 0;
const filteredGroups = getConfigurationsByService(service);
Expand All @@ -113,11 +113,17 @@ function listGroups(service, limit, offset, callback) {
}
}
}

callback(null, {
count: filteredGroups.length,
services: result
});
if (endpoint != null && endpoint.includes('configgroups')) {
callback(null, {
count: filteredGroups.length,
configGroups: result
});
} else {
callback(null, {
count: filteredGroups.length,
services: result
});
}
}

function init(newConfig, callback) {
Expand All @@ -130,7 +136,7 @@ function clear(callback) {
callback();
}

function find(service, subservice, callback) {
function find(endpoint, service, subservice, callback) {
const result = [];

for (const i in registeredGroups) {
Expand All @@ -145,10 +151,17 @@ function find(service, subservice, callback) {

if (result.length > 0) {
logger.debug(context, 'groups found %j', result);
return callback(null, {
count: result.length,
services: result
});
if (endpoint.includes('configgroups')) {
return callback(null, {
count: result.length,
configGroups: result
});
} else {
return callback(null, {
count: result.length,
services: result
});
}
} else {
return callback(new errors.DeviceGroupNotFound(service, subservice));
}
Expand Down
34 changes: 24 additions & 10 deletions lib/services/groups/groupRegistryMongoDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function createGroup(group, callback) {
* @param {Number} limit Maximum number of entries to return.
* @param {Number} offset Number of entries to skip for pagination.
*/
function listGroups(service, limit, offset, callback) {
function listGroups(endpoint, service, limit, offset, callback) {
const condition = {};

function toObjectFn(obj) {
Expand All @@ -153,10 +153,17 @@ function listGroups(service, limit, offset, callback) {
async.series(
[query.exec.bind(query), Group.model.countDocuments.bind(Group.model, condition)],
function (error, results) {
callback(error, {
count: results[1],
services: results[0].map(toObjectFn)
});
if (endpoint.includes('configgroups')) {
callback(error, {
count: results[1],
configGroups: results[0].map(toObjectFn)
});
} else {
callback(error, {
count: results[1],
services: results[0].map(toObjectFn)
});
}
}
);
}
Expand Down Expand Up @@ -192,7 +199,7 @@ function getById(id, callback) {
* @param {String} subservice Subservice used to filter the groups.
* @param {Function} callback The callback function.
*/
function find(service, subservice, callback) {
function find(endpoint, service, subservice, callback) {
const condition = {};

function toObjectFn(obj) {
Expand All @@ -207,10 +214,17 @@ function find(service, subservice, callback) {
async.series(
[query.exec.bind(query), Group.model.countDocuments.bind(Group.model, condition)],
function (error, results) {
callback(error, {
count: results[1],
services: results[0].map(toObjectFn)
});
if (endpoint.includes('configgroups')) {
callback(error, {
count: results[1],
configGroups: results[0].map(toObjectFn)
});
} else {
callback(error, {
count: results[1],
services: results[0].map(toObjectFn)
});
}
}
);
}
Expand Down
Loading
Loading