annet 2.4.0__py3-none-any.whl → 2.5.1__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 +22 -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/rpl_generators/cumulus_frr.py +5 -5
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/METADATA +2 -2
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/RECORD +23 -13
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/WHEEL +1 -1
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/entry_points.txt +0 -0
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/licenses/AUTHORS +0 -0
- {annet-2.4.0.dist-info → annet-2.5.1.dist-info}/licenses/LICENSE +0 -0
- {annet-2.4.0.dist-info → annet-2.5.1.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)
|
|
@@ -353,18 +353,18 @@ class CumulusPolicyGenerator(ABC):
|
|
|
353
353
|
) -> Iterator[Sequence[str]]:
|
|
354
354
|
if action.value.prepend:
|
|
355
355
|
for path_item in action.value.prepend:
|
|
356
|
-
yield "set as-path prepend", path_item
|
|
356
|
+
yield "set", "as-path prepend", path_item
|
|
357
357
|
if action.value.expand:
|
|
358
358
|
raise NotImplementedError("asp_path.expand is not supported for Cumulus")
|
|
359
359
|
if action.value.delete:
|
|
360
360
|
for path_item in action.value.delete:
|
|
361
|
-
yield "set as-path exclude", path_item
|
|
361
|
+
yield "set", "as-path exclude", path_item
|
|
362
362
|
if action.value.set is not None:
|
|
363
|
-
yield "set as-path exclude all"
|
|
363
|
+
yield "set", "as-path exclude", "all"
|
|
364
364
|
for path_item in action.value.set:
|
|
365
|
-
yield "set as-path prepend", path_item
|
|
365
|
+
yield "set", "as-path prepend", path_item
|
|
366
366
|
if action.value.expand_last_as:
|
|
367
|
-
yield "set as-path prepend last-as", action.value.expand_last_as
|
|
367
|
+
yield "set", "as-path prepend last-as", action.value.expand_last_as
|
|
368
368
|
|
|
369
369
|
def _cumulus_policy_then(
|
|
370
370
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: annet
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Summary: annet
|
|
5
5
|
Home-page: https://github.com/annetutil/annet
|
|
6
6
|
License: MIT
|
|
@@ -21,7 +21,7 @@ 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
27
|
Dynamic: license-file
|
|
@@ -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=SrxW_uBLvMTqtRiYXreL6RrZK4MpxVguF2ITnYOnVHU,2226
|
|
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
|
|
@@ -102,7 +112,7 @@ annet/rpl/statement_builder.py,sha256=qKhLS34lygbhtbEIY-6jzs0Aisc6qmNc_iyk9iKPyH
|
|
|
102
112
|
annet/rpl_generators/__init__.py,sha256=V4rAZlBaOUSjeQ5eCNmWeD7BSJLIwy0lKU_01grebpc,832
|
|
103
113
|
annet/rpl_generators/aspath.py,sha256=kZakwPLfGGiXu9fC6I1z-pvy7Fe-4dy93_-lYcx39_4,2038
|
|
104
114
|
annet/rpl_generators/community.py,sha256=SWpaOvoQUNISuRm41-IvGPFmntvgFv9ee4zegsMyeo0,11496
|
|
105
|
-
annet/rpl_generators/cumulus_frr.py,sha256=
|
|
115
|
+
annet/rpl_generators/cumulus_frr.py,sha256=eABVCpn4ru_BFQJDcPZZEi1EL1cBwfNhtC1mDmC6BwA,21548
|
|
106
116
|
annet/rpl_generators/entities.py,sha256=uO78iG2zHAGra5DqzpfnBgoc6slHEc6wDLvlnoySvJc,3750
|
|
107
117
|
annet/rpl_generators/execute.py,sha256=wS6e6fwcPWywsHB0gBMqZ17eF0s4YOBgDgwPB_cr5Rw,431
|
|
108
118
|
annet/rpl_generators/policy.py,sha256=j_2EtAsaxldhZZT4kRXKZacuAsGnHr3JSc2BMxr_Pow,37174
|
|
@@ -167,8 +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
|
|
170
|
-
annet-2.
|
|
171
|
-
annet-2.
|
|
180
|
+
annet-2.5.1.dist-info/licenses/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
|
|
181
|
+
annet-2.5.1.dist-info/licenses/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
|
|
172
182
|
annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
173
183
|
annet_generators/example/__init__.py,sha256=1z030I00c9KeqW0ntkT1IRLYKD5LZAHYjiNHrOLen1Q,221
|
|
174
184
|
annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn6yo,2100
|
|
@@ -180,8 +190,8 @@ annet_generators/rpl_example/generator.py,sha256=zndIGfV4ZlTxPgAGYs7bMQvTc_tYScO
|
|
|
180
190
|
annet_generators/rpl_example/items.py,sha256=d99HSXDHFjZq511EvGhIqRTWK3F4ZsCWfdUqFYQcyhE,772
|
|
181
191
|
annet_generators/rpl_example/mesh.py,sha256=z_WgfDZZ4xnyh3cSf75igyH09hGvtexEVwy1gCD_DzA,288
|
|
182
192
|
annet_generators/rpl_example/route_policy.py,sha256=z6nPb0VDeQtKD1NIg9sFvmUxBD5tVs2frfNIuKdM-5c,2318
|
|
183
|
-
annet-2.
|
|
184
|
-
annet-2.
|
|
185
|
-
annet-2.
|
|
186
|
-
annet-2.
|
|
187
|
-
annet-2.
|
|
193
|
+
annet-2.5.1.dist-info/METADATA,sha256=yV5XEXm3TVL8ONqDFzOU1Gfw1aKGTDkKLAaZhtWg5Wc,815
|
|
194
|
+
annet-2.5.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
195
|
+
annet-2.5.1.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
|
|
196
|
+
annet-2.5.1.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
|
|
197
|
+
annet-2.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|