networkmgmt 0.0.2__tar.gz → 0.0.3__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 (80) hide show
  1. networkmgmt-0.0.3/PKG-INFO +552 -0
  2. networkmgmt-0.0.3/README.md +515 -0
  3. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/__init__.py +1 -1
  4. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/__main__.py +2 -3
  5. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/categorize.py +0 -3
  6. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/cli.py +60 -12
  7. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/lldp.py +1 -1
  8. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/scanner.py +5 -3
  9. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/snmp.py +68 -181
  10. networkmgmt-0.0.3/networkmgmt/snmp/__init__.py +55 -0
  11. networkmgmt-0.0.3/networkmgmt/snmp/credentials.py +92 -0
  12. networkmgmt-0.0.3/networkmgmt/snmp/errors.py +65 -0
  13. networkmgmt-0.0.3/networkmgmt/snmp/polling.py +39 -0
  14. networkmgmt-0.0.3/networkmgmt/snmp/portlist.py +51 -0
  15. networkmgmt-0.0.3/networkmgmt/snmp/session.py +466 -0
  16. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/snmp_vlan_dump/_util.py +36 -0
  17. networkmgmt-0.0.3/networkmgmt/snmp_vlan_dump/cli.py +152 -0
  18. networkmgmt-0.0.3/networkmgmt/snmp_vlan_dump/collector.py +218 -0
  19. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/snmp_vlan_dump/formatters.py +11 -1
  20. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/snmp_vlan_dump/models.py +3 -0
  21. networkmgmt-0.0.3/networkmgmt/snmp_vlan_dump/snmp.py +69 -0
  22. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/__init__.py +0 -1
  23. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/cli.py +153 -55
  24. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/__init__.py +1 -0
  25. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/netgear/__init__.py +1 -1
  26. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/backend.py +141 -0
  27. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/client.py +196 -0
  28. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/models.py +120 -0
  29. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/oids.py +97 -0
  30. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/routing.py +391 -0
  31. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/snmp_managers.py +557 -0
  32. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear/web.py +225 -0
  33. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear_plus/__init__.py +5 -0
  34. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear_plus/client.py +101 -0
  35. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear_plus/managers.py +508 -0
  36. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/netgear_plus/sdk.py +223 -0
  37. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/qnap/client.py +51 -14
  38. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/qnap/rest.py +174 -20
  39. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/qnap/utils.py +117 -0
  40. networkmgmt-0.0.3/networkmgmt/switchctrl/vendors/qnap/vlan_rest.py +314 -0
  41. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/pyproject.toml +42 -10
  42. networkmgmt-0.0.2/PKG-INFO +0 -370
  43. networkmgmt-0.0.2/README.md +0 -340
  44. networkmgmt-0.0.2/networkmgmt/snmp_vlan_dump/cli.py +0 -92
  45. networkmgmt-0.0.2/networkmgmt/snmp_vlan_dump/collector.py +0 -191
  46. networkmgmt-0.0.2/networkmgmt/snmp_vlan_dump/snmp.py +0 -103
  47. networkmgmt-0.0.2/networkmgmt/switchctrl/vendors/netgear/client.py +0 -47
  48. networkmgmt-0.0.2/networkmgmt/switchctrl/vendors/qnap/utils.py +0 -21
  49. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/.gitignore +0 -0
  50. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/LICENSE.md +0 -0
  51. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/__init__.py +0 -0
  52. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/_util.py +0 -0
  53. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/mermaid.py +0 -0
  54. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/models.py +0 -0
  55. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/discovery/oui.py +0 -0
  56. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/snmp_vlan_dump/__init__.py +0 -0
  57. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/snmp_vlan_dump/mermaid.py +0 -0
  58. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/base/__init__.py +0 -0
  59. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/base/client.py +0 -0
  60. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/base/managers.py +0 -0
  61. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/base/transport.py +0 -0
  62. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/exceptions.py +0 -0
  63. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/factory.py +0 -0
  64. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/models/__init__.py +0 -0
  65. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/models/port.py +0 -0
  66. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/models/stats.py +0 -0
  67. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/models/system.py +0 -0
  68. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/models/vlan.py +0 -0
  69. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/cisco/__init__.py +0 -0
  70. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/cisco/client.py +1 -1
  71. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/cisco/managers.py +0 -0
  72. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/common/__init__.py +0 -0
  73. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/common/cisco_cli.py +0 -0
  74. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/common/cisco_managers.py +0 -0
  75. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/mikrotik/__init__.py +0 -0
  76. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/mikrotik/client.py +0 -0
  77. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/mikrotik/managers.py +0 -0
  78. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/mikrotik/rest.py +0 -0
  79. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/mikrotik/ssh.py +0 -0
  80. {networkmgmt-0.0.2 → networkmgmt-0.0.3}/networkmgmt/switchctrl/vendors/qnap/__init__.py +0 -0
@@ -0,0 +1,552 @@
1
+ Metadata-Version: 2.4
2
+ Name: networkmgmt
3
+ Version: 0.0.3
4
+ Summary: Multi-vendor network management toolkit — topology discovery, switch control, and VLAN management
5
+ Project-URL: Homepage, https://github.com/vroomfondel/networkmgmt
6
+ Project-URL: Repository, https://github.com/vroomfondel/networkmgmt
7
+ Project-URL: Issues, https://github.com/vroomfondel/networkmgmt
8
+ Author-email: Henning Thieß <ht@xomox.cc>
9
+ License-File: LICENSE.md
10
+ Keywords: ansible,cisco,discovery,lldp,management,mikrotik,netgear,network,qnap,snmp,switch,topology,vlan
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: System :: Networking
17
+ Classifier: Topic :: System :: Networking :: Monitoring
18
+ Classifier: Topic :: System :: Systems Administration
19
+ Requires-Python: >=3.14
20
+ Requires-Dist: loguru>=0.7.3
21
+ Requires-Dist: paramiko>=5.1.0
22
+ Requires-Dist: pydantic>=2.14.2
23
+ Requires-Dist: pyyaml>=6.0.3
24
+ Requires-Dist: requests>=2.34.2
25
+ Requires-Dist: tabulate>=0.10.0
26
+ Provides-Extra: all
27
+ Requires-Dist: netgear-tool>=0.2.0; extra == 'all'
28
+ Requires-Dist: pysnmp>=7.1.30; extra == 'all'
29
+ Requires-Dist: scapy>=2.8.0; extra == 'all'
30
+ Provides-Extra: discovery
31
+ Requires-Dist: scapy>=2.8.0; extra == 'discovery'
32
+ Provides-Extra: netgear-plus
33
+ Requires-Dist: netgear-tool>=0.2.0; extra == 'netgear-plus'
34
+ Provides-Extra: snmp
35
+ Requires-Dist: pysnmp>=7.1.30; extra == 'snmp'
36
+ Description-Content-Type: text/markdown
37
+
38
+ [![black-lint](https://github.com/vroomfondel/networkmgmt/actions/workflows/checkblack.yml/badge.svg)](https://github.com/vroomfondel/networkmgmt/actions/workflows/checkblack.yml)
39
+ [![mypy and pytests](https://github.com/vroomfondel/networkmgmt/actions/workflows/mypynpytests.yml/badge.svg)](https://github.com/vroomfondel/networkmgmt/actions/workflows/mypynpytests.yml)
40
+ [![BuildAndPushMultiarch](https://github.com/vroomfondel/networkmgmt/actions/workflows/buildmultiarchandpush.yml/badge.svg)](https://github.com/vroomfondel/networkmgmt/actions/workflows/buildmultiarchandpush.yml)
41
+ ![Cumulative Clones](https://img.shields.io/endpoint?logo=github&url=https://gist.githubusercontent.com/vroomfondel/906f5c4deb7e6e6bcd6ee0f7c96f586c/raw/networkmgmt_clone_count.json)
42
+ [![Docker Pulls](https://img.shields.io/docker/pulls/xomoxcc/networkmgmt?logo=docker)](https://hub.docker.com/r/xomoxcc/networkmgmt/tags)
43
+ [![PyPI](https://img.shields.io/pypi/v/networkmgmt?logo=python&logoColor=white)](https://pypi.org/project/networkmgmt/)
44
+
45
+ [![Gemini_Generated_Image_8bu6gi8bu6gi8bu6_250x250.png](https://raw.githubusercontent.com/vroomfondel/networkmgmt/main/Gemini_Generated_Image_8bu6gi8bu6gi8bu6_250x250.png)](https://hub.docker.com/r/xomoxcc/networkmgmt/tags)
46
+
47
+ # WIP !!!
48
+
49
+ # networkmgmt — Network Management Toolkit
50
+
51
+ CLI tool and Python library for multi-vendor switch management and network topology discovery.
52
+
53
+ Quick links:
54
+ - [Docker Hub](https://hub.docker.com/r/xomoxcc/networkmgmt/tags) — multi-arch image (amd64/arm64)
55
+ - [PyPI](https://pypi.org/project/networkmgmt/) — `pip install networkmgmt`
56
+ - [GitHub](https://github.com/vroomfondel/networkmgmt) — source, issues, CI
57
+
58
+ ## Modules
59
+
60
+ | Module | Description |
61
+ |--------------------------------|---------------------------------------------------------------------------|
62
+ | **networkmgmt.switchctrl** | Multi-vendor switch management (Cisco, MikroTik, QNAP, Netgear Pro/Plus) |
63
+ | **networkmgmt.snmp** | Shared SNMPv2c/v3 core (optional `pysnmp`) used by the Netgear Pro vendor |
64
+ | **networkmgmt.discovery** | Network topology discovery (ARP, DNS, SNMP, LLDP, nmap, traceroute) |
65
+ | **networkmgmt.snmp_vlan_dump** | SNMP VLAN-port dump for Netgear switches |
66
+
67
+ ## Supported Switch Vendors
68
+
69
+ | Vendor | Model(s) | Transport | Notes |
70
+ |------------------|-------------------------------------------------------|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
71
+ | **cisco** | Catalyst 1200 (C1200-8T-D) | SSH CLI only | 8 GE ports (`gi1`–`gi8`), no REST API, enable password required |
72
+ | **mikrotik** | RouterOS v7+ switches | REST API + SSH CLI | REST for monitoring, SSH for configuration |
73
+ | **qnap** | QSW-M408 series | REST API + SSH CLI | Monitoring and VLAN via REST (declarative `apply_port_membership`, 0.3 s request delay), port/LACP via Cisco-style SSH CLI; no PVID |
74
+ | **netgear** | Smart Managed Pro: S3300 stack, GS108Tv2, M4300 class | SNMPv3 (v2c fallback), web UI for static routes only | VLAN incl. PVID, port admin, LAG read-only, routing interfaces, management IP, static routes, `save_config()` |
75
+ | **netgear_plus** | Smart Managed Plus: GS105E, GS108E, GS305E | Web UI via optional `netgear-tool` | Declarative 802.1Q incl. removal, PVID, port admin; no LACP, no sensors |
76
+
77
+ ## CLI Structure
78
+
79
+ `networkmgmt` is an orchestrator that dispatches to three sub-CLIs. Each sub-CLI can also be invoked directly:
80
+
81
+ | Orchestrator command | Direct script | Description |
82
+ |------------------------------|--------------------------|--------------------------------|
83
+ | `networkmgmt switchctrl ...` | `networkmgmt-switchctrl` | Multi-vendor switch management |
84
+ | `networkmgmt discover ...` | `networkmgmt-discover` | Network topology discovery |
85
+ | `networkmgmt vlan-dump ...` | `networkmgmt-vlan-dump` | SNMP VLAN-port dump |
86
+
87
+ ## Installation
88
+
89
+ ```bash
90
+ pip install .
91
+ ```
92
+
93
+ Optional extras:
94
+
95
+ ```bash
96
+ pip install networkmgmt[snmp] # pysnmp: netgear (Smart Managed Pro) vendor
97
+ pip install networkmgmt[netgear-plus] # netgear-tool: netgear_plus (Smart Managed Plus) vendor
98
+ pip install networkmgmt[discovery] # scapy: ARP scan in networkmgmt-discover
99
+ pip install networkmgmt[all] # everything above
100
+ ```
101
+
102
+ ## Network Topology Discovery
103
+
104
+ Discover local network topology via ARP scanning, reverse DNS, MAC vendor lookup, SNMP bridge tables, LLDP, optional nmap service detection, and traceroute. Outputs Mermaid flowcharts or JSON.
105
+
106
+ ### CLI
107
+
108
+ ```bash
109
+ # Basic discovery (auto-detect interface)
110
+ networkmgmt-discover -i eth0
111
+ # or: networkmgmt discover -i eth0
112
+
113
+ # With nmap service detection (requires root for ARP scan)
114
+ sudo networkmgmt-discover -i eth0 --nmap -o topology.md
115
+
116
+ # JSON output
117
+ networkmgmt-discover -i eth0 --format json -o topology.json
118
+
119
+ # Multi-subnet scan
120
+ networkmgmt-discover -i eth0,vlan100 -o multi.md
121
+
122
+ # SNMP L2 topology (query switch MAC tables), SNMPv2c per switch
123
+ networkmgmt-discover -i eth0 --switches 192.0.2.38:public,192.0.2.19
124
+
125
+ # SNMPv3 for every switch without :community (v2c entries can be mixed in)
126
+ networkmgmt-discover -i eth0 --switches 192.0.2.38,192.0.2.150,192.0.2.19:public \
127
+ --snmp-user admin --snmp-auth-key 'AUTHPASS' --snmp-auth-protocol sha512
128
+
129
+ # LLDP-based topology
130
+ networkmgmt-discover -i eth0 --lldp-collect /tmp/lldp
131
+
132
+ # Manual topology + diagram style
133
+ networkmgmt-discover -i eth0 --topology 192.0.2.50:192.0.2.19:g3 -d hierarchical
134
+
135
+ # Traceroute to external targets
136
+ networkmgmt-discover -i eth0 -t 8.8.8.8,1.1.1.1
137
+ sudo networkmgmt-discover -i eth0 -t 192.0.2.0/24
138
+ ```
139
+
140
+ ### Discovery Options
141
+
142
+ | Option | Description |
143
+ |--------------------------|--------------------------------------------------------------------------------|
144
+ | `-i` / `--interface` | Network interface(s), comma-separated (default: auto-detect) |
145
+ | `-t` / `--targets` | Traceroute targets: IPs, CIDR (`192.168.1.0/24`), or range (`192.168.1.1-254`) |
146
+ | `--nmap` | Enable nmap service detection |
147
+ | `--top-ports` | nmap top ports to scan (default: 100) |
148
+ | `-o` / `--output` | Output file (default: stdout) |
149
+ | `--format` | `mermaid` (default) or `json` |
150
+ | `--timeout` | Scan timeout in seconds (default: 10) |
151
+ | `--max-hops` | Max traceroute hops (default: 30) |
152
+ | `--trace-local` | Tracepath to all LAN hosts to detect switch hierarchy |
153
+ | `--switches` | SNMP L2 discovery: `IP[:community],...` (default community: `public`) |
154
+ | `--snmp-user` | SNMPv3 user for `--switches` entries without `:community` |
155
+ | `--snmp-auth-key` | SNMPv3 auth passphrase (or `$SNMP_AUTH_KEY`) |
156
+ | `--snmp-auth-protocol` | `md5`, `sha`, `sha256`, `sha512` (default) |
157
+ | `--snmp-priv-key` | SNMPv3 privacy passphrase (or `$SNMP_PRIV_KEY`); unset = authNoPriv |
158
+ | `--snmp-priv-protocol` | `des`, `aes128` (default) |
159
+ | `--snmp-timeout` | SNMP timeout per request in seconds (default: 5) |
160
+ | `--snmp-retries` | SNMP retries per request (default: 1) |
161
+ | `--lldp-collect` | SSH into hosts, collect lldpctl JSON to directory |
162
+ | `--lldp-dir` | Read existing LLDP JSON files from directory |
163
+ | `--topology` | Manual L2 topology: `HOST:SWITCH:PORT,...` |
164
+ | `-d` / `--diagram-style` | `auto` (default), `flat`, `categorized`, `hierarchical` |
165
+ | `--direction` | Mermaid flowchart direction: `LR` or `TD` (default: auto) |
166
+ | `--elk` | Use ELK layout engine for large diagrams |
167
+ | `-v` / `--verbose` | Verbose logging |
168
+
169
+ ### Python Library Usage (Discovery)
170
+
171
+ ```python
172
+ from networkmgmt.discovery import NetworkTopologyScanner, MermaidGenerator
173
+
174
+ scanner = NetworkTopologyScanner(interfaces=["eth0"], use_nmap=True)
175
+ topology = scanner.run_discovery()
176
+
177
+ # Generate Mermaid diagram
178
+ gen = MermaidGenerator(topology, diagram_style="hierarchical")
179
+ print(gen.generate())
180
+
181
+ # Or export as JSON
182
+ print(topology.model_dump_json(indent=2))
183
+ ```
184
+
185
+ ## SNMP VLAN Dump
186
+
187
+ Dumps VLAN membership (tagged/untagged), PVIDs and link state per port from Q-BRIDGE-MIB capable switches (tested on Netgear S3300 stacks and GS108Tv2) as a terminal table, Markdown or Mermaid diagram.
188
+
189
+ ```bash
190
+ # SNMPv2c
191
+ networkmgmt vlan-dump 192.0.2.38 public
192
+ networkmgmt vlan-dump 192.0.2.38 public -m -o s3300.md -d trunks
193
+
194
+ # SNMPv3 (defaults sha512/aes128; authNoPriv when --snmp-priv-key is missing)
195
+ networkmgmt vlan-dump 192.0.2.38 --snmp-user admin --snmp-auth-key 'AUTHPASS'
196
+
197
+ # GS108Tv2: the web login is the SNMPv3 user, md5/sha + des only
198
+ networkmgmt vlan-dump 192.0.2.150 --snmp-user admin --snmp-auth-key 'WEBPASS' \
199
+ --snmp-auth-protocol sha --snmp-priv-key 'WEBPASS' --snmp-priv-protocol des
200
+
201
+ SNMP_AUTH_KEY='AUTHPASS' networkmgmt vlan-dump 192.0.2.38 --snmp-user admin --snmp-timeout 10 --snmp-retries 2
202
+ ```
203
+
204
+ - Factory VLANs (1, 2 Voice, 3 Auto-Video on the GS108Tv2) are missing from `dot1qVlanStaticTable`; the dump merges them in from `dot1qVlanCurrentTable`, static entries win.
205
+ - Stack links (S3300) show up in the VLAN 1 bitmap but are not bridge ports; they are listed in a note line and left out of tables and diagrams.
206
+ - A wrong user or key is reported as `SNMP authentication failed`. With SNMPv3 this often surfaces only as a timeout, so the message names user, auth and privacy settings as the likely cause.
207
+
208
+ ## Switch Management CLI
209
+
210
+ ```bash
211
+ networkmgmt-switchctrl --vendor <VENDOR> --host <IP> --password <PW> [options] <command>
212
+ # or: networkmgmt switchctrl --vendor <VENDOR> --host <IP> --password <PW> [options] <command>
213
+ ```
214
+
215
+ ### Global Options
216
+
217
+ | Option | Description |
218
+ |---------------------|------------------------------------------------------------------------------------|
219
+ | `--vendor` | Switch vendor (`cisco`, `mikrotik`, `netgear`, `netgear_plus`, `qnap`) |
220
+ | `--host` | Switch IP address or hostname |
221
+ | `--password` | Admin password (required except for `netgear` with `--community` or `--snmp-user`) |
222
+ | `--username` | Username (default: `admin`; `netgear`: alias for `--snmp-user`) |
223
+ | `--enable-password` | Enable password (Cisco: required; QNAP: auto-generated if omitted) |
224
+ | `--ssh-port` | SSH port (default: 22) |
225
+ | `--rest-port` | REST API port (default: 443) |
226
+ | `--ssh-username` | SSH username (vendor-specific default if omitted) |
227
+ | `--ssh-password` | SSH password (vendor-specific default if omitted) |
228
+ | `--verify-ssl` | Verify SSL certificates for REST API |
229
+ | `-v` / `--verbose` | Enable debug logging |
230
+
231
+ ### Commands
232
+
233
+ ### Vendor Options
234
+
235
+ All options are command-line flags; each is rejected for vendors it does not belong to.
236
+
237
+ | Option | Vendor | Description |
238
+ |-------------------------------------------|--------------|------------------------------------------------------------------------------|
239
+ | `--community` | netgear | SNMPv2c community (fallback when no `--snmp-user` is given) |
240
+ | `--snmp-user` | netgear | SNMPv3 user |
241
+ | `--auth-key` | netgear | SNMPv3 authentication passphrase (default: `--password`) |
242
+ | `--auth-protocol {md5,sha,sha256,sha512}` | netgear | SNMPv3 authentication protocol (default: `sha512`; GS108Tv2: `md5` or `sha`) |
243
+ | `--priv-key` | netgear | SNMPv3 privacy passphrase (omit for authNoPriv) |
244
+ | `--priv-protocol {des,aes128}` | netgear | SNMPv3 privacy protocol (default: `aes128`; GS108Tv2: `des`) |
245
+ | `--web-password` | netgear | Web UI password for static routes (default: `--password`) |
246
+ | `--password` | netgear_plus | Web UI password (the only option this vendor needs) |
247
+ | `--vlan-backend {rest,ssh}` | qnap | VLAN backend (default: `rest`; `ssh` if SSH options are given) |
248
+ | `--rest-delay` | qnap | Seconds between REST requests (default: 0.3) |
249
+
250
+ #### `monitor` — Show system info, sensors, ports, and LACP status
251
+
252
+ Sections a vendor does not implement (Netgear sensors, LACP on `netgear_plus`) are reported as not supported and skipped; the rest is still printed.
253
+
254
+ ```bash
255
+ # Cisco Catalyst 1200
256
+ networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
257
+ --username admin --password <PW> --enable-password <EN> monitor
258
+
259
+ # QNAP QSW
260
+ networkmgmt-switchctrl --vendor qnap --host 192.168.1.1 --password <PW> monitor
261
+
262
+ # Netgear Smart Managed Pro, SNMPv3 (S3300: sha512 + aes128 are the defaults)
263
+ networkmgmt-switchctrl --vendor netgear --host 192.168.1.38 --snmp-user monitor \
264
+ --auth-key <AUTH> --priv-key <PRIV> monitor
265
+
266
+ # Netgear GS108Tv2: web login is the SNMPv3 user, md5/sha + des only
267
+ networkmgmt-switchctrl --vendor netgear --host 192.168.1.150 --snmp-user admin \
268
+ --auth-key <WEBPW> --auth-protocol sha --priv-key <WEBPW> --priv-protocol des monitor
269
+
270
+ # Netgear, SNMPv2c
271
+ networkmgmt-switchctrl --vendor netgear --host 192.168.1.38 --community public vlan list
272
+
273
+ # Netgear Smart Managed Plus
274
+ networkmgmt-switchctrl --vendor netgear_plus --host 192.168.1.5 --password <PW> vlan list
275
+ ```
276
+
277
+ #### `vlan` — VLAN management
278
+
279
+ ```bash
280
+ # Create VLAN
281
+ networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
282
+ --username admin --password <PW> --enable-password <EN> \
283
+ vlan create 100 --name servers
284
+
285
+ # List VLANs
286
+ networkmgmt-switchctrl --vendor cisco ... vlan list
287
+
288
+ # Delete VLAN
289
+ networkmgmt-switchctrl --vendor cisco ... vlan delete 100
290
+ ```
291
+
292
+ #### `port` — Port configuration
293
+
294
+ ```bash
295
+ # Configure port (Cisco uses gi1-gi8, QNAP uses GigabitEthernet1/0/1)
296
+ networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
297
+ --username admin --password <PW> --enable-password <EN> \
298
+ port config gi1 --speed 1000 --duplex full
299
+
300
+ # Disable a port
301
+ networkmgmt-switchctrl --vendor cisco ... port config gi3 --shutdown
302
+ ```
303
+
304
+ #### `example` — Quick connectivity test
305
+
306
+ ```bash
307
+ networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
308
+ --username admin --password <PW> --enable-password <EN> example
309
+ ```
310
+
311
+ ## Python Library Usage (Switch Management)
312
+
313
+ ```python
314
+ from networkmgmt import create_switch
315
+
316
+ # Cisco Catalyst 1200
317
+ with create_switch(
318
+ "cisco",
319
+ host="192.168.1.254",
320
+ username="admin",
321
+ password="mypass",
322
+ enable_password="myenable",
323
+ ) as switch:
324
+ switch.enable()
325
+
326
+ # Monitoring
327
+ info = switch.monitoring.get_system_info()
328
+ print(f"{info.model} — FW {info.firmware_version}")
329
+
330
+ sensors = switch.monitoring.get_sensor_data()
331
+ print(f"Temperature: {sensors.temperature}°C")
332
+
333
+ ports = switch.monitoring.get_port_status()
334
+ for p in ports:
335
+ print(f" {p.port}: {'UP' if p.link_up else 'DOWN'}")
336
+
337
+ # VLAN management (uses 'vlan database' mode on C1200)
338
+ switch.vlan.create_vlan(100, "servers")
339
+ switch.vlan.assign_port_to_vlan("gi3", 100)
340
+
341
+ # LACP (uses 'mode auto' on C1200)
342
+ switch.lacp.create_port_channel(1, ["gi5", "gi6"])
343
+ ```
344
+
345
+ ```python
346
+ # QNAP QSW
347
+ with create_switch("qnap", host="192.168.1.1", password="admin123") as switch:
348
+ switch.enable() # auto-generates enable password from serial
349
+ info = switch.monitoring.get_system_info()
350
+ print(info.model)
351
+
352
+ # QNAP QSW: declarative VLAN reconcile over REST
353
+ from networkmgmt.switchctrl.vendors.qnap.vlan_rest import PortMembership
354
+
355
+ with create_switch("qnap", host="192.168.1.1", password="admin123", rest_delay=0.3) as switch:
356
+ result = switch.rest_vlan.apply_port_membership(
357
+ [1, 100],
358
+ {"3": PortMembership(untagged=100), "4": PortMembership(tagged=[100])},
359
+ protect_ports=["11"],
360
+ )
361
+ print(result)
362
+ ```
363
+
364
+ ```python
365
+ # Netgear Smart Managed Pro (S3300 stack) over SNMPv3 — needs networkmgmt[snmp]
366
+ with create_switch(
367
+ "netgear",
368
+ host="192.168.1.38",
369
+ snmp_user="monitor",
370
+ auth_key="authpass",
371
+ priv_key="privpass",
372
+ web_password="webpass", # only for static routes
373
+ ) as switch:
374
+ print(switch.monitoring.get_system_info().model)
375
+
376
+ switch.vlan.create_vlan(20, "iot")
377
+ switch.vlan.assign_port_to_vlan("1/g5", 20) # untagged; also sets the PVID
378
+ switch.port.disable_port("1/g6")
379
+
380
+ routing = switch.routing
381
+ routing.set_interface(20, "192.168.20.1/24")
382
+ routing.add_static_route("10.9.0.0/16", "192.168.20.254")
383
+
384
+ switch.save_config() # running -> startup, otherwise lost on reboot
385
+ ```
386
+
387
+ ```python
388
+ # Netgear Smart Managed Plus (GS105E/GS108E/GS305E) — needs networkmgmt[netgear-plus]
389
+ from networkmgmt.switchctrl.vendors.netgear_plus.managers import PortVlanSpec
390
+
391
+ with create_switch("netgear_plus", host="192.168.1.5", password="secret") as switch:
392
+ plan = switch.vlan.reconcile(
393
+ [1, 20, 101],
394
+ {
395
+ 1: PortVlanSpec(untagged=1, tagged=[20, 101]),
396
+ 2: PortVlanSpec(untagged=20), # untagged also sets the PVID
397
+ },
398
+ purge_vlans=True,
399
+ )
400
+ print(plan.render(), plan.changed)
401
+ ```
402
+
403
+ ## Vendor-Specific Notes
404
+
405
+ ### Cisco Catalyst 1200 (C1200-8T-D)
406
+
407
+ - **SSH only** — no REST API available
408
+ - **Port names**: `gi1` through `gi8` (not `GigabitEthernet1/0/1`)
409
+ - **Enable password required** — no auto-generation, C1200 enforces password change on first login
410
+ - **VLAN creation** uses `vlan database` mode (not `configure terminal` > `vlan {id}`)
411
+ - **LACP** uses `channel-group {id} mode auto` (not `mode active`)
412
+ - **Fanless** — PoE-powered, `get_sensor_data()` always returns `fan_speed=0`
413
+
414
+ ### QNAP QSW
415
+
416
+ - **Dual transport** — REST API for monitoring and VLANs, SSH (Cisco-style CLI) for port/LACP configuration
417
+ - **VLAN backend** — REST by default (`vlan_backend="rest"`); SSH if `ssh_username`, `ssh_password` or `enable_password` is given (or `vlan_backend="ssh"`)
418
+ - **Serialised REST** — `rest_delay` (default 0.3 s) between requests
419
+ - **Enable password** can be auto-generated from the switch serial number
420
+ - **Default SSH credentials**: `guest` / `guest123`
421
+ - **No PVID** — the untagged membership is the native/access VLAN, so at most one per port
422
+
423
+ ### Netgear Smart Managed Pro (`netgear`)
424
+
425
+ - **SNMP** — SNMPv3 (`snmp_user`, `auth_key`, `priv_key`) preferred, SNMPv2c (`community`) as fallback; needs `pysnmp` (`networkmgmt[snmp]`)
426
+ - **Models** — S3300 stack, GS108Tv2, M4300 class; port names are `<unit>/g<n>`
427
+ - **Managers** — VLAN incl. PVID, port admin state, LAG read-only, stack units/ports; sensors and LAG changes raise `NotImplementedError`
428
+ - **`switch.routing`** — VLAN routing interfaces, management IP/gateway and static routes; static routes need `web_password` (web UI)
429
+ - **`switch.save_config()`** — writes are running-config only until saved
430
+ - **Writes are verified** — every write is polled until the read-back shows it
431
+
432
+ ### Netgear Smart Managed Plus (`netgear_plus`)
433
+
434
+ - **Web UI** via the optional `netgear-tool` package (`networkmgmt[netgear-plus]`); single web session, use the client as a context manager
435
+ - **Models** — GS105E, GS108E, GS305E; ports are 1-based numbers
436
+ - **VLAN** — declarative `switch.vlan.reconcile(...)` (create, edit, PVID, delete, read-back check), `ensure_vlan`, `ensure_vlan_absent`, `ensure_port_vlans`
437
+ - **802.1Q mode** must be enabled on the switch; no LACP, no sensors (`NotImplementedError`)
438
+
439
+ ### MikroTik
440
+
441
+ - **Dual transport** — REST API (RouterOS v7+) for monitoring, SSH for configuration
442
+ - **No enable mode** — RouterOS uses direct admin access
443
+
444
+ ## Hardware quirks
445
+
446
+ - **GS108T SNMPv3** — the user is the web login (`admin`, auth key = web password) and only `md5`/`sha` with `des` work.
447
+ - **Delayed writes** — SNMP and REST writes take effect with delay, so every write is verified by polling the read-back.
448
+ - **One varbind per PDU** — VLAN writes on Netgear Pro are sent as single-varbind SETs; bundled varbinds are rejected with `commitFailed`.
449
+ - **Factory VLANs** — Netgear Pro lists default VLANs only in the Q-BRIDGE current table, not in the static table.
450
+ - **Untagged mask** — patch the Netgear Pro untagged port list bit by bit; clearing the CPU-port bit (13 on the GS108T) blocks every later untagged change of that VLAN, cleared bits of regular ports are harmless.
451
+ - **Stack links** — Netgear Pro stack ports are not bridge ports and are rejected as VLAN members.
452
+ - **Save** — Netgear Pro persists the config via `agentSaveConfig` under `4526.11` (not `4526.10`).
453
+ - **Static routes** — Netgear Pro accepts them only through the web UI (SNMP writes fail with `commitFailed`), which allows at most 4 sessions.
454
+ - **Plus VLANs** — `untagged` also sets the PVID, and 802.1Q mode must be on.
455
+ - **QNAP backend** — bursts of REST requests crash the switch backend (fork ENOMEM), so requests are serialised; avoid `lldp/neighbors/status`; there is no PVID.
456
+
457
+ ## Ansible modules
458
+
459
+ The `ansible/` directory contains stand-alone Ansible modules (no collection packaging) for Netgear Smart Managed Plus and Pro switches and QNAP QSW switches. They encode the same hardware findings as `networkmgmt.switchctrl`, but target playbooks: declarative, idempotent, with check mode and diff. See [ansible/README.md](https://github.com/vroomfondel/networkmgmt/blob/main/ansible/README.md).
460
+
461
+ ## Architecture
462
+
463
+ ```
464
+ networkmgmt/
465
+ ├── __init__.py # Public API: create_switch(), list_vendors()
466
+ ├── __main__.py # Orchestrator CLI — dispatches to sub-CLIs
467
+ ├── snmp/ # Shared SNMP core (optional pysnmp): credentials, session, polling, portlists
468
+ ├── switchctrl/ # Multi-vendor switch management
469
+ │ ├── __init__.py # Re-exports: create_switch, list_vendors, SwitchError
470
+ │ ├── cli.py # Switch management CLI (networkmgmt-switchctrl)
471
+ │ ├── factory.py # Vendor registry and factory
472
+ │ ├── exceptions.py # Exception hierarchy
473
+ │ ├── base/ # Abstract base classes
474
+ │ │ ├── client.py # BaseSwitchClient
475
+ │ │ ├── managers.py # BaseMonitoringManager, BaseVLANManager, ...
476
+ │ │ └── transport.py # BaseTransport
477
+ │ ├── models/ # Dataclasses (vendor-agnostic)
478
+ │ │ ├── port.py # PortConfig, PortStatus, PortSpeed, ...
479
+ │ │ ├── vlan.py # VLAN, TrunkConfig
480
+ │ │ ├── stats.py # PortStatistics
481
+ │ │ └── system.py # SystemInfo, SensorData, LACPInfo
482
+ │ └── vendors/
483
+ │ ├── common/ # Shared Cisco-style CLI transport & managers
484
+ │ │ ├── cisco_cli.py # CiscoCLITransport (SSH + paramiko)
485
+ │ │ └── cisco_managers.py CiscoVLANManager, CiscoPortManager, CiscoLACPManager
486
+ │ ├── cisco/ # Cisco Catalyst 1200
487
+ │ │ ├── client.py # CiscoSwitch — SSH only
488
+ │ │ └── managers.py # CiscoCLIMonitoringManager, CiscoCatalyst*Manager
489
+ │ ├── mikrotik/ # MikroTik RouterOS
490
+ │ │ ├── client.py # MikroTikSwitch
491
+ │ │ ├── managers.py # MikroTik*Manager
492
+ │ │ ├── rest.py # MikroTikRESTTransport
493
+ │ │ └── ssh.py # RouterOSTransport
494
+ │ ├── qnap/ # QNAP QSW
495
+ │ │ ├── client.py # QNAPSwitch
496
+ │ │ ├── rest.py # QNAPRESTTransport, QNAPMonitoringManager
497
+ │ │ ├── vlan_rest.py # QNAPRESTVLANManager (apply_port_membership)
498
+ │ │ └── utils.py # generate_enable_password()
499
+ │ ├── netgear/ # Netgear Smart Managed Pro (SNMP)
500
+ │ │ ├── client.py # NetgearSwitch
501
+ │ │ ├── backend.py # SNMP backend (read-back polling, save)
502
+ │ │ ├── snmp_managers.py Netgear*Manager
503
+ │ │ ├── routing.py # NetgearRoutingManager
504
+ │ │ └── web.py # NetgearWeb (static routes)
505
+ │ └── netgear_plus/ # Netgear Smart Managed Plus (web UI)
506
+ │ ├── client.py # NetgearPlusSwitch
507
+ │ ├── managers.py # NetgearPlus*Manager (reconcile)
508
+ │ └── sdk.py # netgear-tool wrapper
509
+ ├── discovery/ # Network topology discovery
510
+ │ ├── __init__.py # Public API: NetworkTopologyScanner, MermaidGenerator, ...
511
+ │ ├── cli.py # Discovery CLI (networkmgmt-discover)
512
+ │ ├── models.py # Pydantic models: NetworkTopology, DiscoveredHost, ...
513
+ │ ├── _util.py # Shared helpers: _run_cmd, _validate_*, _strip_hostname
514
+ │ ├── oui.py # IEEE OUI database loading and vendor lookup
515
+ │ ├── categorize.py # Device category classification rules
516
+ │ ├── scanner.py # NetworkTopologyScanner (ARP, ping, nmap, DNS, traceroute)
517
+ │ ├── snmp.py # SnmpBridgeDiscovery (SNMP MAC table queries)
518
+ │ ├── lldp.py # LldpDiscovery (SSH + lldpctl)
519
+ │ └── mermaid.py # MermaidGenerator (flowchart diagram output)
520
+ └── snmp_vlan_dump/ # SNMP VLAN-port dump
521
+ ├── __init__.py
522
+ ├── cli.py # VLAN dump CLI (networkmgmt-vlan-dump)
523
+ ├── collector.py # VlanDataCollector
524
+ ├── formatters.py # TerminalFormatter, MarkdownFormatter
525
+ ├── mermaid.py # VlanMermaidGenerator
526
+ └── snmp.py # SNMP operations
527
+ ```
528
+
529
+ ## Adding a New Vendor
530
+
531
+ 1. Create `networkmgmt/switchctrl/vendors/<name>/` with `__init__.py`, `client.py`, and optionally `managers.py`
532
+ 2. Decorate your client class with `@register_vendor("<name>")`
533
+ 3. Add `import networkmgmt.switchctrl.vendors.<name>` to `networkmgmt/switchctrl/vendors/__init__.py`
534
+ 4. The CLI picks it up automatically via `list_vendors()`
535
+
536
+
537
+ ## License
538
+ This project is licensed under the LGPL where applicable/possible — see [LICENSE.md](https://github.com/vroomfondel/networkmgmt/blob/main/LICENSE.md). Some files/parts may use other licenses: [MIT](https://github.com/vroomfondel/networkmgmt/blob/main/LICENSEMIT.md) | [GPL](https://github.com/vroomfondel/networkmgmt/blob/main/LICENSEGPL.md) | [LGPL](https://github.com/vroomfondel/networkmgmt/blob/main/LICENSELGPL.md). Always check per‑file headers/comments.
539
+
540
+
541
+ ## Authors
542
+ - Repo owner (primary author)
543
+ - Additional attributions are noted inline in code comments
544
+
545
+
546
+ ## Acknowledgments
547
+ - Inspirations and snippets are referenced in code comments where appropriate.
548
+
549
+
550
+ ## ⚠️ Note
551
+
552
+ This is a development/experimental project. For production use, review security settings, customize configurations, and test thoroughly in your environment. Provided "as is" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use at your own risk.