netbox-lantronix 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. netbox_lantronix-0.5.1/LICENSE +202 -0
  2. netbox_lantronix-0.5.1/PKG-INFO +211 -0
  3. netbox_lantronix-0.5.1/README.md +194 -0
  4. netbox_lantronix-0.5.1/netbox_lantronix/__init__.py +28 -0
  5. netbox_lantronix-0.5.1/netbox_lantronix/api/__init__.py +0 -0
  6. netbox_lantronix-0.5.1/netbox_lantronix/api/serializers.py +168 -0
  7. netbox_lantronix-0.5.1/netbox_lantronix/api/urls.py +13 -0
  8. netbox_lantronix-0.5.1/netbox_lantronix/api/views.py +79 -0
  9. netbox_lantronix-0.5.1/netbox_lantronix/bootstrap.py +42 -0
  10. netbox_lantronix-0.5.1/netbox_lantronix/endpoint_checks.py +27 -0
  11. netbox_lantronix-0.5.1/netbox_lantronix/filtersets.py +62 -0
  12. netbox_lantronix-0.5.1/netbox_lantronix/forms.py +90 -0
  13. netbox_lantronix-0.5.1/netbox_lantronix/jobs.py +230 -0
  14. netbox_lantronix-0.5.1/netbox_lantronix/migrations/0001_initial.py +278 -0
  15. netbox_lantronix-0.5.1/netbox_lantronix/migrations/0002_finding_signature.py +27 -0
  16. netbox_lantronix-0.5.1/netbox_lantronix/migrations/0003_link_mgmt_ip.py +17 -0
  17. netbox_lantronix-0.5.1/netbox_lantronix/migrations/0004_portfacts_state.py +20 -0
  18. netbox_lantronix-0.5.1/netbox_lantronix/migrations/0005_link_firmware_version.py +20 -0
  19. netbox_lantronix-0.5.1/netbox_lantronix/migrations/__init__.py +0 -0
  20. netbox_lantronix-0.5.1/netbox_lantronix/models.py +319 -0
  21. netbox_lantronix-0.5.1/netbox_lantronix/navigation.py +63 -0
  22. netbox_lantronix-0.5.1/netbox_lantronix/percepxion/__init__.py +0 -0
  23. netbox_lantronix-0.5.1/netbox_lantronix/percepxion/client.py +278 -0
  24. netbox_lantronix-0.5.1/netbox_lantronix/percepxion/records.py +90 -0
  25. netbox_lantronix-0.5.1/netbox_lantronix/percepxion/resolver.py +203 -0
  26. netbox_lantronix-0.5.1/netbox_lantronix/percepxion/telemetry.py +123 -0
  27. netbox_lantronix-0.5.1/netbox_lantronix/sanitize.py +106 -0
  28. netbox_lantronix-0.5.1/netbox_lantronix/sync/__init__.py +0 -0
  29. netbox_lantronix-0.5.1/netbox_lantronix/sync/apply.py +317 -0
  30. netbox_lantronix-0.5.1/netbox_lantronix/sync/planner.py +440 -0
  31. netbox_lantronix-0.5.1/netbox_lantronix/tables.py +113 -0
  32. netbox_lantronix-0.5.1/netbox_lantronix/template_content.py +90 -0
  33. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/devicelink.html +27 -0
  34. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/devicetypeoverride.html +13 -0
  35. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/inc/device_panel.html +13 -0
  36. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/inc/finding_fix.html +8 -0
  37. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/inc/port_buttons.html +6 -0
  38. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/inc/port_facts.html +12 -0
  39. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/modelrule.html +13 -0
  40. netbox_lantronix-0.5.1/netbox_lantronix/templates/netbox_lantronix/percepxionsource.html +69 -0
  41. netbox_lantronix-0.5.1/netbox_lantronix/tests/__init__.py +0 -0
  42. netbox_lantronix-0.5.1/netbox_lantronix/tests/netbox_fixtures.py +65 -0
  43. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_apply.py +165 -0
  44. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_client.py +570 -0
  45. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_endpoint_checks.py +36 -0
  46. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_jobs.py +213 -0
  47. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_planner.py +408 -0
  48. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_plugin_registry.py +26 -0
  49. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_recorded.py +70 -0
  50. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_resolver.py +224 -0
  51. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_sanitize.py +76 -0
  52. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_serializers.py +44 -0
  53. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_telemetry.py +102 -0
  54. netbox_lantronix-0.5.1/netbox_lantronix/tests/test_views.py +269 -0
  55. netbox_lantronix-0.5.1/netbox_lantronix/urls.py +18 -0
  56. netbox_lantronix-0.5.1/netbox_lantronix/views.py +197 -0
  57. netbox_lantronix-0.5.1/netbox_lantronix.egg-info/PKG-INFO +211 -0
  58. netbox_lantronix-0.5.1/netbox_lantronix.egg-info/SOURCES.txt +61 -0
  59. netbox_lantronix-0.5.1/netbox_lantronix.egg-info/dependency_links.txt +1 -0
  60. netbox_lantronix-0.5.1/netbox_lantronix.egg-info/requires.txt +6 -0
  61. netbox_lantronix-0.5.1/netbox_lantronix.egg-info/top_level.txt +1 -0
  62. netbox_lantronix-0.5.1/pyproject.toml +29 -0
  63. netbox_lantronix-0.5.1/setup.cfg +4 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-lantronix
3
+ Version: 0.5.1
4
+ Summary: NetBox plugin that keeps NetBox current with Lantronix SLC and EMG devices managed by Percepxion
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Repository, https://github.com/Lantronix/netbox-lantronix
7
+ Project-URL: Changelog, https://github.com/Lantronix/netbox-lantronix/blob/main/CHANGELOG.md
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: requests>=2.31
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8; extra == "dev"
14
+ Requires-Dist: ruff>=0.6; extra == "dev"
15
+ Requires-Dist: requests>=2.31; extra == "dev"
16
+ Dynamic: license-file
17
+
18
+ # netbox-lantronix
19
+
20
+ A NetBox plugin that keeps NetBox current with the Lantronix SLC 9000, SLC 8000 and EMG console servers managed by Percepxion. Nobody has to type console server inventory into NetBox by hand.
21
+
22
+ On each sync the plugin reads Percepxion and:
23
+
24
+ - creates the console server in NetBox with the right device type, so its console server ports come from the device type
25
+ - labels each console server port with the name configured on the console server, and describes it with the hostname of the attached device
26
+ - shows the attached device's make, model, OS and serial on the port, when the console server reports them
27
+ - adds an **Open console** button on each port that launches an SSH session through the console server (`ssh://<console server>:<base port + port number>`)
28
+ - lists anything it couldn't decide, such as an ambiguous model or a name conflict, as findings with a one-click fix
29
+
30
+ The plugin never writes to Percepxion or to a console server. It reads from Percepxion and writes to NetBox only.
31
+
32
+ ## Requirements
33
+
34
+ | | |
35
+ |---|---|
36
+ | NetBox | 4.6.0 to 4.7.x (the plugin refuses to load on other versions) |
37
+ | Python | 3.12 or later |
38
+ | RQ worker | A running NetBox worker (`manage.py rqworker`). Scheduled and on-demand syncs run as NetBox background jobs. |
39
+ | Percepxion | Percepxion cloud or on-premises, and a Percepxion user with the **tenant_user** role in the organization you sync. No administrator role is needed. |
40
+ | Device types | Lantronix SLC and EMG device types, imported before the first sync. The definitions are in [`docker/device-types`](docker/device-types). |
41
+
42
+ ## Install
43
+
44
+ 1. Install the package into the NetBox virtual environment:
45
+
46
+ ```
47
+ source /opt/netbox/venv/bin/activate
48
+ pip install netbox-lantronix
49
+ ```
50
+
51
+ To pin a version, install `netbox-lantronix==X.Y.Z` with a version from the [releases](https://github.com/Lantronix/netbox-lantronix/releases). For netbox-docker, follow [Docker](#docker) instead of these steps.
52
+
53
+ 2. Enable and configure the plugin in `configuration.py` (see [Configuration](#configuration)).
54
+
55
+ 3. Run the migrations and collect static files:
56
+
57
+ ```
58
+ cd /opt/netbox/netbox
59
+ python3 manage.py migrate netbox_lantronix
60
+ python3 manage.py collectstatic --no-input
61
+ ```
62
+
63
+ 4. Restart NetBox and the RQ worker.
64
+
65
+ 5. Create the NetBox user that sync changes are attributed to, for example `percepxion-sync`, and give it permissions (see [Permissions](#permissions)). It doesn't need to log in.
66
+
67
+ 6. Import the device types for your hardware from [`docker/device-types`](docker/device-types) through **Devices > Device Types > Import**.
68
+
69
+ On the first run the plugin creates the manufacturer `Lantronix`, the platform `lantronix_itmgos` and the device custom field `percepxion_device_id` if they don't exist, and reuses them if they do. These are the same objects the `lantronix.oob` Ansible collection's NetBox playbook uses, so the two can share a NetBox.
70
+
71
+ ## Docker
72
+
73
+ This builds a NetBox 4.6 image with the plugin, using [netbox-docker](https://github.com/netbox-community/netbox-docker). You need Docker with Compose and a Percepxion user with the **tenant_user** role.
74
+
75
+ 1. Clone both repositories side by side and copy in the plugin's files:
76
+
77
+ ```
78
+ git clone -b 5.0.2 --depth 1 https://github.com/netbox-community/netbox-docker.git
79
+ git clone https://github.com/Lantronix/netbox-lantronix.git
80
+ cd netbox-docker
81
+ cp ../netbox-lantronix/docker/docker-compose.override.yml .
82
+ cp ../netbox-lantronix/docker/plugins.py configuration/plugins.py
83
+ cp ../netbox-lantronix/docker/percepxion.env.example env/percepxion.env
84
+ ```
85
+
86
+ 2. Add your Percepxion username and password to `env/percepxion.env`. For on-premises Percepxion, change `PERCEPXION_URL` too.
87
+
88
+ 3. Build and start NetBox. The first start runs the database migrations and can take several minutes.
89
+
90
+ ```
91
+ docker compose build
92
+ docker compose up -d
93
+ ```
94
+
95
+ 4. Create your NetBox login:
96
+
97
+ ```
98
+ docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
99
+ ```
100
+
101
+ 5. Import the device types and create the `percepxion-sync` user, a site and a role. Its permissions are limited to that site, and running it again changes nothing that already exists.
102
+
103
+ ```
104
+ docker compose exec netbox /opt/netbox/netbox/manage.py nbshell -c "exec(open('/opt/netbox-lantronix-docker/setup.py').read())"
105
+ ```
106
+
107
+ 6. Open http://localhost:8000 and follow [First sync](#first-sync), with endpoint `percepxion`, site **Console Servers** and role **Console Server**.
108
+
109
+ To use another port, set `NETBOX_PORT` when you start NetBox. The stack runs as Compose project `netbox-lantronix`, so its containers and database stay separate from any other netbox-docker on the host.
110
+
111
+ ## Configuration
112
+
113
+ Endpoints and credentials live only in `configuration.py` or the environment, never in the NetBox database.
114
+
115
+ ```python
116
+ import os
117
+
118
+ PLUGINS = ["netbox_lantronix"]
119
+
120
+ PLUGINS_CONFIG = {
121
+ "netbox_lantronix": {
122
+ # NetBox user that change records are attributed to. Must exist.
123
+ "sync_user": "percepxion-sync",
124
+ "endpoints": {
125
+ # Name you pick here; a Percepxion source in the UI refers to it.
126
+ "percepxion-cloud": {
127
+ "url": "https://api.percepxion.ai/api", # API base, including /api
128
+ "username": os.environ["PERCEPXION_USERNAME"],
129
+ "password": os.environ["PERCEPXION_PASSWORD"],
130
+ # Optional:
131
+ # "verify": True, # TLS verification, on by default
132
+ # "ca_bundle": "/etc/ssl/px-ca.pem", # CA bundle for on-premises Percepxion
133
+ # "proxy": "http://proxy.example.com:3128",
134
+ },
135
+ },
136
+ },
137
+ }
138
+ ```
139
+
140
+ - `url` must use `https://`. The plugin won't load an endpoint that doesn't.
141
+ - `username` and `password` are required. They're read when a sync starts and never written to the database, job data, logs or findings.
142
+ - A missing key stops the plugin at startup with an error that names the endpoint and the key, never the value.
143
+ - Turning `verify` off shows a warning on every source that uses the endpoint.
144
+ - Endpoint changes take effect after a NetBox restart.
145
+
146
+ ## First sync
147
+
148
+ 1. Go to **Plugins > Lantronix > Percepxion Sources > Add**.
149
+ 2. Pick the endpoint and enter the Percepxion organization ID. Then choose the NetBox site and device role for new console servers, the sync interval in minutes (0 turns scheduling off, otherwise at least 5), and the SSH base port (3000 unless you changed it on your console servers).
150
+ 3. Save, then click **Sync now**. The job appears under the source with its counts and log.
151
+ 4. Open **Findings**. Each one names the device and the fix.
152
+
153
+ To sync on events instead of waiting for the schedule, call `POST /api/plugins/lantronix/sources/<id>/sync/` with an API token whose user has the sync permission. It answers 202 with the queued job, or 409 when a run is already queued or running, which will pick up the change.
154
+
155
+ ### Device models
156
+
157
+ Percepxion reports an SLC 9000's model as its total number of serial ports and doesn't report the Ethernet switch module or the power supply type. Several SLC 9000 SKUs therefore look the same in Percepxion. The plugin picks the device type in this order:
158
+
159
+ 1. **Type override** for that device, if you set one
160
+ 2. **`show sysconfig` output** stored in Percepxion: if anyone has run `show sysconfig` on the unit through Percepxion (console editor or a CLI job), the plugin reads the exact model and power supply type from that output
161
+ 3. **Model rule** on the source, matching Percepxion model plus RJ45 and USB port counts to one device type, for fleets that buy one variant
162
+ 4. A **single device type** that matches the port counts
163
+
164
+ When none of these settles it, the device isn't created and an "ambiguous model" finding lists the candidate types. **Create rule** and **Override** on the finding open forms with the Percepxion values filled in and the device type choices limited to those candidates. EMG units resolve from Percepxion data alone.
165
+
166
+ ### What the plugin changes in NetBox
167
+
168
+ | Object | Plugin writes | Plugin never changes |
169
+ |---|---|---|
170
+ | Console server (device) | created with name, type, site, role, platform, serial; name kept in step with Percepxion | site, role or type of an existing device |
171
+ | Console server port | label (the port's name on the console server), description (attached device hostname) | name, cables, anything else |
172
+ | Port facts panel | attached device make, model, OS, version, serial, last reported time | |
173
+
174
+ The console server is the source of truth for port labels and descriptions. A label edited by hand in NetBox is overwritten on the next sync. Rename the port on the console server instead.
175
+
176
+ The plugin matches Percepxion devices to NetBox devices by its own link, then by serial number, then by name. When a serial match is in a different site from the source, or a name match has no serial to confirm it, the link is created as **pending** and nothing is written until someone with the approve permission approves it. A run writes only objects that changed, so a sync with no changes in Percepxion records no change log entries.
177
+
178
+ ## Permissions
179
+
180
+ | Permission | Allows |
181
+ |---|---|
182
+ | `netbox_lantronix.add/change/delete_percepxionsource` | manage sources |
183
+ | `netbox_lantronix.sync_percepxionsource` | run **Sync now** or the sync API call, and schedule syncs when saving a source |
184
+ | `netbox_lantronix.view_*` | see sources, links, rules, overrides, findings and run history |
185
+ | `netbox_lantronix.approve_devicelink` | approve pending device adoptions |
186
+ | `netbox_lantronix.add/change_modelrule`, `..._devicetypeoverride` | resolve ambiguous models |
187
+
188
+ The sync user needs `dcim.view/add/change_device` and `dcim.view/change_consoleserverport`, plus view on device types, sites, roles and platforms. Constrain these with NetBox object permissions, for example to one site, and the plugin stays inside them. A run that would write outside them fails as a whole, with the reason on the job, and changes nothing.
189
+
190
+ The **Open console** button and the facts panel are shown only to users who can view the device and its ports.
191
+
192
+ ## Open console
193
+
194
+ The button builds `ssh://<address>:<SSH base port + port number>`. It uses the device's primary IP in NetBox, or the management address Percepxion reports when no primary IP is set. Your browser opens it with your SSH client and you sign in to the console server as yourself.
195
+
196
+ On the console server, direct SSH access is off by default on every port. Turn it on for the ports you want to reach, for example `set deviceport port 1-48 sshin enable` (answer `yes` to the confirmation), or from the WebUI's device port settings with **Apply Settings** to the ports you choose.
197
+
198
+ ## Troubleshooting
199
+
200
+ | Symptom | Check |
201
+ |---|---|
202
+ | Plugin doesn't load | NetBox log names the endpoint and missing key, or a NetBox version outside 4.6 to 4.7 |
203
+ | Job stays queued | RQ worker not running |
204
+ | Job fails with a login error | Credentials in the environment. After a rejected login, scheduled runs pause for at least 30 minutes. Fix the credentials, restart NetBox, then click **Sync now**; it retries at once only when the credentials changed. |
205
+ | Job fails with a permission error | The sync user's object permissions don't cover the device or site named in the error |
206
+ | Device missing after a sync | **Findings**: ambiguous model, missing device type, name conflict or pending adoption |
207
+ | PuTTY or ssh reports "connection refused" | Direct SSH access is off on that port of the console server (see [Open console](#open-console)) |
208
+
209
+ ## License
210
+
211
+ Apache-2.0
@@ -0,0 +1,194 @@
1
+ # netbox-lantronix
2
+
3
+ A NetBox plugin that keeps NetBox current with the Lantronix SLC 9000, SLC 8000 and EMG console servers managed by Percepxion. Nobody has to type console server inventory into NetBox by hand.
4
+
5
+ On each sync the plugin reads Percepxion and:
6
+
7
+ - creates the console server in NetBox with the right device type, so its console server ports come from the device type
8
+ - labels each console server port with the name configured on the console server, and describes it with the hostname of the attached device
9
+ - shows the attached device's make, model, OS and serial on the port, when the console server reports them
10
+ - adds an **Open console** button on each port that launches an SSH session through the console server (`ssh://<console server>:<base port + port number>`)
11
+ - lists anything it couldn't decide, such as an ambiguous model or a name conflict, as findings with a one-click fix
12
+
13
+ The plugin never writes to Percepxion or to a console server. It reads from Percepxion and writes to NetBox only.
14
+
15
+ ## Requirements
16
+
17
+ | | |
18
+ |---|---|
19
+ | NetBox | 4.6.0 to 4.7.x (the plugin refuses to load on other versions) |
20
+ | Python | 3.12 or later |
21
+ | RQ worker | A running NetBox worker (`manage.py rqworker`). Scheduled and on-demand syncs run as NetBox background jobs. |
22
+ | Percepxion | Percepxion cloud or on-premises, and a Percepxion user with the **tenant_user** role in the organization you sync. No administrator role is needed. |
23
+ | Device types | Lantronix SLC and EMG device types, imported before the first sync. The definitions are in [`docker/device-types`](docker/device-types). |
24
+
25
+ ## Install
26
+
27
+ 1. Install the package into the NetBox virtual environment:
28
+
29
+ ```
30
+ source /opt/netbox/venv/bin/activate
31
+ pip install netbox-lantronix
32
+ ```
33
+
34
+ To pin a version, install `netbox-lantronix==X.Y.Z` with a version from the [releases](https://github.com/Lantronix/netbox-lantronix/releases). For netbox-docker, follow [Docker](#docker) instead of these steps.
35
+
36
+ 2. Enable and configure the plugin in `configuration.py` (see [Configuration](#configuration)).
37
+
38
+ 3. Run the migrations and collect static files:
39
+
40
+ ```
41
+ cd /opt/netbox/netbox
42
+ python3 manage.py migrate netbox_lantronix
43
+ python3 manage.py collectstatic --no-input
44
+ ```
45
+
46
+ 4. Restart NetBox and the RQ worker.
47
+
48
+ 5. Create the NetBox user that sync changes are attributed to, for example `percepxion-sync`, and give it permissions (see [Permissions](#permissions)). It doesn't need to log in.
49
+
50
+ 6. Import the device types for your hardware from [`docker/device-types`](docker/device-types) through **Devices > Device Types > Import**.
51
+
52
+ On the first run the plugin creates the manufacturer `Lantronix`, the platform `lantronix_itmgos` and the device custom field `percepxion_device_id` if they don't exist, and reuses them if they do. These are the same objects the `lantronix.oob` Ansible collection's NetBox playbook uses, so the two can share a NetBox.
53
+
54
+ ## Docker
55
+
56
+ This builds a NetBox 4.6 image with the plugin, using [netbox-docker](https://github.com/netbox-community/netbox-docker). You need Docker with Compose and a Percepxion user with the **tenant_user** role.
57
+
58
+ 1. Clone both repositories side by side and copy in the plugin's files:
59
+
60
+ ```
61
+ git clone -b 5.0.2 --depth 1 https://github.com/netbox-community/netbox-docker.git
62
+ git clone https://github.com/Lantronix/netbox-lantronix.git
63
+ cd netbox-docker
64
+ cp ../netbox-lantronix/docker/docker-compose.override.yml .
65
+ cp ../netbox-lantronix/docker/plugins.py configuration/plugins.py
66
+ cp ../netbox-lantronix/docker/percepxion.env.example env/percepxion.env
67
+ ```
68
+
69
+ 2. Add your Percepxion username and password to `env/percepxion.env`. For on-premises Percepxion, change `PERCEPXION_URL` too.
70
+
71
+ 3. Build and start NetBox. The first start runs the database migrations and can take several minutes.
72
+
73
+ ```
74
+ docker compose build
75
+ docker compose up -d
76
+ ```
77
+
78
+ 4. Create your NetBox login:
79
+
80
+ ```
81
+ docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
82
+ ```
83
+
84
+ 5. Import the device types and create the `percepxion-sync` user, a site and a role. Its permissions are limited to that site, and running it again changes nothing that already exists.
85
+
86
+ ```
87
+ docker compose exec netbox /opt/netbox/netbox/manage.py nbshell -c "exec(open('/opt/netbox-lantronix-docker/setup.py').read())"
88
+ ```
89
+
90
+ 6. Open http://localhost:8000 and follow [First sync](#first-sync), with endpoint `percepxion`, site **Console Servers** and role **Console Server**.
91
+
92
+ To use another port, set `NETBOX_PORT` when you start NetBox. The stack runs as Compose project `netbox-lantronix`, so its containers and database stay separate from any other netbox-docker on the host.
93
+
94
+ ## Configuration
95
+
96
+ Endpoints and credentials live only in `configuration.py` or the environment, never in the NetBox database.
97
+
98
+ ```python
99
+ import os
100
+
101
+ PLUGINS = ["netbox_lantronix"]
102
+
103
+ PLUGINS_CONFIG = {
104
+ "netbox_lantronix": {
105
+ # NetBox user that change records are attributed to. Must exist.
106
+ "sync_user": "percepxion-sync",
107
+ "endpoints": {
108
+ # Name you pick here; a Percepxion source in the UI refers to it.
109
+ "percepxion-cloud": {
110
+ "url": "https://api.percepxion.ai/api", # API base, including /api
111
+ "username": os.environ["PERCEPXION_USERNAME"],
112
+ "password": os.environ["PERCEPXION_PASSWORD"],
113
+ # Optional:
114
+ # "verify": True, # TLS verification, on by default
115
+ # "ca_bundle": "/etc/ssl/px-ca.pem", # CA bundle for on-premises Percepxion
116
+ # "proxy": "http://proxy.example.com:3128",
117
+ },
118
+ },
119
+ },
120
+ }
121
+ ```
122
+
123
+ - `url` must use `https://`. The plugin won't load an endpoint that doesn't.
124
+ - `username` and `password` are required. They're read when a sync starts and never written to the database, job data, logs or findings.
125
+ - A missing key stops the plugin at startup with an error that names the endpoint and the key, never the value.
126
+ - Turning `verify` off shows a warning on every source that uses the endpoint.
127
+ - Endpoint changes take effect after a NetBox restart.
128
+
129
+ ## First sync
130
+
131
+ 1. Go to **Plugins > Lantronix > Percepxion Sources > Add**.
132
+ 2. Pick the endpoint and enter the Percepxion organization ID. Then choose the NetBox site and device role for new console servers, the sync interval in minutes (0 turns scheduling off, otherwise at least 5), and the SSH base port (3000 unless you changed it on your console servers).
133
+ 3. Save, then click **Sync now**. The job appears under the source with its counts and log.
134
+ 4. Open **Findings**. Each one names the device and the fix.
135
+
136
+ To sync on events instead of waiting for the schedule, call `POST /api/plugins/lantronix/sources/<id>/sync/` with an API token whose user has the sync permission. It answers 202 with the queued job, or 409 when a run is already queued or running, which will pick up the change.
137
+
138
+ ### Device models
139
+
140
+ Percepxion reports an SLC 9000's model as its total number of serial ports and doesn't report the Ethernet switch module or the power supply type. Several SLC 9000 SKUs therefore look the same in Percepxion. The plugin picks the device type in this order:
141
+
142
+ 1. **Type override** for that device, if you set one
143
+ 2. **`show sysconfig` output** stored in Percepxion: if anyone has run `show sysconfig` on the unit through Percepxion (console editor or a CLI job), the plugin reads the exact model and power supply type from that output
144
+ 3. **Model rule** on the source, matching Percepxion model plus RJ45 and USB port counts to one device type, for fleets that buy one variant
145
+ 4. A **single device type** that matches the port counts
146
+
147
+ When none of these settles it, the device isn't created and an "ambiguous model" finding lists the candidate types. **Create rule** and **Override** on the finding open forms with the Percepxion values filled in and the device type choices limited to those candidates. EMG units resolve from Percepxion data alone.
148
+
149
+ ### What the plugin changes in NetBox
150
+
151
+ | Object | Plugin writes | Plugin never changes |
152
+ |---|---|---|
153
+ | Console server (device) | created with name, type, site, role, platform, serial; name kept in step with Percepxion | site, role or type of an existing device |
154
+ | Console server port | label (the port's name on the console server), description (attached device hostname) | name, cables, anything else |
155
+ | Port facts panel | attached device make, model, OS, version, serial, last reported time | |
156
+
157
+ The console server is the source of truth for port labels and descriptions. A label edited by hand in NetBox is overwritten on the next sync. Rename the port on the console server instead.
158
+
159
+ The plugin matches Percepxion devices to NetBox devices by its own link, then by serial number, then by name. When a serial match is in a different site from the source, or a name match has no serial to confirm it, the link is created as **pending** and nothing is written until someone with the approve permission approves it. A run writes only objects that changed, so a sync with no changes in Percepxion records no change log entries.
160
+
161
+ ## Permissions
162
+
163
+ | Permission | Allows |
164
+ |---|---|
165
+ | `netbox_lantronix.add/change/delete_percepxionsource` | manage sources |
166
+ | `netbox_lantronix.sync_percepxionsource` | run **Sync now** or the sync API call, and schedule syncs when saving a source |
167
+ | `netbox_lantronix.view_*` | see sources, links, rules, overrides, findings and run history |
168
+ | `netbox_lantronix.approve_devicelink` | approve pending device adoptions |
169
+ | `netbox_lantronix.add/change_modelrule`, `..._devicetypeoverride` | resolve ambiguous models |
170
+
171
+ The sync user needs `dcim.view/add/change_device` and `dcim.view/change_consoleserverport`, plus view on device types, sites, roles and platforms. Constrain these with NetBox object permissions, for example to one site, and the plugin stays inside them. A run that would write outside them fails as a whole, with the reason on the job, and changes nothing.
172
+
173
+ The **Open console** button and the facts panel are shown only to users who can view the device and its ports.
174
+
175
+ ## Open console
176
+
177
+ The button builds `ssh://<address>:<SSH base port + port number>`. It uses the device's primary IP in NetBox, or the management address Percepxion reports when no primary IP is set. Your browser opens it with your SSH client and you sign in to the console server as yourself.
178
+
179
+ On the console server, direct SSH access is off by default on every port. Turn it on for the ports you want to reach, for example `set deviceport port 1-48 sshin enable` (answer `yes` to the confirmation), or from the WebUI's device port settings with **Apply Settings** to the ports you choose.
180
+
181
+ ## Troubleshooting
182
+
183
+ | Symptom | Check |
184
+ |---|---|
185
+ | Plugin doesn't load | NetBox log names the endpoint and missing key, or a NetBox version outside 4.6 to 4.7 |
186
+ | Job stays queued | RQ worker not running |
187
+ | Job fails with a login error | Credentials in the environment. After a rejected login, scheduled runs pause for at least 30 minutes. Fix the credentials, restart NetBox, then click **Sync now**; it retries at once only when the credentials changed. |
188
+ | Job fails with a permission error | The sync user's object permissions don't cover the device or site named in the error |
189
+ | Device missing after a sync | **Findings**: ambiguous model, missing device type, name conflict or pending adoption |
190
+ | PuTTY or ssh reports "connection refused" | Direct SSH access is off on that port of the console server (see [Open console](#open-console)) |
191
+
192
+ ## License
193
+
194
+ Apache-2.0
@@ -0,0 +1,28 @@
1
+ from netbox.plugins import PluginConfig
2
+
3
+ __version__ = "0.5.1"
4
+
5
+
6
+ class NetBoxLantronixConfig(PluginConfig):
7
+ name = "netbox_lantronix"
8
+ verbose_name = "Lantronix"
9
+ description = "Sync Lantronix SLC and EMG devices from Percepxion into NetBox"
10
+ version = __version__
11
+ base_url = "lantronix"
12
+ min_version = "4.6.0"
13
+ max_version = "4.7.99"
14
+ default_settings = {
15
+ "sync_user": None,
16
+ "endpoints": {},
17
+ }
18
+
19
+ def ready(self):
20
+ super().ready()
21
+ from netbox.plugins import get_plugin_config
22
+
23
+ from .endpoint_checks import validate_endpoints
24
+
25
+ validate_endpoints(get_plugin_config(self.name, "endpoints"))
26
+
27
+
28
+ config = NetBoxLantronixConfig