Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file has been changed in the PR?

In addition, looking to telefonicaid/iotagent-json#527 I don't see similar changes

'on':
"on":
push:
branches:
- master
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
npm run lint:md
- name: Run Textlint Markdown Linter
run: npm run lint:text

lint-code:
name: Lint JavaScript
runs-on: ubuntu-latest
Expand All @@ -58,15 +58,15 @@ jobs:
mongodb:
image: mongo:4.2
ports:
- 27017:27017
- 27017:27017
mosquitto:
image: eclipse-mosquitto:1.6.7
ports:
- 1883:1883
- 1883:1883
rabbitmq:
image: rabbitmq:3.8.9
ports:
- 5672:5672
- 5672:5672
strategy:
matrix:
node-version:
Expand All @@ -77,11 +77,11 @@ jobs:
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: 'Install Node.js ${{ matrix.node-version }}'
- name: "Install Node.js ${{ matrix.node-version }}"
uses: actions/setup-node@v1
with:
node-version: '${{ matrix.node-version }}'
- name: 'Unit Tests with Node.js ${{ matrix.node-version }}'
node-version: "${{ matrix.node-version }}"
- name: "Unit Tests with Node.js ${{ matrix.node-version }}"
run: |
npm install
npm test
Expand All @@ -94,19 +94,19 @@ jobs:
mongodb:
image: mongo:4.2
ports:
- 27017:27017
- 27017:27017
mosquitto:
image: eclipse-mosquitto:1.6.7
ports:
- 1883:1883
- 1883:1883
rabbitmq:
image: rabbitmq:3.8.9
ports:
- 5672:5672
- 5672:5672
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: 'Test Coverage with Node.js 12.x'
- name: "Test Coverage with Node.js 12.x"
uses: actions/setup-node@v1
with:
node-version: 12.x
Expand Down
2 changes: 2 additions & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

- Fix: avoid raise mongo alarm when a measure is not maching a group configuration
- Upgrade NodeJS version from 10 to 12 in Dockerfile due to Node 10 End-of-Life
- Set Nodejs 12 as minimum version in packages.json (effectively removing Nodev10 from supported versions)
- Add list of environment variables which can be protected by Docker Secrets
- Add: virtual host configuration added to AMQP transport (config.amqp.vhost and IOTA_AMQP_VHOST env var)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The latest IoT Agent for Ultralight documentation is also available on

## Contributing

If you'd like to contribute, start by searching through the issues and pull requests to see whether someone else has
If you'd like to contribute, start by searching through the issues and pull requests to see whether someone else has
raised a similar idea or question.

Before contributing, please check out [contribution guidelines](docs/contribution.md)
Expand Down Expand Up @@ -106,7 +106,7 @@ docker pull rabbitmq

docker run -d -p 1883:1883 -l mosquitto ansi/mosquitto
docker run -d -p 27017:27017 -l mongodb mongo
docker run -d -p 5672:5672 -l rabbitmq rabbitmq
docker run -d -p 5672:5672 -l -v $(pwd)/docs/rabbitmq-config.json:/etc/rabbitmq/definition.json -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_management load_definitions '/etc/rabbitmq/definition.json'" rabbitmq:management
```

The required libraries, if missing, can be installed with:
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ config.mqtt = {
config.amqp = {
host: 'localhost',
port: 5672,
// vhost: "custom-virtual-host",
// username: 'guest',
// password: 'guest',
exchange: 'iota-exchange',
Expand Down
54 changes: 32 additions & 22 deletions docs/contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

Before we get started, here are a few things we expect from you (and that you should expect from others):

* Be kind and thoughtful in your conversations around this project. We all come from different backgrounds and
- Be kind and thoughtful in your conversations around this project. We all come from different backgrounds and
projects, which means we likely have different perspectives on "how open source is done." Try to listen to others
rather than convince them that your way is correct.
* Please ensure that your contribution passes all tests. If there are test failures, you will need to address them
- Please ensure that your contribution passes all tests. If there are test failures, you will need to address them
before we can merge your contribution.
* When adding content, please consider if it is widely valuable. Please don't add references or links to things you or
- When adding content, please consider if it is widely valuable. Please don't add references or links to things you or
your employer have created as others will do so if they appreciate it.
* When reporting a vulnerability on the software, please, put in contact with IoT Agent Node Lib repository maintainers in order to discuss it
in a private way.
- When reporting a vulnerability on the software, please, put in contact with IoT Agent Node Lib repository
maintainers in order to discuss it in a private way.

## How to contribute

If you'd like to contribute, start by searching through the [issues](https://github.com/telefonicaid/iotagent-ul/issues) and
[pull requests](https://github.com/telefonicaid/iotagent-ul/pulls) to see whether someone else has raised a similar idea or
question. In adition, you can also check in the IoTAgent Node Lib framework repository for [issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and [pull requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) across all the IoT-Agents
If you'd like to contribute, start by searching through the [issues](https://github.com/telefonicaid/iotagent-ul/issues)
and [pull requests](https://github.com/telefonicaid/iotagent-ul/pulls) to see whether someone else has raised a similar
idea or question. In adition, you can also check in the IoTAgent Node Lib framework repository for
[issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
[pull requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) across all the IoT-Agents

If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following:

Expand All @@ -28,18 +30,22 @@ If you don't see your idea listed, and you think it fits into the goals of this

### Pull Request protocol

As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest/))
As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest/))
contributions are done using a pull request (PR). The detailed "protocol" used in such PR is described below:

- Direct commits to master branch (even single-line modifications) are not allowed. Every modification has to come as a PR
- In case the PR is implementing/fixing a numbered issue, the issue number has to be referenced in the body of the PR at creation time
- Anybody is welcome to provide comments to the PR (either direct comments or using the review feature offered by Github)
- Use *code line comments* instead of *general comments*, for traceability reasons (see comments lifecycle below)
- Direct commits to master branch (even single-line modifications) are not allowed. Every modification has to come as
a PR
- In case the PR is implementing/fixing a numbered issue, the issue number has to be referenced in the body of the PR
at creation time
- Anybody is welcome to provide comments to the PR (either direct comments or using the review feature offered by
Github)
- Use _code line comments_ instead of _general comments_, for traceability reasons (see comments lifecycle below)
- Comments lifecycle
- Comment is created, initiating a *comment thread*
- Comment is created, initiating a _comment thread_
- New comments can be added as responses to the original one, starting a discussion
- After discussion, the comment thread ends in one of the following ways:
- `Fixed in <commit hash>` in case the discussion involves a fix in the PR branch (which commit hash is included as reference)
- `Fixed in <commit hash>` in case the discussion involves a fix in the PR branch (which commit hash is
included as reference)
- `NTC`, if finally nothing needs to be done (NTC = Nothing To Change)
- PR can be merged when the following conditions are met:
- All comment threads are closed
Expand All @@ -48,15 +54,19 @@ contributions are done using a pull request (PR). The detailed "protocol" used i

Some additional remarks to take into account when contributing with new PRs:

* PR must include not only code contributions, but their corresponding pieces of documentation (new or modifications to existing one) and tests
* PR modifications must pass full regression based on existing test (unit, functional, memory, e2e) in addition to whichever new test added due to the new functionality
* PR should be of an appropriated size that makes review achievable. Too large PRs could be closed with a "please, redo the work in smaller pieces" without any further discussing
- PR must include not only code contributions, but their corresponding pieces of documentation (new or modifications
to existing one) and tests
- PR modifications must pass full regression based on existing test (unit, functional, memory, e2e) in addition to
whichever new test added due to the new functionality
- PR should be of an appropriated size that makes review achievable. Too large PRs could be closed with a "please,
redo the work in smaller pieces" without any further discussing

## Community

Discussions about the Open Source Guides take place on this repository's
[Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and [Pull Requests](https://github.com/telefonicaid/iotagent-node-lib/pulls)
sections. Anybody is welcome to join these conversations.
[Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
[Pull Requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) sections. Anybody is welcome to join these
conversations.

Wherever possible, do not take these conversations to private channels, including contacting the maintainers directly.

Expand All @@ -78,8 +88,8 @@ In order to start contributing:
git clone https://github.com/your-github-username/iotagent-ul.git
```

3. Add the main iotagent-ul repository as a remote to your forked repository (use any name for your remote
repository, it does not have to be iotagent-ul, although we will use it in the next steps):
3. Add the main iotagent-ul repository as a remote to your forked repository (use any name for your remote repository,
it does not have to be iotagent-ul, although we will use it in the next steps):

```bash
git remote add iotagent-ul https://github.com/telefonicaid/iotagent-ul.git
Expand Down
14 changes: 7 additions & 7 deletions docs/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ the case you want to use old versions:

The following table provides information about the last iotagent-ul version supporting currently removed features:

| **Removed feature** | **Last iotagent-ul version supporting feature** | **That version release date** |
| ---------------------- | ------------------------------------------------- | ----------------------------- |
| NGSIv1 API | Not yet defined | Not yet defined |
| Support to Node.js v4 | 1.8.0 | December 19th, 2018 |
| Support to Node.js v6 | 1.9.0 | May 22nd, 2019 |
| Support to Node.js v8 | 1.13.0 | April 7th, 2020 |
| Support to Node.js v10 | 1.16.0 | February 18th, 2021 |
| **Removed feature** | **Last iotagent-ul version supporting feature** | **That version release date** |
| ---------------------- | ----------------------------------------------- | ----------------------------- |
| NGSIv1 API | Not yet defined | Not yet defined |
| Support to Node.js v4 | 1.8.0 | December 19th, 2018 |
| Support to Node.js v6 | 1.9.0 | May 22nd, 2019 |
| Support to Node.js v8 | 1.13.0 | April 7th, 2020 |
| Support to Node.js v10 | 1.16.0 | February 18th, 2021 |
2 changes: 2 additions & 0 deletions docs/installationguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ IoT Agent. The following attributes are accepted:
default is `mqtt`
- **host**: Host where the MQTT Broker is located.
- **port**: Port where the MQTT Broker is listening
- **vhost**: virtual host in the AMQP Broker to which IoT Agent will connect (optional).
- **username**: Username for the IoT Agent in the MQTT broker, if authentication is activated.
- **password**: Password for the IoT Agent in the MQTT broker, if authentication is activated.
- **ca**: ca certificates to use for validating server certificates (optional). Default is to trust the well-known CAs
Expand Down Expand Up @@ -253,6 +254,7 @@ The ones relating specific Ultralight 2.0 bindings are described in the followin
| IOTA_MQTT_AVOID_LEADING_SLASH | mqtt.avoidLeadingSlash |
| IOTA_AMQP_HOST | amqp.host |
| IOTA_AMQP_PORT | amqp.port |
| IOTA_AMQP_VHOST | amqp.vhost |
| IOTA_AMQP_USERNAME | amqp.username |
| IOTA_AMQP_PASSWORD | amqp.password |
| IOTA_AMQP_EXCHANGE | amqp.exchange |
Expand Down
26 changes: 26 additions & 0 deletions docs/rabbitmq-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"vhosts": [
{
"name": "/"
},
{
"name": "foo/bar"
}
],
"permissions": [
{
"user": "guest",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
},
{
"user": "guest",
"vhost": "foo/bar",
"configure": ".*",
"write": ".*",
"read": ".*"
}
]
}
68 changes: 34 additions & 34 deletions lib/bindings/AMQPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function generateCommandExecution(apiKey, device, attribute) {
function commandHandler(device, attributes, callback) {
config.getLogger().debug(context, 'Handling AMQP command for device [%s]', device.id);

utils.getEffectiveApiKey(device.service, device.subservice, device, function(error, apiKey) {
utils.getEffectiveApiKey(device.service, device.subservice, device, function (error, apiKey) {
async.series(attributes.map(generateCommandExecution.bind(null, apiKey, device)), callback);
});
}
Expand Down Expand Up @@ -151,6 +151,9 @@ function start(callback) {
uri += ':' + config.getConfig().amqp.port;
}
}
if (config.getConfig().amqp.vhost && config.getConfig().amqp.vhost !== '/') {
uri += '/' + config.getConfig().amqp.vhost;
}
} else {
return config.getLogger().error(context, 'Error AMQP is not configured');
}
Expand All @@ -165,46 +168,43 @@ function start(callback) {
return;
}
isConnecting = true;
amqp.connect(
uri,
function(err, conn) {
isConnecting = false;
// try again
if (err) {
config.getLogger().error(context, err.message);
if (numRetried <= retries) {
numRetried++;
return setTimeout(createConnection, retryTime * 1000, callback);
amqp.connect(uri, function (err, conn) {
isConnecting = false;
// try again
if (err) {
config.getLogger().error(context, err.message);
if (numRetried <= retries) {
numRetried++;
return setTimeout(createConnection, retryTime * 1000, callback);
}
} else {
conn.on('error', function (err) {
if (err.message !== 'Connection closing') {
config.getLogger().error(context, err.message);
}
} else {
conn.on('error', function(err) {
if (err.message !== 'Connection closing') {
config.getLogger().error(context, err.message);
});
conn.on('close', function () {
// If amqpConn is null, the connection has been closed on purpose
if (amqpConn) {
config.getLogger().error(context, 'reconnecting');
if (numRetried <= retries) {
numRetried++;
return setTimeout(createConnection, retryTime * 1000);
}
});
conn.on('close', function() {
// If amqpConn is null, the connection has been closed on purpose
if (amqpConn) {
config.getLogger().error(context, 'reconnecting');
if (numRetried <= retries) {
numRetried++;
return setTimeout(createConnection, retryTime * 1000);
}
}
});
config.getLogger().info(context, 'connected');
amqpConn = conn;
if (callback) {
callback();
}
});
config.getLogger().info(context, 'connected');
amqpConn = conn;
if (callback) {
callback();
}
}
);
});
}

function createChannel(callback) {
config.getLogger().debug(context, 'channel creating');
amqpConn.createChannel(function(err, ch) {
amqpConn.createChannel(function (err, ch) {
if (err) {
config.getLogger().error(context, err.message);
}
Expand All @@ -225,7 +225,7 @@ function start(callback) {

function assertQueue(callback) {
config.getLogger().debug(context, 'asserting queues');
amqpChannel.assertQueue(queue, { exclusive: false }, function() {
amqpChannel.assertQueue(queue, { exclusive: false }, function () {
amqpChannel.assertQueue(queue + '_commands', { exclusive: false }, callback);
});
}
Expand All @@ -242,7 +242,7 @@ function start(callback) {
callback();
}

async.waterfall([createConnection, createChannel, assertExchange, assertQueue, createListener], function(error) {
async.waterfall([createConnection, createChannel, assertExchange, assertQueue, createListener], function (error) {
if (error) {
config.getLogger().debug('AMQP error %j', error);
}
Expand Down
Loading