annet 2.3.1__py3-none-any.whl → 2.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of annet might be problematic. Click here for more details.
- annet/adapters/netbox/common/adapter.py +60 -0
- annet/adapters/netbox/common/models.py +47 -55
- annet/adapters/netbox/common/status_client.py +7 -0
- annet/adapters/netbox/common/storage_base.py +239 -0
- annet/adapters/netbox/provider.py +20 -7
- annet/adapters/netbox/v24/models.py +295 -0
- annet/adapters/netbox/v24/storage.py +8 -2
- annet/adapters/netbox/v37/models.py +60 -0
- annet/adapters/netbox/v37/storage.py +70 -300
- annet/adapters/netbox/v41/__init__.py +0 -0
- annet/adapters/netbox/v41/models.py +78 -0
- annet/adapters/netbox/v41/storage.py +91 -0
- annet/adapters/netbox/v42/__init__.py +0 -0
- annet/adapters/netbox/v42/models.py +63 -0
- annet/adapters/netbox/v42/storage.py +91 -0
- annet/annlib/netdev/devdb/data/devdb.json +2 -0
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info}/METADATA +4 -3
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info}/RECORD +23 -13
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info}/WHEEL +1 -1
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info}/entry_points.txt +0 -0
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info/licenses}/AUTHORS +0 -0
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info/licenses}/LICENSE +0 -0
- {annet-2.3.1.dist-info → annet-2.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from adaptix import P
|
|
3
|
+
from adaptix.conversion import get_converter, link, link_constant, link_function
|
|
4
|
+
from annetbox.v42 import client_sync
|
|
5
|
+
from annetbox.v42 import models as api_models
|
|
6
|
+
|
|
7
|
+
from annet.adapters.netbox.common.adapter import NetboxAdapter, get_device_breed, get_device_hw
|
|
8
|
+
from annet.adapters.netbox.common.storage_base import BaseNetboxStorage
|
|
9
|
+
from annet.adapters.netbox.v42.models import InterfaceV42, NetboxDeviceV42, PrefixV42, IpAddressV42
|
|
10
|
+
from annet.storage import Storage
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NetboxV42Adapter(NetboxAdapter[NetboxDeviceV42, InterfaceV42, IpAddressV42, PrefixV42]):
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
storage: Storage,
|
|
17
|
+
url: str,
|
|
18
|
+
token: str,
|
|
19
|
+
ssl_context: ssl.SSLContext | None,
|
|
20
|
+
threads: int,
|
|
21
|
+
):
|
|
22
|
+
self.netbox = client_sync.NetboxV42(url=url, token=token, ssl_context=ssl_context, threads=threads)
|
|
23
|
+
self.convert_device = get_converter(
|
|
24
|
+
api_models.Device,
|
|
25
|
+
NetboxDeviceV42,
|
|
26
|
+
recipe=[
|
|
27
|
+
link_function(get_device_breed, P[NetboxDeviceV42].breed),
|
|
28
|
+
link_function(get_device_hw, P[NetboxDeviceV42].hw),
|
|
29
|
+
link_constant(P[NetboxDeviceV42].interfaces, factory=list),
|
|
30
|
+
link_constant(P[NetboxDeviceV42].storage, value=storage),
|
|
31
|
+
link(P[api_models.Device].name, P[NetboxDeviceV42].hostname),
|
|
32
|
+
link(P[api_models.Device].name, P[NetboxDeviceV42].fqdn),
|
|
33
|
+
]
|
|
34
|
+
)
|
|
35
|
+
self.convert_interfaces = get_converter(
|
|
36
|
+
list[api_models.Interface],
|
|
37
|
+
list[InterfaceV42],
|
|
38
|
+
recipe=[
|
|
39
|
+
link_constant(P[InterfaceV42].ip_addresses, factory=list),
|
|
40
|
+
link_constant(P[InterfaceV42].lag_min_links, value=None),
|
|
41
|
+
]
|
|
42
|
+
)
|
|
43
|
+
self.convert_ip_addresses = get_converter(
|
|
44
|
+
list[api_models.IpAddress],
|
|
45
|
+
list[IpAddressV42],
|
|
46
|
+
recipe=[
|
|
47
|
+
link_constant(P[IpAddressV42].prefix, value=None),
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
self.convert_ip_prefixes = get_converter(
|
|
51
|
+
list[api_models.Prefix],
|
|
52
|
+
list[PrefixV42],
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def list_all_fqdns(self) -> list[str]:
|
|
56
|
+
return [
|
|
57
|
+
d.name
|
|
58
|
+
for d in self.netbox.dcim_all_devices_brief().results
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
def list_devices(self, query: dict[str, list[str]]) -> list[NetboxDeviceV42]:
|
|
62
|
+
return [
|
|
63
|
+
self.convert_device(dev)
|
|
64
|
+
for dev in self.netbox.dcim_all_devices(**query).results
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
def get_device(self, device_id: int) -> NetboxDeviceV42:
|
|
68
|
+
return self.convert_device(self.netbox.dcim_device(device_id))
|
|
69
|
+
|
|
70
|
+
def list_interfaces_by_devices(self, device_ids: list[int]) -> list[InterfaceV42]:
|
|
71
|
+
return self.convert_interfaces(self.netbox.dcim_all_interfaces(device_id=device_ids).results)
|
|
72
|
+
|
|
73
|
+
def list_interfaces(self, ids: list[int]) -> list[InterfaceV42]:
|
|
74
|
+
return self.convert_interfaces(self.netbox.dcim_all_interfaces(id=ids).results)
|
|
75
|
+
|
|
76
|
+
def list_ipaddr_by_ifaces(self, iface_ids: list[int]) -> list[IpAddressV42]:
|
|
77
|
+
return self.convert_ip_addresses(self.netbox.ipam_all_ip_addresses(interface_id=iface_ids).results)
|
|
78
|
+
|
|
79
|
+
def list_ipprefixes(self, prefixes: list[str]) -> list[PrefixV42]:
|
|
80
|
+
return self.convert_ip_prefixes(self.netbox.ipam_all_prefixes(prefix=prefixes).results)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class NetboxStorageV42(BaseNetboxStorage[NetboxDeviceV42, InterfaceV42, IpAddressV42, PrefixV42]):
|
|
84
|
+
def _init_adapter(
|
|
85
|
+
self,
|
|
86
|
+
url: str,
|
|
87
|
+
token: str,
|
|
88
|
+
ssl_context: ssl.SSLContext | None,
|
|
89
|
+
threads: int,
|
|
90
|
+
) -> NetboxAdapter[NetboxDeviceV42, InterfaceV42, IpAddressV42, PrefixV42]:
|
|
91
|
+
return NetboxV42Adapter(self, url, token, ssl_context, threads)
|
|
@@ -128,6 +128,8 @@
|
|
|
128
128
|
"PC.Whitebox.Asterfusion.CX": " CX",
|
|
129
129
|
"PC.Whitebox.Asterfusion.CX.CX500": " CX5\\d\\d",
|
|
130
130
|
"PC.Whitebox.Asterfusion.CX.CX500.CX532P-N": " CX532P-N",
|
|
131
|
+
"PC.Whitebox.Asterfusion.CX.CX800": " CX8\\d\\d",
|
|
132
|
+
"PC.Whitebox.Asterfusion.CX.CX800.CX864E-N": " CX864E-N",
|
|
131
133
|
"PC.Whitebox.Ufispace": "[Uu]fi[Ss]pace",
|
|
132
134
|
"PC.Whitebox.Ufispace.S": " S",
|
|
133
135
|
"PC.Whitebox.Ufispace.S.S9100": " S91\\d\\d",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: annet
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: annet
|
|
5
5
|
Home-page: https://github.com/annetutil/annet
|
|
6
6
|
License: MIT
|
|
@@ -21,9 +21,10 @@ Requires-Dist: yarl>=1.8.2
|
|
|
21
21
|
Requires-Dist: adaptix==3.0.0b7
|
|
22
22
|
Requires-Dist: dataclass-rest==0.4
|
|
23
23
|
Provides-Extra: netbox
|
|
24
|
-
Requires-Dist: annetbox[sync]>=0.2.
|
|
24
|
+
Requires-Dist: annetbox[sync]>=0.2.2; extra == "netbox"
|
|
25
25
|
Dynamic: home-page
|
|
26
26
|
Dynamic: license
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
Dynamic: provides-extra
|
|
28
29
|
Dynamic: requires-dist
|
|
29
30
|
Dynamic: requires-python
|
|
@@ -30,18 +30,28 @@ annet/adapters/fetchers/stub/fetcher.py,sha256=FzpkIzPJBQVuNNSdXKoGzkALmIGMgo2gm
|
|
|
30
30
|
annet/adapters/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
annet/adapters/file/provider.py,sha256=KyHuA5w9E4T3Lxeko8b5M7jRmu7yhTJVLqLkas4ue1A,6654
|
|
32
32
|
annet/adapters/netbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
annet/adapters/netbox/provider.py,sha256=
|
|
33
|
+
annet/adapters/netbox/provider.py,sha256=sVxjUfXkGnnyCnPmualOJBcHfP7F529zeHzlfiKrMP4,2124
|
|
34
34
|
annet/adapters/netbox/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
+
annet/adapters/netbox/common/adapter.py,sha256=-YcO3371D8hupNXKf5f4-FdFSjTto-7VKDvz29Gid38,2016
|
|
35
36
|
annet/adapters/netbox/common/client.py,sha256=PaxHG4W9H8_uunIwMBNYkLq4eQJYoO6p6gY-ciQs7Nc,2563
|
|
36
37
|
annet/adapters/netbox/common/manufacturer.py,sha256=Y9kqU13q6fwYu0_HiotUKAy7OHFZngkC2s3s4IDAbDg,1745
|
|
37
|
-
annet/adapters/netbox/common/models.py,sha256=
|
|
38
|
+
annet/adapters/netbox/common/models.py,sha256=fMqhXTXNgZwAhClZ3XBQN6cesYy3miEXzuF-0v93u3c,7427
|
|
38
39
|
annet/adapters/netbox/common/query.py,sha256=kbNQSZwkjFeDArHwA8INHUauxCxYElXtNh58pZipWdo,1867
|
|
39
|
-
annet/adapters/netbox/common/status_client.py,sha256=
|
|
40
|
+
annet/adapters/netbox/common/status_client.py,sha256=POaqiQJ0jPcqUQH-X_fWHVnKB7TBYveNriaT0eNTlfI,769
|
|
41
|
+
annet/adapters/netbox/common/storage_base.py,sha256=T8mgEH4X87pHM4qet-3kl9UAAhXtZdPrcYK276CzTY0,8721
|
|
40
42
|
annet/adapters/netbox/common/storage_opts.py,sha256=wfv1spElomwgVYMCgGth3SWVF0RsRgtUgq9GpFL9hJs,1520
|
|
41
43
|
annet/adapters/netbox/v24/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
-
annet/adapters/netbox/v24/
|
|
44
|
+
annet/adapters/netbox/v24/models.py,sha256=TAZUYXf1TlOrzgitWZaaLvW0tB143RgnFb1wA2X9lc8,7549
|
|
45
|
+
annet/adapters/netbox/v24/storage.py,sha256=zptzrW4aZUv_exuGw0DqQPm_kXZR3DwL4zRHYL6twTk,6219
|
|
43
46
|
annet/adapters/netbox/v37/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
|
-
annet/adapters/netbox/v37/
|
|
47
|
+
annet/adapters/netbox/v37/models.py,sha256=VqI1bT5E5pFIaDJWxWMU6bioNyrXKJuNq-_J8YIJIbw,1613
|
|
48
|
+
annet/adapters/netbox/v37/storage.py,sha256=ymt1h3slOEvQdNRQDBq3qQ-nW58EospX6lnNZtJ5jQ0,3747
|
|
49
|
+
annet/adapters/netbox/v41/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
|
+
annet/adapters/netbox/v41/models.py,sha256=nunqgxffobE2C3_g1bkHXWffStBdAJxHfx0eAbvnWAU,2068
|
|
51
|
+
annet/adapters/netbox/v41/storage.py,sha256=h6e7V4Od5o7P3Ssr_vUQ1IBjsxdnug4YGvG1BokwKuk,3795
|
|
52
|
+
annet/adapters/netbox/v42/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
+
annet/adapters/netbox/v42/models.py,sha256=xo5TB6VE0KNvQwUB_zasl2bDbNuKCCjcsHB3P-JVLgk,1784
|
|
54
|
+
annet/adapters/netbox/v42/storage.py,sha256=atiThgkDGVdJStvFCDn4JtPZfEAhUNbw5IH_W-ijFDg,3795
|
|
45
55
|
annet/annlib/__init__.py,sha256=fT1l4xV5fqqg8HPw9HqmZVN2qwS8i6X1aIm2zGDjxKY,252
|
|
46
56
|
annet/annlib/command.py,sha256=uuBddMQphtn8P5MO5kzIa8_QrtMns-k05VeKv1bcAuA,1043
|
|
47
57
|
annet/annlib/diff.py,sha256=MZ6eQAU3cadQp8KaSE6uAYFtcfMDCIe_eNuVROnYkCk,4496
|
|
@@ -56,7 +66,7 @@ annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
|
|
|
56
66
|
annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
67
|
annet/annlib/netdev/db.py,sha256=fI_u5aya4l61mbYSjj4JwlVfi3s7obt2jqERSuXGRUI,1634
|
|
58
68
|
annet/annlib/netdev/devdb/__init__.py,sha256=aKYjjLbJebdKBjnGDpVLQdSqrV2JL24spGm58tmMWVU,892
|
|
59
|
-
annet/annlib/netdev/devdb/data/devdb.json,sha256=
|
|
69
|
+
annet/annlib/netdev/devdb/data/devdb.json,sha256=4RTRg9PbRiUfi-kVIalim7Rtdkdu_48MGGtrZ6XmXmg,6677
|
|
60
70
|
annet/annlib/netdev/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
71
|
annet/annlib/netdev/views/dump.py,sha256=rIlyvnA3uM8bB_7oq1nS2KDxTp6dQh2hz-FbNhYIpOU,4630
|
|
62
72
|
annet/annlib/netdev/views/hardware.py,sha256=3JCZLH7deIHhCguwPJTUX-WDvWjG_xt6BdSEZSO6zkQ,4226
|
|
@@ -167,6 +177,8 @@ annet/rulebook/texts/ribbon.deploy,sha256=hCq2XeAcwaYanyQ8lTdnez6Pgq-gRqpNuR8dAl
|
|
|
167
177
|
annet/rulebook/texts/ribbon.rul,sha256=609LyLTDCtXPVQNAzqS-VEyCpW3byHP8TCMJLFMn5cc,2108
|
|
168
178
|
annet/rulebook/texts/routeros.order,sha256=M71uy_hf0KAjLNS3zZY3uih4m2xLUcu26FEoVVjC6k0,905
|
|
169
179
|
annet/rulebook/texts/routeros.rul,sha256=ipfxjj0mjFef6IsUlupqx4BY_Je_OUb8u_U1019O1DE,1203
|
|
180
|
+
annet-2.5.0.dist-info/licenses/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
|
|
181
|
+
annet-2.5.0.dist-info/licenses/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
|
|
170
182
|
annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
171
183
|
annet_generators/example/__init__.py,sha256=1z030I00c9KeqW0ntkT1IRLYKD5LZAHYjiNHrOLen1Q,221
|
|
172
184
|
annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn6yo,2100
|
|
@@ -178,10 +190,8 @@ annet_generators/rpl_example/generator.py,sha256=zndIGfV4ZlTxPgAGYs7bMQvTc_tYScO
|
|
|
178
190
|
annet_generators/rpl_example/items.py,sha256=d99HSXDHFjZq511EvGhIqRTWK3F4ZsCWfdUqFYQcyhE,772
|
|
179
191
|
annet_generators/rpl_example/mesh.py,sha256=z_WgfDZZ4xnyh3cSf75igyH09hGvtexEVwy1gCD_DzA,288
|
|
180
192
|
annet_generators/rpl_example/route_policy.py,sha256=z6nPb0VDeQtKD1NIg9sFvmUxBD5tVs2frfNIuKdM-5c,2318
|
|
181
|
-
annet-2.
|
|
182
|
-
annet-2.
|
|
183
|
-
annet-2.
|
|
184
|
-
annet-2.
|
|
185
|
-
annet-2.
|
|
186
|
-
annet-2.3.1.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
|
|
187
|
-
annet-2.3.1.dist-info/RECORD,,
|
|
193
|
+
annet-2.5.0.dist-info/METADATA,sha256=Vhn9KPGkgtnCN1raOof_b6lpHl-tKYrM9kdOqAmoY44,815
|
|
194
|
+
annet-2.5.0.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
|
195
|
+
annet-2.5.0.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
|
|
196
|
+
annet-2.5.0.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
|
|
197
|
+
annet-2.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|