annet 0.16.14__py3-none-any.whl → 0.16.15__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.

@@ -139,6 +139,13 @@ class Interface(Entity):
139
139
  family = IpFamily(value=6, label="IPv6")
140
140
  else:
141
141
  family = IpFamily(value=4, label="IPv4")
142
+
143
+ for existing_addr in self.ip_addresses:
144
+ if existing_addr.address == address_mask and (
145
+ (existing_addr.vrf is None and vrf is None) or
146
+ (existing_addr.vrf is not None and existing_addr.vrf.name == vrf)
147
+ ):
148
+ return
142
149
  self.ip_addresses.append(IpAddress(
143
150
  id=0,
144
151
  display=address_mask,
@@ -54,6 +54,8 @@
54
54
  "Huawei.CE.CE8800.CE8851": " CE8851",
55
55
  "Huawei.CE.CE8800.CE8855": " CE8855",
56
56
  "Huawei.CE.CE9800": " CE98\\d\\d",
57
+ "Huawei.CE.CE9800.CE9855": " CE9855",
58
+ "Huawei.CE.CE9800.CE9860": " CE9860",
57
59
  "Huawei.Quidway": " (LS-)?S",
58
60
  "Huawei.Quidway.S2x": "2\\d{3}",
59
61
  "Huawei.Quidway.S2x.S2300": "23\\d\\d",
annet/bgp_models.py CHANGED
@@ -178,6 +178,7 @@ class FamilyOptions:
178
178
  class PeerGroup:
179
179
  name: str
180
180
  remote_as: ASN = ASN(None)
181
+ families: set[Family] = field(default_factory=set)
181
182
  internal_name: str = ""
182
183
  description: str = ""
183
184
  update_source: str = ""
annet/implicit.py CHANGED
@@ -71,14 +71,14 @@ def _implicit_tree(device):
71
71
  netconf
72
72
  """
73
73
  elif device.hw.Arista:
74
- # эта часть конфигурации будет не видна в конфиге, если она включена с таким набором полей:
74
+ # This part of configuration will not be visible in configuration
75
75
  text = r"""
76
76
  ip load-sharing trident fields ipv6 destination-port source-ip ingress-interface destination-ip source-port flow-label
77
77
  ip load-sharing trident fields ip source-ip source-port destination-ip destination-port ingress-interface
78
78
  """
79
79
  elif device.hw.Nexus:
80
80
  text = r"""
81
- # часть конфигурации скрытая если включена
81
+ # This part of configuration will not be visible in configuration if enabled
82
82
  snmp-server enable traps link linkDown
83
83
  snmp-server enable traps link linkUp
84
84
  """
@@ -107,25 +107,24 @@ def _implicit_tree(device):
107
107
  """
108
108
 
109
109
  elif device.hw.Nexus.N3x:
110
- # У нексуса сложные взаимоотношения с
111
- # shutdown командой вездe
112
- # в данный момент поведение проверенно для Cisco Nexus 3132Q 6.0(2)U6(7)
110
+ # Cisco Nexus has some specific related to "shutdown" command
111
+ # Behavior is cheked on Cisco Nexus 3132Q 6.0(2)U6(7)
113
112
  text += r"""
114
113
  # SVI
115
114
  !interface Vlan*
116
115
  !shutdown
117
116
  !interface mgmt[0-9]*
118
117
  no shutdown
119
- # Физические НЕ сплитованные интерфейсы и subif'ы
118
+ # Physical and NOT splitted interfaces and subifs
120
119
  !interface */Ethernet1\/[0-9.]*/
121
120
  no shutdown
122
- # Физические НЕ сплитованные интерфейсы и subif'ы
121
+ # Physical and NOT splitted interfaces and subifs
123
122
  !interface */Ethernet1\/[0-9]+\/[0-9.]+/
124
123
  # только explicit
125
- # Лупбеки
124
+ # Loopbacks
126
125
  !interface */Loopback[0-9.]+/
127
126
  no shutdown
128
- # Агрегаты
127
+ # Port-Channels
129
128
  !interface */port-channel[0-9.]+/
130
129
  no shutdown
131
130
  # BGP
@@ -135,11 +134,15 @@ def _implicit_tree(device):
135
134
  """
136
135
  elif device.hw.Cisco:
137
136
  text += r"""
138
- !interface *Ethernet*
137
+ !interface */\S*Ethernet\S+/
138
+ mtu 1500
139
+ no shutdown
140
+ !interface */Loopback[0-9.]+/
141
+ mtu 1500
142
+ no shutdown
143
+ !interface */port-channel[0-9.]+/
139
144
  mtu 1500
140
145
  no shutdown
141
-
142
-
143
146
  """
144
147
  if device.hw.Cisco.Catalyst:
145
148
  # this configuration is not visible in running-config when enabled
@@ -2,11 +2,13 @@ from dataclasses import dataclass
2
2
  from ipaddress import ip_interface
3
3
  from typing import Optional, Union
4
4
 
5
- from adaptix import Retort, loader, Chain, name_mapping
5
+ from adaptix import Retort, loader, Chain, name_mapping, as_is_loader
6
6
 
7
7
  from .peer_models import DirectPeerDTO, IndirectPeerDTO, VirtualPeerDTO, VirtualLocalDTO
8
- from ..bgp_models import Aggregate, GlobalOptions, VrfOptions, FamilyOptions, Peer, PeerGroup, ASN, PeerOptions
9
- from ..storage import Device
8
+ from ..bgp_models import (
9
+ Aggregate, GlobalOptions, VrfOptions, FamilyOptions, Peer, PeerGroup, ASN, PeerOptions,
10
+ Redistribute, BFDTimers,
11
+ )
10
12
 
11
13
 
12
14
  PeerDTO = Union[DirectPeerDTO, IndirectPeerDTO, VirtualPeerDTO]
@@ -52,6 +54,8 @@ retort = Retort(
52
54
  loader(FamilyOptions, ObjMapping, Chain.FIRST),
53
55
  loader(Aggregate, ObjMapping, Chain.FIRST),
54
56
  loader(PeerOptions, ObjMapping, Chain.FIRST),
57
+ as_is_loader(Redistribute),
58
+ as_is_loader(BFDTimers),
55
59
  name_mapping(PeerOptions, map={
56
60
  "local_as": "asnum",
57
61
  }),
@@ -82,7 +86,7 @@ def to_bgp_peer(local: LocalDTO, connected: PeerDTO, connected_hostname: str, in
82
86
  result.description = getattr(connected, "description", result.description)
83
87
  result.families = getattr(connected, "families", result.families)
84
88
  # local
85
- result.import_policy = getattr(connected, "import_policy", result.import_policy)
86
- result.export_policy = getattr(connected, "export_policy", result.export_policy)
87
- result.update_source = getattr(connected, "update_source", result.update_source)
89
+ result.import_policy = getattr(local, "import_policy", result.import_policy)
90
+ result.export_policy = getattr(local, "export_policy", result.export_policy)
91
+ result.update_source = getattr(local, "update_source", result.update_source)
88
92
  return result
annet/mesh/peer_models.py CHANGED
@@ -96,7 +96,7 @@ class IndirectPeerDTO(MeshSession, _OptionsDTO):
96
96
  update_source: str
97
97
 
98
98
 
99
- class VirtualLocalDTO(BaseMeshModel):
99
+ class VirtualLocalDTO(_OptionsDTO):
100
100
  asnum: int
101
101
  pod: int
102
102
  addr: str
@@ -109,13 +109,14 @@ class VirtualLocalDTO(BaseMeshModel):
109
109
  svi: int
110
110
 
111
111
 
112
- class VirtualPeerDTO(MeshSession, _OptionsDTO):
112
+ class VirtualPeerDTO(MeshSession):
113
113
  addr: str
114
114
  description: str
115
115
 
116
116
 
117
117
  class MeshPeerGroup(_OptionsDTO):
118
118
  name: str
119
+ families: Annotated[set[FamilyName], Concat()]
119
120
  remote_as: Union[int, str]
120
121
  internal_name: str
121
122
  update_source: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.16.14
3
+ Version: 0.16.15
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  annet/__init__.py,sha256=k2dq8aOYjkjZszKoOlxEmR49uYoKh-8_HC2K8FeqLwA,2139
2
2
  annet/annet.py,sha256=TMdEuM7GJQ4TjRVmuK3bCTZN-21lxjQ9sXqEdILUuBk,725
3
3
  annet/argparse.py,sha256=v1MfhjR0B8qahza0WinmXClpR8UiDFhmwDDWtNroJPA,12855
4
- annet/bgp_models.py,sha256=LEPlAuXaPpsQKL0s5QUlYhV5JE4yNKDCP9FX09Bdh_c,7986
4
+ annet/bgp_models.py,sha256=SUBiOFVK4PCzFO7AjcypF3E9SrvbNx8i7hdUYmLmDMo,8041
5
5
  annet/cli.py,sha256=hDpjIr3w47lgQ_CvCQS1SXFDK-SJrf5slbT__5u6GIA,12342
6
6
  annet/cli_args.py,sha256=KQlihxSl-Phhq1-9oJDdNSbIllEX55LlPfH6viEKOuw,13483
7
7
  annet/connectors.py,sha256=-Lghz3PtWCBU8Ohrp0KKQcmm1AUZtN0EnOaZ6IQgCQI,5105
@@ -11,7 +11,7 @@ annet/executor.py,sha256=Jny-hm0otZA1naPpFWR-R16SbaZioSQ8pkx-Yd2PYlM,19004
11
11
  annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
12
12
  annet/gen.py,sha256=rOAveprvBaEXbLyaQUhQ0QtOvcDfndlIOpchNhu8M1U,33499
13
13
  annet/hardware.py,sha256=_iR28dWiPtt6ZYdk-qg1sxazkSRJE3ukqKB-fFFfQak,1141
14
- annet/implicit.py,sha256=H8dABp2XlHecESojf6g4kxwReU8YUGBL5lfHlXoJUkc,5611
14
+ annet/implicit.py,sha256=kGKO-mdvPw4HROx4VhnQWxbNlnbG2LuSYEzZbQX2Elo,5518
15
15
  annet/lib.py,sha256=lOdz3UJFYkO0wnuzIRRq3FpULQliqBtfmGmKOGVFO4Q,4238
16
16
  annet/output.py,sha256=FYMcWCc43-b51KsCiKnXPZHawhgWNoVtY9gRqw__Ce0,7473
17
17
  annet/parallel.py,sha256=hLkzEht0KhzmzUWDdO4QFYQHzhxs3wPlTA8DxbB2ziw,17160
@@ -33,7 +33,7 @@ annet/adapters/netbox/provider.py,sha256=3IrfZ6CfCxf-lTnJlIC2TQ8M_rDxOB_B7HGXZ92
33
33
  annet/adapters/netbox/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  annet/adapters/netbox/common/client.py,sha256=PaxHG4W9H8_uunIwMBNYkLq4eQJYoO6p6gY-ciQs7Nc,2563
35
35
  annet/adapters/netbox/common/manufacturer.py,sha256=QoTjmuBAg5klOJqeo8HuS2HybIUGsjTkknLkQL_Tiec,1606
36
- annet/adapters/netbox/common/models.py,sha256=SeWQZV-zvaKvK2YT2Bwf-iapkIs5pr7I7rAI7vlFMB8,6886
36
+ annet/adapters/netbox/common/models.py,sha256=JAAtbUB6UOzA3-VF5Fa33XktgKC3C2csareTZnHyqd0,7177
37
37
  annet/adapters/netbox/common/query.py,sha256=ziUFM7cUEbEIf3k1szTll4aO-OCUa-2Ogxbebi7Tegs,646
38
38
  annet/adapters/netbox/common/status_client.py,sha256=W4nTb2yvBlJ2UkWUmUhKQ2PaSQb1shjhHj5ebb4s2s4,591
39
39
  annet/adapters/netbox/common/storage_opts.py,sha256=5tt6wxUUJTIzNbOVXMnYBwZedNAIqYlve3YWl6GdbZM,1197
@@ -55,7 +55,7 @@ annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
55
55
  annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  annet/annlib/netdev/db.py,sha256=fI_u5aya4l61mbYSjj4JwlVfi3s7obt2jqERSuXGRUI,1634
57
57
  annet/annlib/netdev/devdb/__init__.py,sha256=aKYjjLbJebdKBjnGDpVLQdSqrV2JL24spGm58tmMWVU,892
58
- annet/annlib/netdev/devdb/data/devdb.json,sha256=Qph7WxZBEbgBqbCFeYu6ZM0qkEBn80WmJEjfJkcaZ-0,5940
58
+ annet/annlib/netdev/devdb/data/devdb.json,sha256=_apUe1EsJORxD5CfAvBcpPlnIf_H7I_hjLuVTgS5-H0,6024
59
59
  annet/annlib/netdev/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  annet/annlib/netdev/views/dump.py,sha256=rIlyvnA3uM8bB_7oq1nS2KDxTp6dQh2hz-FbNhYIpOU,4630
61
61
  annet/annlib/netdev/views/hardware.py,sha256=3JCZLH7deIHhCguwPJTUX-WDvWjG_xt6BdSEZSO6zkQ,4226
@@ -86,8 +86,8 @@ annet/mesh/basemodel.py,sha256=bBBx1wu3ftENgf_4PGCV-SkEcxH3tFekvoointT3894,4739
86
86
  annet/mesh/device_models.py,sha256=Jv6g9blnvTVxHGgHhnGd3b_8C3EHGpV7txyyR0Yt_Rg,3301
87
87
  annet/mesh/executor.py,sha256=iDarSYfq9H6MSf-M1HkQOFIaUb8j-nG0sQNbgzq4XIo,13726
88
88
  annet/mesh/match_args.py,sha256=CR3kdIV9NGtyk9E2JbcOQ3TRuYEryTWP3m2yCo2VCWg,5751
89
- annet/mesh/models_converter.py,sha256=Wot-uxsHEg2QgBuYEntKkpXRq8P3kg_u-Xx9L3oAHI0,3088
90
- annet/mesh/peer_models.py,sha256=CgfMlUcIl3O06hQNFkZjqZB4_Ihm9Fi4tZdIxCE2K5M,2536
89
+ annet/mesh/models_converter.py,sha256=9K-B-Y5gQktr6ycHiCIM0OHsCM8yPUpO89AceU0Of3A,3168
90
+ annet/mesh/peer_models.py,sha256=T8sgKcg1a0BAkRVS5Kfc65CrlIB2AqQcwrehfEqWhLk,2572
91
91
  annet/mesh/registry.py,sha256=G-FszWc_VKeN3eVpb-MRGbAGzbcSuEVAzbDC2k747XA,8611
92
92
  annet/rulebook/__init__.py,sha256=14IpOfTbeJtre7JKrfXVYiH0qAXsUSOL7AatUFmSQs0,3847
93
93
  annet/rulebook/common.py,sha256=zK1s2c5lc5HQbIlMUQ4HARQudXSgOYiZ_Sxc2I_tHqg,721
@@ -151,11 +151,11 @@ annet_generators/example/__init__.py,sha256=1z030I00c9KeqW0ntkT1IRLYKD5LZAHYjiNH
151
151
  annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn6yo,2100
152
152
  annet_generators/mesh_example/__init__.py,sha256=NfNWgXn1TNiWI6A5tmU6Y-4QV2i33td0Qs3re0MNNMo,218
153
153
  annet_generators/mesh_example/bgp.py,sha256=jzyDndSSGYyYBquDnLlR-7P5lzmUKcSyYCml3VsoMC0,1385
154
- annet_generators/mesh_example/mesh_logic.py,sha256=4-gAgdQwO_2v8UF6UEGKpiLTTyzwge9YLel-Jup6H6c,1251
155
- annet-0.16.14.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
156
- annet-0.16.14.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
157
- annet-0.16.14.dist-info/METADATA,sha256=egMj4TY9XuOV5Spjb_3AW-OVTI84wuD7524-Ii_ZISw,745
158
- annet-0.16.14.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
159
- annet-0.16.14.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
160
- annet-0.16.14.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
161
- annet-0.16.14.dist-info/RECORD,,
154
+ annet_generators/mesh_example/mesh_logic.py,sha256=DJS5JMCTs0rs0LN__0LulNgo2ekUcWiOMe02BlOeFas,1454
155
+ annet-0.16.15.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
156
+ annet-0.16.15.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
157
+ annet-0.16.15.dist-info/METADATA,sha256=VI-njmyEaLFgh_aLn0WYEXAxnsims000_VWqTUu5ujc,745
158
+ annet-0.16.15.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
159
+ annet-0.16.15.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
160
+ annet-0.16.15.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
161
+ annet-0.16.15.dist-info/RECORD,,
@@ -1,3 +1,4 @@
1
+ from annet.bgp_models import Redistribute, BFDTimers
1
2
  from annet.mesh import Right, MeshRulesRegistry, GlobalOptions, MeshSession, DirectPeer, VirtualLocal, VirtualPeer
2
3
 
3
4
  registry = MeshRulesRegistry()
@@ -6,6 +7,9 @@ registry = MeshRulesRegistry()
6
7
  @registry.device("{name:.*}")
7
8
  def device_handler(global_opts: GlobalOptions):
8
9
  global_opts.local_as = 12345
10
+ global_opts.ipv4_unicast.redistributes = (Redistribute(
11
+ protocol="ipv4", policy="sss",
12
+ ),)
9
13
  global_opts.groups["GROP_NAME"].remote_as = 11111
10
14
 
11
15
 
@@ -21,6 +25,7 @@ def virtual_handler(device: VirtualLocal, peer: VirtualPeer, session: MeshSessio
21
25
  session.asnum = 12345
22
26
  device.svi = 1
23
27
  device.addr = "192.168.1.254"
28
+ device.listen_network = ["10.0.0.0/8"]
24
29
  peer.addr = f"192.168.127.{peer.num}"
25
30
 
26
31