netbox-netscaler 0.1.0__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 (32) hide show
  1. netbox_netscaler-0.1.0/LICENSE +190 -0
  2. netbox_netscaler-0.1.0/PKG-INFO +154 -0
  3. netbox_netscaler-0.1.0/README.md +123 -0
  4. netbox_netscaler-0.1.0/netbox_netscaler/__init__.py +39 -0
  5. netbox_netscaler-0.1.0/netbox_netscaler/api.py +17 -0
  6. netbox_netscaler-0.1.0/netbox_netscaler/cache.py +52 -0
  7. netbox_netscaler-0.1.0/netbox_netscaler/inventory.py +194 -0
  8. netbox_netscaler-0.1.0/netbox_netscaler/matching.py +162 -0
  9. netbox_netscaler-0.1.0/netbox_netscaler/navigation.py +25 -0
  10. netbox_netscaler-0.1.0/netbox_netscaler/nitro.py +81 -0
  11. netbox_netscaler-0.1.0/netbox_netscaler/resolve.py +53 -0
  12. netbox_netscaler-0.1.0/netbox_netscaler/sync.py +227 -0
  13. netbox_netscaler-0.1.0/netbox_netscaler/sync_netbox.py +138 -0
  14. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/_pairs.html +21 -0
  15. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/_state.html +1 -0
  16. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/ip_tab.html +98 -0
  17. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/netscaler_tab.html +65 -0
  18. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/stale_vips.html +63 -0
  19. netbox_netscaler-0.1.0/netbox_netscaler/templates/netbox_netscaler/sync_vips.html +116 -0
  20. netbox_netscaler-0.1.0/netbox_netscaler/urls.py +11 -0
  21. netbox_netscaler-0.1.0/netbox_netscaler/views.py +247 -0
  22. netbox_netscaler-0.1.0/netbox_netscaler.egg-info/PKG-INFO +154 -0
  23. netbox_netscaler-0.1.0/netbox_netscaler.egg-info/SOURCES.txt +30 -0
  24. netbox_netscaler-0.1.0/netbox_netscaler.egg-info/dependency_links.txt +1 -0
  25. netbox_netscaler-0.1.0/netbox_netscaler.egg-info/requires.txt +7 -0
  26. netbox_netscaler-0.1.0/netbox_netscaler.egg-info/top_level.txt +1 -0
  27. netbox_netscaler-0.1.0/pyproject.toml +61 -0
  28. netbox_netscaler-0.1.0/setup.cfg +4 -0
  29. netbox_netscaler-0.1.0/tests/test_inventory.py +117 -0
  30. netbox_netscaler-0.1.0/tests/test_matching.py +190 -0
  31. netbox_netscaler-0.1.0/tests/test_nitro.py +98 -0
  32. netbox_netscaler-0.1.0/tests/test_sync.py +246 -0
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 sieteunoseis
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-netscaler
3
+ Version: 0.1.0
4
+ Summary: Read-only NetBox plugin showing Citrix NetScaler VIPs, service group members and GSLB names on VMs and devices
5
+ Author-email: sieteunoseis <jeremy.worden@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/sieteunoseis/netbox-netscaler
8
+ Project-URL: Repository, https://github.com/sieteunoseis/netbox-netscaler
9
+ Project-URL: Issues, https://github.com/sieteunoseis/netbox-netscaler/issues
10
+ Project-URL: Documentation, https://github.com/sieteunoseis/netbox-netscaler/wiki
11
+ Project-URL: Changelog, https://github.com/sieteunoseis/netbox-netscaler/blob/main/CHANGELOG.md
12
+ Keywords: netbox,netscaler,citrix,load balancer,gslb,plugin
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: Django
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: requests>=2.28.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: black; extra == "dev"
27
+ Requires-Dist: flake8; extra == "dev"
28
+ Requires-Dist: isort; extra == "dev"
29
+ Requires-Dist: pytest; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # netbox-netscaler
33
+
34
+ Read-only NetBox plugin that shows which Citrix NetScaler (ADC) VIPs depend on a server, so that
35
+ decommissions stop missing the load balancer.
36
+
37
+ - **NetScaler tab** on every VM and Device with an IP: each lb VIP where the server is a
38
+ service-group member, across all configured HA pairs, with the member state, the GSLB names in
39
+ front of the VIP, and flags:
40
+ - **Last live member**: no other server behind the VIP is UP, so the VIP goes down with this one.
41
+ - **Name mismatch**: the NetScaler server object's name matches neither the NetBox object nor the
42
+ IP's DNS name. This usually means the NetScaler config is wrong or stale.
43
+ - **Ambiguous IP**: more than one NetBox IP record has the member's address.
44
+ - **Stale VIPs** page (Plugins menu): every VIP with no live server behind it. That covers VIPs
45
+ whose members are all DOWN, all on decommissioning or offline objects, or not in NetBox, as well
46
+ as VIPs with no members at all.
47
+
48
+ - **NetScaler tab on IP address pages**: for a VIP, its vservers, members (linked to their NetBox objects)
49
+ and GSLB names; for a member IP, the VIPs it belongs to.
50
+ - **Sync VIPs** page (Plugins menu): compares live VIPs with NetBox IPAM and lets an engineer preview, tick and
51
+ apply changes. Run it whenever you like; there is no schedule.
52
+ - **Create**: VIPs that are UP but have no NetBox IP record. They're created as `/32`, role VIP, attached to
53
+ the pair's current Primary NetScaler VM.
54
+ - **Update**: VIP records whose status, description or attachment no longer matches NetScaler. Each row shows
55
+ old → new values. DNS names are only filled in when blank, never replaced.
56
+ - **Orphaned**: VIP records whose address isn't on any NetScaler. The only action is setting them to
57
+ deprecated; nothing is ever deleted. Orphans are hidden while any pair is unreachable.
58
+ - Non-VIP records at a VIP address are listed as conflicts and never changed. Every change is recorded in the
59
+ changelog under the user who applied it, plus a journal entry.
60
+
61
+ This replaces the `netscaler_vip_sync.py` custom script.
62
+
63
+ The plugin never changes NetScaler. It only sends NITRO `GET` requests. The only writes are to NetBox IPAM, and
64
+ only when someone applies a sync.
65
+
66
+ ## How it works
67
+
68
+ 1. For each configured HA pair, the plugin asks the first node that answers which node is
69
+ **Primary** (`config/hanode`), and reads only from the Primary. UP/DOWN health state is only
70
+ authoritative on the Primary, and the Primary changes with every failover.
71
+ 2. It pulls lb vservers, service-group members and GSLB bindings using bulk NITRO calls (about
72
+ 8 requests per pair).
73
+ 3. It caches each pair's inventory in NetBox's cache (default 15 minutes; a Refresh button clears
74
+ it).
75
+ 4. It matches each member IP to NetBox IP addresses, then to the VM or Device they're assigned to,
76
+ when it renders a page.
77
+
78
+ Page loads never wait on NetScaler. The tab's visibility check and badge read the cache only.
79
+
80
+ ## Permissions
81
+
82
+ - The tabs and the Stale VIPs page need view permission on the object or on IP addresses.
83
+ - Sync VIPs: previewing needs `ipam.view_ipaddress`; applying needs `ipam.add_ipaddress` to create and
84
+ `ipam.change_ipaddress` to update or deprecate.
85
+
86
+ ## Requirements
87
+
88
+ - NetBox 4.7.5 or newer
89
+ - A **read-only** NetScaler account with NITRO API access on every node
90
+
91
+ ## Installation
92
+
93
+ ```bash
94
+ pip install netbox-netscaler
95
+ ```
96
+
97
+ Add the plugin to `configuration/plugins.py`:
98
+
99
+ ```python
100
+ import os
101
+
102
+ PLUGINS = ["netbox_netscaler"]
103
+
104
+ PLUGINS_CONFIG = {
105
+ "netbox_netscaler": {
106
+ "username": os.environ.get("NETSCALER_API_USERNAME", ""),
107
+ "password": os.environ.get("NETSCALER_API_PASSWORD", ""),
108
+ "pairs": [
109
+ {"name": "Site A", "nodes": ["ns-a1.example.com", "ns-a2.example.com"]},
110
+ {"name": "Site B", "nodes": ["ns-b1.example.com", "ns-b2.example.com"]},
111
+ # A standalone appliance is a one-node pair:
112
+ # {"name": "Lab", "nodes": ["ns-lab.example.com"]},
113
+ # Per-pair credentials override the defaults:
114
+ # {"name": "DMZ", "nodes": [...], "username": "...", "password": "..."},
115
+ ],
116
+ },
117
+ }
118
+ ```
119
+
120
+ Restart NetBox. No migrations are needed; the plugin has no database models.
121
+
122
+ ## Settings
123
+
124
+ | Setting | Default | Description |
125
+ |---|---|---|
126
+ | `pairs` | `[]` | HA pairs: `{"name", "nodes", "username"?, "password"?}` |
127
+ | `username` / `password` | `""` | Default NITRO credentials |
128
+ | `cache_timeout` | `900` | Seconds to cache each pair's inventory. An unreachable pair is cached for at most 60 s. |
129
+ | `timeout` | `15` | NITRO request timeout in seconds |
130
+ | `verify_ssl` | `False` | Verify NetScaler TLS certificates |
131
+ | `vip_tenant` | `""` | Tenant slug set on VIP records created by Sync VIPs (blank = no tenant) |
132
+ | `tab_weight` | `9005` | Position of the NetScaler tab on object pages |
133
+ | `top_level_menu` | `False` | `True` gives the plugin its own sidebar menu instead of an entry under Plugins |
134
+
135
+ ## Reuse
136
+
137
+ Other code can ask what NetScaler config depends on an object:
138
+
139
+ ```python
140
+ from netbox_netscaler.api import memberships_for
141
+
142
+ for m in memberships_for(vm):
143
+ print(m.vserver.pair, m.vserver.name, m.member.ip, m.last_live, [d for g in m.gslb for d in g.domains])
144
+ ```
145
+
146
+ ## Support
147
+
148
+ If you find this plugin helpful, consider supporting development:
149
+
150
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-support-yellow?style=flat&logo=buy-me-a-coffee)](https://buymeacoffee.com/automatebldrs)
151
+
152
+ ## License
153
+
154
+ Apache-2.0
@@ -0,0 +1,123 @@
1
+ # netbox-netscaler
2
+
3
+ Read-only NetBox plugin that shows which Citrix NetScaler (ADC) VIPs depend on a server, so that
4
+ decommissions stop missing the load balancer.
5
+
6
+ - **NetScaler tab** on every VM and Device with an IP: each lb VIP where the server is a
7
+ service-group member, across all configured HA pairs, with the member state, the GSLB names in
8
+ front of the VIP, and flags:
9
+ - **Last live member**: no other server behind the VIP is UP, so the VIP goes down with this one.
10
+ - **Name mismatch**: the NetScaler server object's name matches neither the NetBox object nor the
11
+ IP's DNS name. This usually means the NetScaler config is wrong or stale.
12
+ - **Ambiguous IP**: more than one NetBox IP record has the member's address.
13
+ - **Stale VIPs** page (Plugins menu): every VIP with no live server behind it. That covers VIPs
14
+ whose members are all DOWN, all on decommissioning or offline objects, or not in NetBox, as well
15
+ as VIPs with no members at all.
16
+
17
+ - **NetScaler tab on IP address pages**: for a VIP, its vservers, members (linked to their NetBox objects)
18
+ and GSLB names; for a member IP, the VIPs it belongs to.
19
+ - **Sync VIPs** page (Plugins menu): compares live VIPs with NetBox IPAM and lets an engineer preview, tick and
20
+ apply changes. Run it whenever you like; there is no schedule.
21
+ - **Create**: VIPs that are UP but have no NetBox IP record. They're created as `/32`, role VIP, attached to
22
+ the pair's current Primary NetScaler VM.
23
+ - **Update**: VIP records whose status, description or attachment no longer matches NetScaler. Each row shows
24
+ old → new values. DNS names are only filled in when blank, never replaced.
25
+ - **Orphaned**: VIP records whose address isn't on any NetScaler. The only action is setting them to
26
+ deprecated; nothing is ever deleted. Orphans are hidden while any pair is unreachable.
27
+ - Non-VIP records at a VIP address are listed as conflicts and never changed. Every change is recorded in the
28
+ changelog under the user who applied it, plus a journal entry.
29
+
30
+ This replaces the `netscaler_vip_sync.py` custom script.
31
+
32
+ The plugin never changes NetScaler. It only sends NITRO `GET` requests. The only writes are to NetBox IPAM, and
33
+ only when someone applies a sync.
34
+
35
+ ## How it works
36
+
37
+ 1. For each configured HA pair, the plugin asks the first node that answers which node is
38
+ **Primary** (`config/hanode`), and reads only from the Primary. UP/DOWN health state is only
39
+ authoritative on the Primary, and the Primary changes with every failover.
40
+ 2. It pulls lb vservers, service-group members and GSLB bindings using bulk NITRO calls (about
41
+ 8 requests per pair).
42
+ 3. It caches each pair's inventory in NetBox's cache (default 15 minutes; a Refresh button clears
43
+ it).
44
+ 4. It matches each member IP to NetBox IP addresses, then to the VM or Device they're assigned to,
45
+ when it renders a page.
46
+
47
+ Page loads never wait on NetScaler. The tab's visibility check and badge read the cache only.
48
+
49
+ ## Permissions
50
+
51
+ - The tabs and the Stale VIPs page need view permission on the object or on IP addresses.
52
+ - Sync VIPs: previewing needs `ipam.view_ipaddress`; applying needs `ipam.add_ipaddress` to create and
53
+ `ipam.change_ipaddress` to update or deprecate.
54
+
55
+ ## Requirements
56
+
57
+ - NetBox 4.7.5 or newer
58
+ - A **read-only** NetScaler account with NITRO API access on every node
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install netbox-netscaler
64
+ ```
65
+
66
+ Add the plugin to `configuration/plugins.py`:
67
+
68
+ ```python
69
+ import os
70
+
71
+ PLUGINS = ["netbox_netscaler"]
72
+
73
+ PLUGINS_CONFIG = {
74
+ "netbox_netscaler": {
75
+ "username": os.environ.get("NETSCALER_API_USERNAME", ""),
76
+ "password": os.environ.get("NETSCALER_API_PASSWORD", ""),
77
+ "pairs": [
78
+ {"name": "Site A", "nodes": ["ns-a1.example.com", "ns-a2.example.com"]},
79
+ {"name": "Site B", "nodes": ["ns-b1.example.com", "ns-b2.example.com"]},
80
+ # A standalone appliance is a one-node pair:
81
+ # {"name": "Lab", "nodes": ["ns-lab.example.com"]},
82
+ # Per-pair credentials override the defaults:
83
+ # {"name": "DMZ", "nodes": [...], "username": "...", "password": "..."},
84
+ ],
85
+ },
86
+ }
87
+ ```
88
+
89
+ Restart NetBox. No migrations are needed; the plugin has no database models.
90
+
91
+ ## Settings
92
+
93
+ | Setting | Default | Description |
94
+ |---|---|---|
95
+ | `pairs` | `[]` | HA pairs: `{"name", "nodes", "username"?, "password"?}` |
96
+ | `username` / `password` | `""` | Default NITRO credentials |
97
+ | `cache_timeout` | `900` | Seconds to cache each pair's inventory. An unreachable pair is cached for at most 60 s. |
98
+ | `timeout` | `15` | NITRO request timeout in seconds |
99
+ | `verify_ssl` | `False` | Verify NetScaler TLS certificates |
100
+ | `vip_tenant` | `""` | Tenant slug set on VIP records created by Sync VIPs (blank = no tenant) |
101
+ | `tab_weight` | `9005` | Position of the NetScaler tab on object pages |
102
+ | `top_level_menu` | `False` | `True` gives the plugin its own sidebar menu instead of an entry under Plugins |
103
+
104
+ ## Reuse
105
+
106
+ Other code can ask what NetScaler config depends on an object:
107
+
108
+ ```python
109
+ from netbox_netscaler.api import memberships_for
110
+
111
+ for m in memberships_for(vm):
112
+ print(m.vserver.pair, m.vserver.name, m.member.ip, m.last_live, [d for g in m.gslb for d in g.domains])
113
+ ```
114
+
115
+ ## Support
116
+
117
+ If you find this plugin helpful, consider supporting development:
118
+
119
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-support-yellow?style=flat&logo=buy-me-a-coffee)](https://buymeacoffee.com/automatebldrs)
120
+
121
+ ## License
122
+
123
+ Apache-2.0
@@ -0,0 +1,39 @@
1
+ """
2
+ NetBox NetScaler Plugin
3
+
4
+ Read-only view of Citrix NetScaler lb VIPs, service group members and GSLB names
5
+ on VirtualMachine and Device detail pages, plus a Stale VIPs report.
6
+ """
7
+
8
+ from netbox.plugins import PluginConfig
9
+
10
+ __version__ = "0.1.0"
11
+
12
+
13
+ class NetScalerConfig(PluginConfig):
14
+ """Plugin configuration for NetBox NetScaler integration."""
15
+
16
+ name = "netbox_netscaler"
17
+ verbose_name = "NetScaler"
18
+ description = "Show NetScaler VIPs, service group members and GSLB names that depend on a VM or device"
19
+ version = __version__
20
+ author = "Jeremy Worden"
21
+ author_email = "jeremy.worden@gmail.com"
22
+ base_url = "netscaler"
23
+ min_version = "4.7.5"
24
+ max_version = "5.99"
25
+ required_settings = []
26
+ default_settings = {
27
+ "top_level_menu": False,
28
+ "tab_weight": 9005,
29
+ "username": "",
30
+ "password": "",
31
+ "pairs": [],
32
+ "cache_timeout": 900,
33
+ "timeout": 15,
34
+ "verify_ssl": False,
35
+ "vip_tenant": "",
36
+ }
37
+
38
+
39
+ config = NetScalerConfig
@@ -0,0 +1,17 @@
1
+ """Reuse hook: what NetScaler config depends on a NetBox VM or Device."""
2
+
3
+ from functools import lru_cache
4
+
5
+ from .cache import get_inventories
6
+ from .matching import Membership, memberships_for_ips
7
+ from .resolve import ips_for_object, object_key, resolve_ip
8
+
9
+
10
+ def memberships_for(obj, inventories=None) -> list[Membership]:
11
+ """Every lb vserver membership (with GSLB names) for one VirtualMachine or Device."""
12
+ ips = ips_for_object(obj)
13
+ if not ips:
14
+ return []
15
+ inventories = get_inventories() if inventories is None else inventories
16
+ resolve = lru_cache(maxsize=None)(resolve_ip) # per call, so NetBox status changes show up
17
+ return memberships_for_ips(ips, object_key(obj), inventories, resolve)
@@ -0,0 +1,52 @@
1
+ """Per-pair inventory cache (option A: live fetch + Django cache)."""
2
+
3
+ from concurrent.futures import ThreadPoolExecutor
4
+
5
+ from django.conf import settings
6
+ from django.core.cache import cache
7
+
8
+ from .inventory import PairInventory, fetch_pair
9
+
10
+ PLUGIN = "netbox_netscaler"
11
+
12
+
13
+ def plugin_settings() -> dict:
14
+ from . import NetScalerConfig
15
+
16
+ merged = dict(NetScalerConfig.default_settings)
17
+ merged.update(settings.PLUGINS_CONFIG.get(PLUGIN, {}))
18
+ return merged
19
+
20
+
21
+ def _key(pair: dict) -> str:
22
+ return f"{PLUGIN}:pair:{pair.get('name')}"
23
+
24
+
25
+ def get_inventories(force: bool = False) -> list[PairInventory]:
26
+ """Inventories for every configured pair, fetching (in parallel) any that are not cached."""
27
+ conf = plugin_settings()
28
+ pairs = conf.get("pairs") or []
29
+ cached = {} if force else cache.get_many([_key(p) for p in pairs])
30
+ missing = [p for p in pairs if _key(p) not in cached]
31
+ if missing:
32
+ with ThreadPoolExecutor(max_workers=len(missing)) as pool:
33
+ fetched = list(pool.map(lambda p: fetch_pair(p, conf), missing))
34
+ for pair, inv in zip(missing, fetched):
35
+ # Unavailable results are cached briefly so a dead pair doesn't stall every page.
36
+ timeout = conf["cache_timeout"] if inv.available else min(60, conf["cache_timeout"])
37
+ cache.set(_key(pair), inv, timeout)
38
+ cached[_key(pair)] = inv
39
+ return [cached[_key(p)] for p in pairs]
40
+
41
+
42
+ def cached_inventories() -> list[PairInventory] | None:
43
+ """Cache-only read: never contacts NetScaler. None if any pair is not cached."""
44
+ pairs = plugin_settings().get("pairs") or []
45
+ cached = cache.get_many([_key(p) for p in pairs])
46
+ if len(cached) != len(pairs):
47
+ return None
48
+ return [cached[_key(p)] for p in pairs]
49
+
50
+
51
+ def clear() -> None:
52
+ cache.delete_many([_key(p) for p in plugin_settings().get("pairs") or []])