Skip to content

Commit c8b509f

Browse files
authored
NOISSUE - Update to Magistrala (#1)
* update mainflux to magistrala Signed-off-by: ianmuchyri <[email protected]> * update license to abstract machines Signed-off-by: ianmuchyri <[email protected]> * update Makefile and README.md Signed-off-by: ianmuchyri <[email protected]> --------- Signed-off-by: ianmuchyri <[email protected]>
1 parent a6e6d4f commit c8b509f

File tree

794 files changed

+50109
-81200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

794 files changed

+50109
-81200
lines changed

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) Mainflux
1+
# Copyright (c) Abstract Machines
22
# SPDX-License-Identifier: Apache-2.0
33

44
BUILD_DIR ?= build
@@ -11,19 +11,19 @@ VERSION ?= $(shell git describe --abbrev=0 --tags)
1111
COMMIT ?= $(shell git rev-parse HEAD)
1212
TIME ?= $(shell date +%F_%T)
1313

14-
ifneq ($(MF_BROKER_TYPE),)
15-
MF_BROKER_TYPE := $(MF_BROKER_TYPE)
14+
ifneq ($(MG_BROKER_TYPE),)
15+
MG_BROKER_TYPE := $(MG_BROKER_TYPE)
1616
else
17-
MF_BROKER_TYPE=nats
17+
MG_BROKER_TYPE=nats
1818
endif
1919

2020
define compile_service
2121
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
22-
go build -mod=vendor -tags $(MF_BROKER_TYPE) -ldflags "-s -w \
23-
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
24-
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
25-
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
26-
-o ${BUILD_DIR}/mainflux-$(1) cmd/main.go
22+
go build -mod=vendor -tags $(MG_BROKER_TYPE) -ldflags "-s -w \
23+
-X 'github.com/absmach/agent.BuildTime=$(TIME)' \
24+
-X 'github.com/absmach/agent.Version=$(VERSION)' \
25+
-X 'github.com/absmach/agent.Commit=$(COMMIT)'" \
26+
-o ${BUILD_DIR}/magistrala-$(1) cmd/main.go
2727
endef
2828

2929
define make_docker
@@ -37,7 +37,7 @@ define make_docker
3737
--build-arg VERSION=$(VERSION) \
3838
--build-arg COMMIT=$(COMMIT) \
3939
--build-arg TIME=$(TIME) \
40-
--tag=mainflux/$(svc) \
40+
--tag=magistrala/$(svc) \
4141
-f docker/Dockerfile .
4242
endef
4343

@@ -47,7 +47,7 @@ define make_docker_dev
4747
docker build \
4848
--no-cache \
4949
--build-arg SVC=$(svc) \
50-
--tag=mainflux/$(svc) \
50+
--tag=magistrala/$(svc) \
5151
-f docker/Dockerfile.dev ./build
5252
endef
5353

@@ -82,7 +82,7 @@ dockers_dev: $(DOCKERS_DEV)
8282

8383
define docker_push
8484
for svc in $(SERVICES); do \
85-
docker push mainflux/$$svc:$(1); \
85+
docker push magistrala/$$svc:$(1); \
8686
done
8787
endef
8888

@@ -97,7 +97,7 @@ release:
9797
git checkout $(version)
9898
$(MAKE) dockers
9999
for svc in $(SERVICES); do \
100-
docker tag mainflux/$$svc mainflux/$$svc:$(version); \
100+
docker tag magistrala/$$svc magistrala/$$svc:$(version); \
101101
done
102102
$(call docker_push,$(version))
103103

README.md

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Mainflux IoT Agent
1+
# Magistrala IoT Agent
22

3-
![badge](https://github.com/mainflux/agent/workflows/Go/badge.svg)
3+
![badge](https://github.com/absmach/agent/workflows/Go/badge.svg)
44
![ci][ci]
55
![release][release]
66
[![go report card][grc-badge]][grc-url]
@@ -11,15 +11,15 @@
1111
<img width="30%" height="30%" src="./docs/img/agent.png">
1212
</p>
1313

14-
Mainflux IoT Agent is a communication, execution and SW management agent for Mainflux system.
14+
Magistrala IoT Agent is a communication, execution and SW management agent for Magistrala system.
1515

1616
## Install
1717

1818
Get the code:
1919

2020
```bash
21-
go get github.com/mainflux/agent
22-
cd $GOPATH/github.com/mainflux/agent
21+
go get github.com/absmach/agent
22+
cd $GOPATH/github.com/absmach/agent
2323
```
2424

2525
Make:
@@ -37,24 +37,24 @@ go install github.com/nats-io/nats-server/v2@latest
3737
nats-server
3838
```
3939

40-
Create gateway configuration with [Provision][provision] service or through [Mainflux UI][mfxui].
40+
Create gateway configuration with [Provision][provision] service or through [Mainflux UI][mfxui].
4141

4242
Start Agent with:
4343

4444
```bash
45-
MF_AGENT_BOOTSTRAP_ID=<bootstrap_id> \
46-
MF_AGENT_BOOTSTRAP_KEY=<bootstrap_key> \
47-
MF_AGENT_BOOTSTRAP_URL=http://localhost:9013/things/bootstrap \
48-
build/mainflux-agent
45+
MG_AGENT_BOOTSTRAP_ID=<bootstrap_id> \
46+
MG_AGENT_BOOTSTRAP_KEY=<bootstrap_key> \
47+
MG_AGENT_BOOTSTRAP_URL=http://localhost:9013/things/bootstrap \
48+
build/magistrala-agent
4949
```
5050

51-
or,if [Mainflux UI](https://github.com/mainflux/ui) is used,
51+
or,if [Magistrala UI](https://github.com/absmach/ui) is used,
5252

5353
```bash
54-
MF_AGENT_BOOTSTRAP_ID=<bootstrap_id> \
55-
MF_AGENT_BOOTSTRAP_KEY=<bootstrap_key> \
56-
MF_AGENT_BOOTSTRAP_URL=http://localhost:9013/bootstrap/things/bootstrap \
57-
build/mainflux-agent
54+
MG_AGENT_BOOTSTRAP_ID=<bootstrap_id> \
55+
MG_AGENT_BOOTSTRAP_KEY=<bootstrap_key> \
56+
MG_AGENT_BOOTSTRAP_URL=http://localhost:9013/bootstrap/things/bootstrap \
57+
build/magistrala-agent
5858
```
5959

6060
### Config
@@ -95,48 +95,48 @@ Example configuration:
9595
```
9696

9797
Environment:
98-
| Variable | Description | Default |
98+
| Variable | Description | Default |
9999
|----------------------------------------|---------------------------------------------------------------|----------------------------------------|
100-
| MF_AGENT_CONFIG_FILE | Location of configuration file | config.toml |
101-
| MF_AGENT_LOG_LEVEL | Log level | info |
102-
| MF_AGENT_EDGEX_URL | Edgex base url | http://localhost:48090/api/v1/ |
103-
| MF_AGENT_MQTT_URL | MQTT broker url | localhost:1883 |
104-
| MF_AGENT_HTTP_PORT | Agent http port | 9999 |
105-
| MF_AGENT_BOOTSTRAP_URL | Mainflux bootstrap url | http://localhost:9013/things/bootstrap |
106-
| MF_AGENT_BOOTSTRAP_ID | Mainflux bootstrap id | |
107-
| MF_AGENT_BOOTSTRAP_KEY | Mainflux bootstrap key | |
108-
| MF_AGENT_BOOTSTRAP_RETRIES | Number of retries for bootstrap procedure | 5 |
109-
| MF_AGENT_BOOTSTRAP_SKIP_TLS | Skip TLS verification for bootstrap | true |
110-
| MF_AGENT_BOOTSTRAP_RETRY_DELAY_SECONDS | Number of seconds between retries | 10 |
111-
| MF_AGENT_CONTROL_CHANNEL | Channel for sending controls, commands | |
112-
| MF_AGENT_DATA_CHANNEL | Channel for data sending | |
113-
| MF_AGENT_ENCRYPTION | Encryption | false |
114-
| MF_AGENT_BROKER_URL | Broker url | nats://localhost:4222 |
115-
| MF_AGENT_MQTT_USERNAME | MQTT username, Mainflux thing id | |
116-
| MF_AGENT_MQTT_PASSWORD | MQTT password, Mainflux thing key | |
117-
| MF_AGENT_MQTT_SKIP_TLS | Skip TLS verification for MQTT | true |
118-
| MF_AGENT_MQTT_MTLS | Use MTLS for MQTT | false |
119-
| MF_AGENT_MQTT_CA | Location for CA certificate for MTLS | ca.crt |
120-
| MF_AGENT_MQTT_QOS | QoS | 0 |
121-
| MF_AGENT_MQTT_RETAIN | MQTT retain | false |
122-
| MF_AGENT_MQTT_CLIENT_CERT | Location of client certificate for MTLS | thing.cert |
123-
| MF_AGENT_MQTT_CLIENT_PK | Location of client certificate key for MTLS | thing.key |
124-
| MF_AGENT_HEARTBEAT_INTERVAL | Interval in which heartbeat from service is expected | 30s |
125-
| MF_AGENT_TERMINAL_SESSION_TIMEOUT | Timeout for terminal session | 30s |
126-
127-
Here `thing` is a Mainflux thing, and control channel from `channels` is used with `req` and `res` subtopic
100+
| MG_AGENT_CONFIG_FILE | Location of configuration file | config.toml |
101+
| MG_AGENT_LOG_LEVEL | Log level | info |
102+
| MG_AGENT_EDGEX_URL | Edgex base url | http://localhost:48090/api/v1/ |
103+
| MG_AGENT_MQTT_URL | MQTT broker url | localhost:1883 |
104+
| MG_AGENT_HTTP_PORT | Agent http port | 9999 |
105+
| MG_AGENT_BOOTSTRAP_URL | Magistrala bootstrap url | http://localhost:9013/things/bootstrap |
106+
| MG_AGENT_BOOTSTRAP_ID | Magistrala bootstrap id | |
107+
| MG_AGENT_BOOTSTRAP_KEY | Magistrala bootstrap key | |
108+
| MG_AGENT_BOOTSTRAP_RETRIES | Number of retries for bootstrap procedure | 5 |
109+
| MG_AGENT_BOOTSTRAP_SKIP_TLS | Skip TLS verification for bootstrap | true |
110+
| MG_AGENT_BOOTSTRAP_RETRY_DELAY_SECONDS | Number of seconds between retries | 10 |
111+
| MG_AGENT_CONTROL_CHANNEL | Channel for sending controls, commands | |
112+
| MG_AGENT_DATA_CHANNEL | Channel for data sending | |
113+
| MG_AGENT_ENCRYPTION | Encryption | false |
114+
| MG_AGENT_BROKER_URL | Broker url | nats://localhost:4222 |
115+
| MG_AGENT_MQTT_USERNAME | MQTT username, Magistrala thing id | |
116+
| MG_AGENT_MQTT_PASSWORD | MQTT password, Magistrala thing key | |
117+
| MG_AGENT_MQTT_SKIP_TLS | Skip TLS verification for MQTT | true |
118+
| MG_AGENT_MQTT_MTLS | Use MTLS for MQTT | false |
119+
| MG_AGENT_MQTT_CA | Location for CA certificate for MTLS | ca.crt |
120+
| MG_AGENT_MQTT_QOS | QoS | 0 |
121+
| MG_AGENT_MQTT_RETAIN | MQTT retain | false |
122+
| MG_AGENT_MQTT_CLIENT_CERT | Location of client certificate for MTLS | thing.cert |
123+
| MG_AGENT_MQTT_CLIENT_PK | Location of client certificate key for MTLS | thing.key |
124+
| MG_AGENT_HEARTBEAT_INTERVAL | Interval in which heartbeat from service is expected | 30s |
125+
| MG_AGENT_TERMINAL_SESSION_TIMEOUT | Timeout for terminal session | 30s |
126+
127+
Here `thing` is a Magistrala thing, and control channel from `channels` is used with `req` and `res` subtopic
128128
(i.e. app needs to PUB/SUB on `/channels/<control_channel_id>/messages/req` and `/channels/<control_channel_id>/messages/res`).
129129

130130
## Sending commands to other services
131131

132132
You can send commands to other services that are subscribed on the same Broker as Agent.
133133
Commands are being sent via MQTT to topic:
134134

135-
* `channels/<control_channel_id>/messages/services/<service_name>/<subtopic>`
135+
- `channels/<control_channel_id>/messages/services/<service_name>/<subtopic>`
136136

137137
when messages is received Agent forwards them to Broker on subject:
138138

139-
* `commands.<service_name>.<subtopic>`.
139+
- `commands.<service_name>.<subtopic>`.
140140

141141
Payload is up to the application and service itself.
142142

@@ -191,13 +191,13 @@ Or you can send a command via MQTT to Agent and receive response on MQTT topic l
191191
In one terminal subscribe for result:
192192

193193
```bash
194-
mosquitto_sub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/messages/req -h <mqtt_host> -p 1883
194+
mosquitto_sub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/messages/req -h <mqtt_host> -p 1883
195195
```
196196

197197
In another terminal publish request to view the list of services:
198198

199199
```bash
200-
mosquitto_pub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/messages/req -h <mqtt_host> -p 1883 -m '[{"bn":"1:", "n":"config", "vs":"view"}]'
200+
mosquitto_pub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/messages/req -h <mqtt_host> -p 1883 -m '[{"bn":"1:", "n":"config", "vs":"view"}]'
201201
```
202202

203203
Check the output in terminal where you subscribed for results. You should see something like:
@@ -213,7 +213,6 @@ Check the output in terminal where you subscribed for results. You should see so
213213
]
214214
```
215215

216-
217216
## How to save config via agent
218217

219218
Agent can be used to send configuration file for the [Export][export] service from cloud to gateway via MQTT.
@@ -224,8 +223,8 @@ mosquitto_pub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/mess
224223

225224
```
226225

227-
* `<config_file_path>` - file path where to save contents
228-
* `<file_content_base64>` - file content, base64 encoded marshaled toml.
226+
- `<config_file_path>` - file path where to save contents
227+
- `<file_content_base64>` - file content, base64 encoded marshaled toml.
229228

230229
Here is an example how to make payload for the command:
231230

@@ -244,15 +243,14 @@ RmlsZSA9ICIuLi9jb25maWdzL2NvbmZpZy50b21sIgoKW2V4cF0KICBsb2dfbGV2ZWwgPSAiZGVidWci
244243

245244
[Apache-2.0](LICENSE)
246245

247-
[grc-badge]: https://goreportcard.com/badge/github.com/mainflux/agent
248-
[grc-url]: https://goreportcard.com/report/github.com/mainflux/agent
246+
[grc-badge]: https://goreportcard.com/badge/github.com/absmach/agent
247+
[grc-url]: https://goreportcard.com/report/github.com/absmach/agent
249248
[docs]: http://mainflux.readthedocs.io
250249
[gitter]: https://gitter.im/mainflux/mainflux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
251250
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
252251
[license]: https://img.shields.io/badge/license-Apache%20v2.0-blue.svg
253-
254252
[export]: https://github.com/mainflux/export
255253
[provision]: https://github.com/mainflux/mainflux/tree/master/provision
256254
[mfxui]: https://github.com/mainflux/ui
257-
[ci]: https://github.com/mainflux/agent/actions/workflows/ci.yml/badge.svg
258-
[release]: https://github.com/mainflux/agent/actions/workflows/release.yml/badge.svg
255+
[ci]: https://github.com/absmach/agent/actions/workflows/ci.yml/badge.svg
256+
[release]: https://github.com/absmach/agent/actions/workflows/release.yml/badge.svg

0 commit comments

Comments
 (0)