Skip to content

Commit f07fc25

Browse files
authored
Merge pull request #35 from netboxlabs/develop
🚚 release
2 parents 6a1d5f1 + 855e92f commit f07fc25

Some content is hidden

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

56 files changed

+4041
-58
lines changed

β€ŽMakefileβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ docker-compose-netbox-plugin-down:
1414

1515
.PHONY: docker-compose-netbox-plugin-test
1616
docker-compose-netbox-plugin-test:
17-
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml run -u root --rm netbox ./manage.py test --keepdb netbox_diode_plugin
17+
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run -u root --rm netbox ./manage.py test --keepdb netbox_diode_plugin
1818
@$(MAKE) docker-compose-netbox-plugin-down
1919

2020
.PHONY: docker-compose-netbox-plugin-test-cover
2121
docker-compose-netbox-plugin-test-cover:
22-
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml run --rm -u root -e COVERAGE_FILE=/opt/netbox/netbox/coverage/.coverage netbox sh -c "coverage run --source=netbox_diode_plugin ./manage.py test --keepdb netbox_diode_plugin && coverage xml -o /opt/netbox/netbox/coverage/report.xml && coverage report -m | tee /opt/netbox/netbox/coverage/report.txt"
22+
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run --rm -u root -e COVERAGE_FILE=/opt/netbox/netbox/coverage/.coverage netbox sh -c "coverage run --source=netbox_diode_plugin --omit=*_pb2*,*/migrations/* ./manage.py test --keepdb netbox_diode_plugin && coverage xml -o /opt/netbox/netbox/coverage/report.xml && coverage report -m | tee /opt/netbox/netbox/coverage/report.txt"
2323
@$(MAKE) docker-compose-netbox-plugin-down

β€ŽREADME.mdβ€Ž

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ PLUGINS = [
4040
]
4141
```
4242

43+
Also in your `configuration.py` file, in order to customise the plugin settings, add `netbox_diode_plugin`to the
44+
`PLUGINS_CONFIG` dictionary, e.g.:
45+
46+
```python
47+
PLUGINS_CONFIG = {
48+
"netbox_diode_plugin": {
49+
# Diode gRPC target for communication with Diode server
50+
"diode_target_override": "grpc://localhost:8080/diode",
51+
52+
# User allowed for Diode to NetBox communication
53+
"diode_to_netbox_username": "diode-to-netbox",
54+
55+
# User allowed for NetBox to Diode communication
56+
"netbox_to_diode_username": "netbox-to-diode",
57+
58+
# # User allowed for data ingestion
59+
"diode_username": "diode-ingestion",
60+
},
61+
}
62+
```
63+
64+
Note: Once you customise usernames with PLUGINS_CONFIG during first installation, you should not change or remove them
65+
later on. Doing so will cause the plugin to stop working properly.
66+
4367
Restart NetBox services to load the plugin:
4468

4569
```

β€Ždocker/Dockerfile-diode-netbox-pluginβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM netboxcommunity/netbox:v4.1-beta1-2.9.1
1+
FROM netboxcommunity/netbox:v4.1-3.0.1
22

33
COPY ./netbox/configuration/ /etc/netbox/config/
44
RUN chmod 755 /etc/netbox/config/* && \
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: diode-netbox-plugin
2+
services:
3+
netbox:
4+
volumes:
5+
- ./netbox/plugins_test.py:/etc/netbox/config/plugins.py:z,ro

β€Ždocker/docker-compose.yamlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: diode-netbox-plugin
22
services:
3-
netbox: &netbox
4-
image: netboxcommunity/netbox:v4.1-beta1-2.9.1-diode-netbox-plugin
3+
netbox:
4+
image: netboxcommunity/netbox:v4.1-3.0.1-diode-netbox-plugin
55
build:
66
context: .
77
dockerfile: Dockerfile-diode-netbox-plugin

β€Ždocker/netbox/configuration/plugins.pyβ€Ž

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
# PLUGINS_CONFIG = {
1010
# "netbox_diode_plugin": {
11+
# # Diode gRPC target for communication with Diode server
12+
# "diode_target_override": "grpc://localhost:8080/diode",
1113
#
12-
# }
14+
# # User allowed for Diode to NetBox communication
15+
# "diode_to_netbox_username": "diode-to-netbox",
16+
#
17+
# # User allowed for NetBox to Diode communication
18+
# "netbox_to_diode_username": "netbox-to-diode",
19+
#
20+
# # User allowed for data ingestion
21+
# "diode_username": "diode-ingestion",
22+
# },
1323
# }

β€Ždocker/netbox/launch-netbox.shβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ load_configuration() {
4646

4747
reload_netbox() {
4848
if [ "$RELOAD_NETBOX_ON_DIODE_PLUGIN_CHANGE" == "true" ]; then
49-
netbox_diode_plugin_md5=$(find /opt/netbox/netbox/netbox_diode_plugin -type f -name "*.py" -exec md5sum {} + | md5sum | awk '{print $1}')
49+
netbox_diode_plugin_md5=$(find /opt/netbox/netbox/netbox_diode_plugin -type f \( -name "*.py" -o -name "*.html" \) -exec md5sum {} + | md5sum | awk '{print $1}')
5050

5151
while true; do
52-
new_md5=$(find /opt/netbox/netbox/netbox_diode_plugin -type f -name "*.py" -exec md5sum {} + | md5sum | awk '{print $1}')
52+
new_md5=$(find /opt/netbox/netbox/netbox_diode_plugin -type f \( -name "*.py" -o -name "*.html" \) -exec md5sum {} + | md5sum | awk '{print $1}')
5353
if [ "$netbox_diode_plugin_md5" != "$new_md5" ]; then
5454
echo "πŸ”„ Reloading NetBox"
5555
curl --silent --output /dev/null --unix-socket /opt/unit/unit.sock -X GET http://localhost/control/applications/netbox/restart
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Add your plugins and plugin settings here.
2+
# Of course uncomment this file out.
3+
4+
# To learn how to build images with your required plugins
5+
# See https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins
6+
7+
PLUGINS = ["netbox_diode_plugin"]
8+
9+
PLUGINS_CONFIG = {
10+
"netbox_diode_plugin": {
11+
"enable_ingestion_logs": True,
12+
}
13+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
pytest==8.0.2
2-
grpcio==1.62.1
1+
Brotli==1.1.0
2+
certifi==2024.7.4
33
coverage==7.6.0
4+
grpcio==1.62.1
5+
protobuf==5.28.1
6+
pytest==8.0.2

β€Žnetbox_diode_plugin/__init__.pyβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ class NetBoxDiodePluginConfig(PluginConfig):
1616
version = version_semver()
1717
base_url = "diode"
1818
min_version = "3.7.2"
19+
default_settings = {
20+
# Default Diode gRPC target for communication with Diode server
21+
"diode_target": "grpc://localhost:8080/diode",
22+
23+
# User allowed for Diode to NetBox communication
24+
"diode_to_netbox_username": "diode-to-netbox",
25+
26+
# User allowed for NetBox to Diode communication
27+
"netbox_to_diode_username": "netbox-to-diode",
28+
29+
# User allowed for data ingestion
30+
"diode_username": "diode-ingestion",
31+
}
1932

2033

2134
config = NetBoxDiodePluginConfig

0 commit comments

Comments
Β (0)