147 lines
7.1 KiB
Markdown
147 lines
7.1 KiB
Markdown
# Mainflux Things and Channels Provisioning Tool
|
|
|
|
A simple utility to create a list of channels and things connected to these channels with possibility to create certificates for mTLS use case.
|
|
|
|
This tool is useful for testing, and it creates a TOML format output (on stdout, can be redirected into the file as needed)
|
|
that can be used by Mainflux MQTT benchmarking tool (`mqtt-bench`).
|
|
|
|
## Installation
|
|
```
|
|
cd tools/provision
|
|
make
|
|
```
|
|
|
|
### Usage
|
|
```
|
|
./provision --help
|
|
Tool for provisioning series of Mainflux channels and things and connecting them together.
|
|
Complete documentation is available at https://docs.mainflux.io
|
|
|
|
Usage:
|
|
provision [flags]
|
|
|
|
Flags:
|
|
--ca string CA for creating and signing things certificate (default "ca.crt")
|
|
--cakey string ca.key for creating and signing things certificate (default "ca.key")
|
|
-h, --help help for provision
|
|
--host string address for mainflux instance (default "https://localhost")
|
|
--num int number of channels and things to create and connect (default 10)
|
|
-p, --password string mainflux users password
|
|
--ssl create certificates for mTLS access
|
|
-u, --username string mainflux user
|
|
--prefix string name prefix for things and channels
|
|
```
|
|
|
|
Example:
|
|
```
|
|
go run tools/provision/cmd/main.go -u test@mainflux.com -p test1234 --host https://142.93.118.47
|
|
```
|
|
|
|
If you want to create a list of channels with certificates:
|
|
|
|
```
|
|
go run tools/provision/cmd/main.go --host http://localhost --num 10 -u test@mainflux.com -p test1234 --ssl true --ca docker/ssl/certs/ca.crt --cakey docker/ssl/certs/ca.key
|
|
|
|
```
|
|
|
|
>`ca.crt` and `ca.key` are used for creating things certificate and for HTTPS,
|
|
> if you are provisioning on remote server you will have to get these files to your local
|
|
> directory so that you can create certificates for things
|
|
|
|
|
|
Example of output:
|
|
|
|
```
|
|
# List of things that can be connected to MQTT broker
|
|
[[things]]
|
|
thing_id = "0eac601b-6d54-4767-b8b7-594aaf9990d3"
|
|
thing_key = "07713103-513f-43c7-b7fe-500c1af23d7d"
|
|
mtls_cert = """-----BEGIN CERTIFICATE-----
|
|
MIIEmTCCA4GgA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ob429u/Txk1XtfXg8DSQOqSEHe6h1ySfZPbTb87A56kBiwG8i5JCaQeX
|
|
RYX01UGsOl2Cxa3vcUAB/hE+SALCIQwvmzNzDJA2a7hEdbdUqDpjzUiqaGViinZZ
|
|
A/nHwQKCAQAkTxLCT7ghIWLaw5Zn7DsDCAXZ7DqVDs5DqbyPSaNjqApe5AW+byKK
|
|
HYvrYrtWqoYQUaFp43+ZjTXYG43vUAxrSAObmieimcFgZfjUK/EIV/Dpito0dY6J
|
|
H92JuKu1RJduQXCx40ulod2OyVkb7Vt2dPnK0xHG4V3TEI/1bCk7xFN6qwuk/oe1
|
|
jusglZfMcbWiBa4VyZsViqc22chJ6KkzqViFbR4MCzmwvpwmOC42zItWpGyMghqv
|
|
WJ6xNkUyb56HpK2ly2ftZMS8VA5sgx8y6zck9vC1GdGT3mNeX/50Q+WvnWuGhSbx
|
|
kOVd/a0qsAcMw7A9nApz6Mk0rSk0MnFhAoIBAQCI6dU5c1sTp/LNp+z6yQmcJD3Z
|
|
HNYdVhf8pxHpRWZ8r5otFwi1lr5vk15Zh59B5nMLQHP3UWJ7R66HUjXCtFe86ojV
|
|
xngL3lXJNtLcCWXQHM/nkWZ1TVCeZ6mS8aJndcy4sY0lPUqRtYaXSV/EyzpQJUmf
|
|
xcEeQuOhBZ4s8uSyuLgEPYbeYyi7Vpujm7UpplTN55dIZrQ7tMefRNgHjybFfC8P
|
|
QsxPR4lWoFpr9xFvtBORlP+In8LjD3Z2EDm2guIRAWebEJGsY7ftAv7CEFrLOJd5
|
|
uCRt+TFMyEfqilipmNsV7esgbroiyEGXGMI8JdBY9OsnK6ZSlXaMnQ9vq2kK
|
|
-----END RSA PRIVATE KEY-----
|
|
"""
|
|
|
|
# List of channels that things can publish to
|
|
# each channel is connected to each thing from things list
|
|
# Things connected to channel 1f18afa1-29c4-4634-99d1-68dfa1b74e6a: 0eac601b-6d54-4767-b8b7-594aaf9990d3
|
|
[[channels]]
|
|
channel_id = "1f18afa1-29c4-4634-99d1-68dfa1b74e6a"
|
|
|
|
```
|