netgear-switch-inventory 0.1.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.
- netgear_switch_inventory-0.1.1/.github/workflows/ci.yml +39 -0
- netgear_switch_inventory-0.1.1/.github/workflows/publish.yml +33 -0
- netgear_switch_inventory-0.1.1/.gitignore +13 -0
- netgear_switch_inventory-0.1.1/LICENSE +183 -0
- netgear_switch_inventory-0.1.1/PKG-INFO +340 -0
- netgear_switch_inventory-0.1.1/README.md +127 -0
- netgear_switch_inventory-0.1.1/pyproject.toml +52 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/__init__.py +35 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/_output_helpers.py +42 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/adapters/__init__.py +5 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/adapters/_base.py +14 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/adapters/gs108.py +139 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/adapters/gs116.py +109 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/cli/__init__.py +0 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/cli/_output.py +71 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/cli/discover.py +47 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/cli/inventory.py +93 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/contrib/__init__.py +0 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/contrib/salt_grains.py +63 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/exceptions.py +28 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/inventory.py +58 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/models.py +152 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/nsdp.py +162 -0
- netgear_switch_inventory-0.1.1/src/netgear_switch/session.py +154 -0
- netgear_switch_inventory-0.1.1/tests/__init__.py +0 -0
- netgear_switch_inventory-0.1.1/tests/conftest.py +117 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/fixture_meta.yaml +10 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/igmp_disabled.html +119 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/igmp_enabled.html +119 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/igmp_template.html +119 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/info.html +14 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/login.html +13 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/loop_disabled.html +42 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/loop_enabled.html +42 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/loop_template.html +42 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/mirror_disabled.html +93 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/mirror_enabled.html +93 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/mirror_template.html +93 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/ports.html +6 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/qos_disabled.html +91 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/qos_enabled.html +91 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/qos_template.html +91 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/storm_disabled.html +78 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/storm_enabled.html +78 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/storm_template.html +78 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/vlan_portbased_disabled.html +68 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/vlan_portbased_enabled.html +68 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs108ev3/V2.06.24EN/vlan_portbased_template.html +68 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/fixture_meta.yaml +11 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/igmp_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/igmp_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/info.html +8 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/login.html +12 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/loop_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/loop_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/mirror_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/mirror_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/ports.html +10 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/power_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/power_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/qos_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/qos_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/storm_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/storm_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/vlan_disabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/gs116ev2/V2.6.0.50/vlan_enabled.html +1 -0
- netgear_switch_inventory-0.1.1/tests/fixtures/server.py +169 -0
- netgear_switch_inventory-0.1.1/tests/integration/conftest.py +108 -0
- netgear_switch_inventory-0.1.1/tests/integration/test_cli.py +83 -0
- netgear_switch_inventory-0.1.1/tests/integration/test_fixture_server.py +182 -0
- netgear_switch_inventory-0.1.1/tests/integration/test_gist.py +104 -0
- netgear_switch_inventory-0.1.1/tests/test_adapters.py +226 -0
- netgear_switch_inventory-0.1.1/tests/test_auth.py +57 -0
- netgear_switch_inventory-0.1.1/tests/test_inventory.py +78 -0
- netgear_switch_inventory-0.1.1/tests/test_models.py +133 -0
- netgear_switch_inventory-0.1.1/tests/test_nsdp.py +111 -0
- netgear_switch_inventory-0.1.1/tests/test_session.py +81 -0
- netgear_switch_inventory-0.1.1/tests/unit/conftest.py +52 -0
- netgear_switch_inventory-0.1.1/tests/unit/test_adapters.py +351 -0
- netgear_switch_inventory-0.1.1/tests/unit/test_auth.py +77 -0
- netgear_switch_inventory-0.1.1/tests/unit/test_models.py +182 -0
- netgear_switch_inventory-0.1.1/tests/unit/test_session.py +194 -0
- netgear_switch_inventory-0.1.1/uv.lock +396 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Lint
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: astral-sh/setup-uv@v3
|
|
16
|
+
- run: uv run --with ruff ruff check src/ tests/
|
|
17
|
+
|
|
18
|
+
test:
|
|
19
|
+
name: Test / Python ${{ matrix.python-version }}
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
strategy:
|
|
22
|
+
matrix:
|
|
23
|
+
python-version: ["3.11", "3.12"]
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: astral-sh/setup-uv@v3
|
|
27
|
+
- name: Install deps
|
|
28
|
+
run: uv sync --extra dev
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: uv run pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
package:
|
|
33
|
+
name: Build & check package
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
- uses: astral-sh/setup-uv@v3
|
|
38
|
+
- run: uv build
|
|
39
|
+
- run: uv run --with twine twine check dist/*
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: astral-sh/setup-uv@v3
|
|
15
|
+
- run: uv build
|
|
16
|
+
- uses: actions/upload-artifact@v4
|
|
17
|
+
with:
|
|
18
|
+
name: dist
|
|
19
|
+
path: dist/
|
|
20
|
+
|
|
21
|
+
publish:
|
|
22
|
+
name: Publish to PyPI
|
|
23
|
+
needs: build
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
environment: pypi
|
|
26
|
+
permissions:
|
|
27
|
+
id-token: write
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/download-artifact@v4
|
|
30
|
+
with:
|
|
31
|
+
name: dist
|
|
32
|
+
path: dist/
|
|
33
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,183 @@
|
|
|
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 made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of developing and
|
|
55
|
+
discussing the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any other
|
|
81
|
+
Contribution embodied in the Work constitutes patent infringement,
|
|
82
|
+
then any patent licenses granted to You under this License for that
|
|
83
|
+
Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
86
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
87
|
+
modifications, and in Source or Object form, provided that You
|
|
88
|
+
meet the following conditions:
|
|
89
|
+
|
|
90
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
91
|
+
Works a copy of this License; and
|
|
92
|
+
|
|
93
|
+
(b) You must cause any modified files to carry prominent notices
|
|
94
|
+
stating that You changed the files; and
|
|
95
|
+
|
|
96
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
97
|
+
that You distribute, all copyright, patent, trademark, and
|
|
98
|
+
attribution notices from the Source form of the Work,
|
|
99
|
+
excluding those notices that do not pertain to any part of
|
|
100
|
+
the Derivative Works; and
|
|
101
|
+
|
|
102
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
103
|
+
distribution, You must include a readable copy of the
|
|
104
|
+
attribution notices contained within such NOTICE file, in
|
|
105
|
+
at least one of the following places: within a NOTICE text
|
|
106
|
+
file distributed as part of the Derivative Works; within
|
|
107
|
+
the Source form or documentation, if provided along with the
|
|
108
|
+
Derivative Works; or, within a display generated by the
|
|
109
|
+
Derivative Works, if and wherever such third-party notices
|
|
110
|
+
normally appear. The contents of the NOTICE file are for
|
|
111
|
+
informational purposes only and do not modify the License.
|
|
112
|
+
You may add Your own attribution notices within Derivative
|
|
113
|
+
Works that You distribute, alongside or in addition to the
|
|
114
|
+
NOTICE text from the Work, provided that such additional
|
|
115
|
+
attribution notices cannot be construed as modifying the License.
|
|
116
|
+
|
|
117
|
+
You may add Your own license statement for Your modifications and
|
|
118
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
119
|
+
publish, distribute, sublicense, and/or sell copies of the Work,
|
|
120
|
+
and to permit persons to whom the Work is furnished to do so,
|
|
121
|
+
subject to the following conditions:
|
|
122
|
+
|
|
123
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
124
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
125
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
126
|
+
this License, without any additional terms or conditions.
|
|
127
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
128
|
+
the terms of any separate license agreement you may have executed
|
|
129
|
+
with Licensor regarding such Contributions.
|
|
130
|
+
|
|
131
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
132
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
133
|
+
except as required for reasonable and customary use in describing the
|
|
134
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
137
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
138
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
139
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
140
|
+
implied, including, without limitation, any conditions of title,
|
|
141
|
+
MERCHANTIBILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
142
|
+
responsible for determining the appropriateness of using or
|
|
143
|
+
redistributing the Work and assume any risks associated with Your
|
|
144
|
+
exercise of permissions under this License.
|
|
145
|
+
|
|
146
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
147
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
148
|
+
unless required by applicable law (such as deliberate and grossly
|
|
149
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
150
|
+
liable to You for damages, including any direct, indirect, special,
|
|
151
|
+
incidental, or exemplary damages of any character arising as a
|
|
152
|
+
result of this License or out of the use or inability to use the
|
|
153
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
154
|
+
work stoppage, computer failure or malfunction, or all other
|
|
155
|
+
commercial damages or losses), even if such Contributor has been
|
|
156
|
+
advised of the possibility of such damages.
|
|
157
|
+
|
|
158
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
159
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
160
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
161
|
+
or other liability obligations and/or rights consistent with this
|
|
162
|
+
License. However, in accepting such obligations, You may offer only
|
|
163
|
+
on behalf of yourself, or on behalf of each other Contributor,
|
|
164
|
+
and only if You agree to indemnify, defend, and hold each
|
|
165
|
+
Contributor harmless for any liability incurred by, or claims
|
|
166
|
+
asserted against, such Contributor by reason of your accepting
|
|
167
|
+
any such warranty or additional liability.
|
|
168
|
+
|
|
169
|
+
END OF TERMS AND CONDITIONS
|
|
170
|
+
|
|
171
|
+
Copyright 2024 Christian Prior-Mamulyan
|
|
172
|
+
|
|
173
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
174
|
+
you may not use this file except in compliance with the License.
|
|
175
|
+
You may obtain a copy of the License at
|
|
176
|
+
|
|
177
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
178
|
+
|
|
179
|
+
Unless required by applicable law or agreed to in writing, software
|
|
180
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
181
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
182
|
+
See the License for the specific language governing permissions and
|
|
183
|
+
limitations under the License.
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netgear-switch-inventory
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Inventory and monitoring for Netgear Easy Smart switches via HTTP scraping
|
|
5
|
+
Project-URL: Source, https://github.com/cprima-integrations/netgear-switch-inventory
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/cprima-integrations/netgear-switch-inventory/issues
|
|
7
|
+
Author-email: Christian Prior-Mamulyan <cprior@gmail.com>
|
|
8
|
+
License: Apache License
|
|
9
|
+
Version 2.0, January 2004
|
|
10
|
+
http://www.apache.org/licenses/
|
|
11
|
+
|
|
12
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
13
|
+
|
|
14
|
+
1. Definitions.
|
|
15
|
+
|
|
16
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
17
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
18
|
+
|
|
19
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
20
|
+
the copyright owner that is granting the License.
|
|
21
|
+
|
|
22
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
23
|
+
other entities that control, are controlled by, or are under common
|
|
24
|
+
control with that entity. For the purposes of this definition,
|
|
25
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
26
|
+
direction or management of such entity, whether by contract or
|
|
27
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
28
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
29
|
+
|
|
30
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
31
|
+
exercising permissions granted by this License.
|
|
32
|
+
|
|
33
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
34
|
+
including but not limited to software source code, documentation
|
|
35
|
+
source, and configuration files.
|
|
36
|
+
|
|
37
|
+
"Object" form shall mean any form resulting from mechanical
|
|
38
|
+
transformation or translation of a Source form, including but
|
|
39
|
+
not limited to compiled object code, generated documentation,
|
|
40
|
+
and conversions to other media types.
|
|
41
|
+
|
|
42
|
+
"Work" shall mean the work of authorship made available under
|
|
43
|
+
the License, as indicated by a copyright notice that is included in
|
|
44
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
45
|
+
|
|
46
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
47
|
+
form, that is based on (or derived from) the Work and for which the
|
|
48
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
49
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
50
|
+
of this License, Derivative Works shall not include works that remain
|
|
51
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
52
|
+
the Work and Derivative Works thereof.
|
|
53
|
+
|
|
54
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
55
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
56
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
57
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
58
|
+
or written communication sent to the Licensor or its representatives,
|
|
59
|
+
including but not limited to communication on electronic mailing lists,
|
|
60
|
+
source code control systems, and issue tracking systems that are managed
|
|
61
|
+
by, or on behalf of, the Licensor for the purpose of developing and
|
|
62
|
+
discussing the Work, but excluding communication that is conspicuously
|
|
63
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
64
|
+
Contribution."
|
|
65
|
+
|
|
66
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
67
|
+
whom a Contribution has been received by the Licensor and included
|
|
68
|
+
within the Work.
|
|
69
|
+
|
|
70
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
74
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
75
|
+
Work and such Derivative Works in Source or Object form.
|
|
76
|
+
|
|
77
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
80
|
+
(except as stated in this section) patent license to make, have made,
|
|
81
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
82
|
+
where such license applies only to those patent claims licensable
|
|
83
|
+
by such Contributor that are necessarily infringed by their
|
|
84
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
85
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
86
|
+
institute patent litigation against any entity (including a cross-claim
|
|
87
|
+
or counterclaim in a lawsuit) alleging that the Work or any other
|
|
88
|
+
Contribution embodied in the Work constitutes patent infringement,
|
|
89
|
+
then any patent licenses granted to You under this License for that
|
|
90
|
+
Work shall terminate as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
98
|
+
Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, You must include a readable copy of the
|
|
111
|
+
attribution notices contained within such NOTICE file, in
|
|
112
|
+
at least one of the following places: within a NOTICE text
|
|
113
|
+
file distributed as part of the Derivative Works; within
|
|
114
|
+
the Source form or documentation, if provided along with the
|
|
115
|
+
Derivative Works; or, within a display generated by the
|
|
116
|
+
Derivative Works, if and wherever such third-party notices
|
|
117
|
+
normally appear. The contents of the NOTICE file are for
|
|
118
|
+
informational purposes only and do not modify the License.
|
|
119
|
+
You may add Your own attribution notices within Derivative
|
|
120
|
+
Works that You distribute, alongside or in addition to the
|
|
121
|
+
NOTICE text from the Work, provided that such additional
|
|
122
|
+
attribution notices cannot be construed as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own license statement for Your modifications and
|
|
125
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
126
|
+
publish, distribute, sublicense, and/or sell copies of the Work,
|
|
127
|
+
and to permit persons to whom the Work is furnished to do so,
|
|
128
|
+
subject to the following conditions:
|
|
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 conditions of title,
|
|
148
|
+
MERCHANTIBILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
149
|
+
responsible for determining the appropriateness of using or
|
|
150
|
+
redistributing the Work and assume any risks associated with Your
|
|
151
|
+
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 exemplary 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 all other
|
|
162
|
+
commercial damages or losses), even if such Contributor has been
|
|
163
|
+
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 offer only
|
|
170
|
+
on behalf of yourself, or on behalf of each other Contributor,
|
|
171
|
+
and only if You agree to indemnify, defend, and hold each
|
|
172
|
+
Contributor harmless for any liability incurred by, or claims
|
|
173
|
+
asserted against, such Contributor by reason of your accepting
|
|
174
|
+
any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2024 Christian Prior-Mamulyan
|
|
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.
|
|
191
|
+
License-File: LICENSE
|
|
192
|
+
Keywords: gs108,gs116,inventory,monitoring,netgear,nsdp,switch
|
|
193
|
+
Classifier: Development Status :: 3 - Alpha
|
|
194
|
+
Classifier: Intended Audience :: System Administrators
|
|
195
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
196
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
197
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
198
|
+
Classifier: Topic :: System :: Monitoring
|
|
199
|
+
Classifier: Topic :: System :: Networking
|
|
200
|
+
Requires-Python: >=3.11
|
|
201
|
+
Requires-Dist: pyyaml>=6.0
|
|
202
|
+
Requires-Dist: requests>=2.32
|
|
203
|
+
Provides-Extra: cli
|
|
204
|
+
Requires-Dist: python-dotenv>=1.0; extra == 'cli'
|
|
205
|
+
Requires-Dist: rich>=13; extra == 'cli'
|
|
206
|
+
Requires-Dist: typer>=0.12; extra == 'cli'
|
|
207
|
+
Provides-Extra: dev
|
|
208
|
+
Requires-Dist: pytest-mock>=3.14; extra == 'dev'
|
|
209
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
210
|
+
Requires-Dist: requests-mock>=1.12; extra == 'dev'
|
|
211
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
212
|
+
Description-Content-Type: text/markdown
|
|
213
|
+
|
|
214
|
+
# netgear-switch-inventory
|
|
215
|
+
|
|
216
|
+
Inventory and monitoring for Netgear Easy Smart switches via HTTP scraping.
|
|
217
|
+
|
|
218
|
+
No SNMP, no official API — the package reverse-engineers the proprietary web UI used
|
|
219
|
+
by Netgear ProSAFE Easy Smart switches (GS116Ev2, GS108Ev3 and compatible).
|
|
220
|
+
|
|
221
|
+
## Device support
|
|
222
|
+
|
|
223
|
+
| Model | Auth | Port status | Features | NSDP discovery |
|
|
224
|
+
|-------|------|-------------|----------|----------------|
|
|
225
|
+
| GS116Ev2 | HMAC-MD5 (`YOU_CAN_NOT_PASS`) | Yes | Yes | Yes |
|
|
226
|
+
| GS108Ev3 | MD5-interleave(password, rand) | No* | Yes | Yes |
|
|
227
|
+
|
|
228
|
+
\* GS108Ev3 serves port state via AJAX (`/getstatus.cgi`). This endpoint is not yet
|
|
229
|
+
implemented. `ports` returns `[]` for GS108Ev3. All other data (identity, features)
|
|
230
|
+
works correctly.
|
|
231
|
+
|
|
232
|
+
## Install
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pip install netgear-switch-inventory
|
|
236
|
+
# with CLI
|
|
237
|
+
pip install "netgear-switch-inventory[cli]"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Or with uv:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
uv add netgear-switch-inventory
|
|
244
|
+
uv add "netgear-switch-inventory[cli]"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Configuration
|
|
248
|
+
|
|
249
|
+
Credentials are passed directly or via environment variables. Create a `.env` file
|
|
250
|
+
(never commit it):
|
|
251
|
+
|
|
252
|
+
```dotenv
|
|
253
|
+
NETGEAR_HOST="192.168.1.100"
|
|
254
|
+
NETGEAR_PASSWORD="password"
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## CLI usage
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Collect and print inventory from a switch
|
|
261
|
+
netgear-inventory collect --host 192.168.1.100
|
|
262
|
+
|
|
263
|
+
# Collect and save to YAML file
|
|
264
|
+
netgear-inventory fetch --host 192.168.1.100 --output ./inventory/
|
|
265
|
+
|
|
266
|
+
# Discover switches on the LAN via NSDP broadcast
|
|
267
|
+
netgear-discover
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Run `--help` on any command for all options.
|
|
271
|
+
|
|
272
|
+
## Library usage
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
from netgear_switch.session import SwitchSession
|
|
276
|
+
from netgear_switch.models import load_catalog
|
|
277
|
+
from netgear_switch.inventory import snapshot, persist
|
|
278
|
+
from pathlib import Path
|
|
279
|
+
|
|
280
|
+
catalog = load_catalog() # ships with package
|
|
281
|
+
|
|
282
|
+
sw = SwitchSession("192.168.1.100", "password")
|
|
283
|
+
sw.login()
|
|
284
|
+
snap = snapshot(sw, catalog)
|
|
285
|
+
|
|
286
|
+
print(snap.model, snap.firmware, snap.firmware_status)
|
|
287
|
+
print(f"{len(snap.ports_up)} ports up")
|
|
288
|
+
|
|
289
|
+
persist(snap, Path("inventory/"))
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## NSDP discovery
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from netgear_switch.nsdp import probe
|
|
296
|
+
|
|
297
|
+
for switch in probe(timeout=3.0):
|
|
298
|
+
print(switch.get("model"), switch.get("ip"), switch.get("_from"))
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Requires the process to bind to UDP 63321. On Linux, use `--network host` in Docker
|
|
302
|
+
or run as root/with `CAP_NET_BIND_SERVICE`.
|
|
303
|
+
|
|
304
|
+
## Salt grains
|
|
305
|
+
|
|
306
|
+
Copy `src/netgear_switch/contrib/salt_grains.py` to your Salt `_grains/` directory
|
|
307
|
+
as `netgear_switch.py`, then configure the minion:
|
|
308
|
+
|
|
309
|
+
```yaml
|
|
310
|
+
# /etc/salt/minion.d/netgear_switch.conf
|
|
311
|
+
netgear_switch:
|
|
312
|
+
host: "192.168.1.100"
|
|
313
|
+
password: "password"
|
|
314
|
+
catalog_path: "/etc/salt/netgear/device_catalog.yaml" # optional
|
|
315
|
+
timeout: 10
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Verify:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
salt-call --local grains.item switch
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The grains module returns switch identity and feature flags under the `switch` key,
|
|
325
|
+
mirroring Salt built-in grain names where applicable (`manufacturer`, `productname`,
|
|
326
|
+
`serialnumber`, `osrelease`).
|
|
327
|
+
|
|
328
|
+
## Known limitations
|
|
329
|
+
|
|
330
|
+
- **GS108Ev3 port status**: not implemented — AJAX endpoint not yet reverse-engineered.
|
|
331
|
+
`ports` is always `[]` for this model.
|
|
332
|
+
- **Write operations**: the package never calls any mutating web UI endpoint.
|
|
333
|
+
- **HTTPS**: Netgear Easy Smart switches do not support HTTPS. All communication
|
|
334
|
+
is HTTP.
|
|
335
|
+
- **Multi-switch**: the CLI and library operate on one switch at a time. Iterate
|
|
336
|
+
from a wrapper script for fleet inventory.
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|