Commit 43abd6f
authored
feat: dev fixes, added receiver for signal to provide mutated inteface name (#42)
* fix(devcontainer): proxy/DNS hardening, dep install, cross-plugin examples
Several related devcontainer issues observed against a corporate network
with HTTP proxy, MITM TLS interception, and a wildcard DNS search domain.
docker-compose.yml:
- Pin postgres/redis to static IPs on a 172.28.200.0/24 bridge subnet.
Avoids the corporate MITM range at 172.30.x.x that Docker would
otherwise auto-pick.
- Add 'dns_search: ["."]' to netbox so bare names like 'postgres'
and 'redis' don't get the host's DNS search domain appended (a
wildcard search domain was returning the wrong IP for the bare
service names).
- Bump postgres max_connections to 200.
devcontainer.json:
- Move HTTP_PROXY/HTTPS_PROXY/NO_PROXY from containerEnv to remoteEnv.
VS Code resolves '${localEnv:HTTP_PROXY}' to an empty string when the
variable is unset on the host, which under containerEnv silently
overrides the value docker-compose loaded from .env. remoteEnv runs
after container start and can't shadow compose env.
- Drop the three REQUESTS_CA_BUNDLE / SSL_CERT_FILE / CURL_CA_BUNDLE
passes (they pointed at host paths that don't exist inside the
container; setup.sh handles CA-bundle resolution itself).
scripts/setup.sh:
- Add a fallback that reads HTTP/HTTPS/NO_PROXY directly from
.devcontainer/.env when remoteEnv left them empty (closes the same
gap as above for users who don't have proxy vars on the host).
- Pin postgres/redis hostnames in /etc/hosts. Backstop for the case
Docker's embedded DNS doesn't alias 'redis' because of a collision
with another container on the host of the same name. /etc/hosts is
consulted before DNS by libc, so this also covers the search-domain
case as defence in depth.
- Install pytest-cov, reuse, and (for the agent loop) the rest of the
test toolchain in the same install line — pyproject lists these as
dev deps but the previous setup.sh didn't install them, so fresh
containers shipped without 'pytest --cov' or the reuse-lint
pre-commit hook working. In-source comment now tracks what each
dep is for.
.env.example:
- Expand the commented NO_PROXY example to include 127.0.0.0/8 and ::1
loopback ranges (useful when container-local services bind there).
config/*.py.example:
- Add commented-out example wiring for an additional plugin mounted
from a sibling workspace ('netbox-example-plugin' under
/workspaces/myorg/…). Demonstrates the org-grouped mount pattern
without naming any specific real plugin.
scripts/process-helpers.sh:
- Restore executable bit (file is sourced by setup.sh and was losing
+x on some checkouts).
* chore(devcontainer): ignore docker-compose.override.yml
Allow a local-only compose override file alongside the committed
docker-compose.yml. docker compose auto-merges it on top, so site- or
plugin-specific env vars, mounts, or service tweaks can live in the
developer's working tree without polluting the shared compose file.
* feat(integration): bridge netbox-librenms-plugin module-name prediction
netbox-librenms-plugin's module-adoption flow predicts what interface
names a module's templates will produce so it can find pre-existing
standalone interfaces to adopt into the module. That prediction calls
NetBox's built-in template.instantiate(), which never sees our rename
rules — so for any module covered by an InterfaceNameRule, adoption
silently misses the post-rename name.
Closes the gap on both sides without coupling either plugin to the other:
engine.predict_rule_output(module, module_bay, raw_names):
- Pure name-prediction function that mirrors apply_interface_name_rules'
template evaluation but does no DB writes. Returns the names that
would exist post-apply (channel_count > 0 expands one raw name into
channel_count output names).
- Falls back to the raw name if evaluate_name_template raises, matching
the apply path's behavior of leaving the interface alone on failure.
signals.on_librenms_predict_module_interface_names:
- Receiver for netbox-librenms-plugin's predict_module_interface_names
Signal. Routes the predicted names through predict_rule_output and
returns the rewritten list. Returns None when module_bay is missing
or the engine raises, so librenms-plugin keeps its original list.
- Import is guarded so INR loads cleanly when librenms-plugin is absent.
Tests cover:
- predict_rule_output: no-rule passthrough, simple rename, breakout
expansion (1→N), multi-name preservation, pure-function guarantee
(no Interface row mutations), template-eval failure fallback.
- LibrenmsPredictReceiverTest: end-to-end signal dispatch returns
rewritten names, None when module_bay missing, None when engine
raises.
* fix: tighten validation of interface name in receiver
* chore: adjust compose
* fix: addressing review
* fix: addressing review1 parent 0a773ab commit 43abd6f
12 files changed
Lines changed: 314 additions & 7 deletions
File tree
- .devcontainer
- config
- scripts
- netbox_interface_name_rules
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 45 | + | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
File mode changed.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
21 | 39 | | |
22 | 40 | | |
23 | 41 | | |
| |||
35 | 53 | | |
36 | 54 | | |
37 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
38 | 71 | | |
39 | 72 | | |
40 | 73 | | |
| |||
105 | 138 | | |
106 | 139 | | |
107 | 140 | | |
108 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
109 | 146 | | |
110 | 147 | | |
111 | 148 | | |
| |||
228 | 265 | | |
229 | 266 | | |
230 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
231 | 281 | | |
232 | 282 | | |
233 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
111 | 151 | | |
112 | 152 | | |
113 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
0 commit comments