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

@@ -1,4 +1,6 @@
1
1
  import re
2
+ from collections import OrderedDict
3
+ from typing import Any
2
4
 
3
5
  from annet.annlib.types import Op
4
6
 
@@ -55,3 +57,93 @@ def banner_login(rule, key, diff, **_):
55
57
  yield (False, f"banner login {key}", None)
56
58
  else:
57
59
  yield from common.default(rule, key, diff)
60
+
61
+
62
+ def bgp_diff(old, new, diff_pre, _pops=(Op.AFFECTED,)):
63
+ """
64
+ Some oder versions of Cisco IOS doesn't create subsection for address family block.
65
+
66
+ it looks like:
67
+
68
+ router bgp 65111
69
+ bgp router-id 1.1.1.1
70
+ bgp log-neighbor-changes
71
+ neighbor SPINE peer-group
72
+ !
73
+ address-family ipv4
74
+ neighbor SPINE send-community both
75
+ neighbor SPINE soft-reconfiguration inbound
76
+ neighbor SPINE route-map TOR_IMPORT_SPINE in
77
+ neighbor SPINE route-map TOR_EXPORT_SPINE out
78
+ exit-address-family
79
+
80
+ but should be
81
+
82
+ router bgp 65111
83
+ bgp router-id 1.1.1.1
84
+ bgp log-neighbor-changes
85
+ neighbor SPINE peer-group
86
+ !
87
+ address-family ipv4
88
+ neighbor SPINE send-community both
89
+ neighbor SPINE soft-reconfiguration inbound
90
+ neighbor SPINE route-map TOR_IMPORT_SPINE in
91
+ neighbor SPINE route-map TOR_EXPORT_SPINE out
92
+ exit-address-family
93
+
94
+ The diff_logic func do it before make diff.
95
+ """
96
+ corrected_old = _create_subsections(old, "address-family")
97
+
98
+ yield from common.default_diff(corrected_old, new, diff_pre, _pops)
99
+
100
+
101
+ def _create_subsections(data: OrderedDict[str, Any], sub_section_prefix: str) -> OrderedDict[str, Any]:
102
+ """
103
+ Reorganizes the given OrderedDict to nest commands under their respective
104
+ sub_section_prefix keys.
105
+
106
+ This function traverses the entries in the provided OrderedDict and groups
107
+ together all entries that are between keys with sub_section_prefix under those
108
+ keys as nested OrderedDicts. The reorganization keeps the order of entries
109
+ stable, only adding nesting where appropriate.
110
+
111
+ Args:
112
+ data (OrderedDict): The original configuration to be transformed.
113
+ sub_section_prefix (str): Prefix of subsection key
114
+
115
+ Returns:
116
+ OrderedDict: A new OrderedDict with nested 'address-family' sections.
117
+ """
118
+
119
+ result = OrderedDict()
120
+ sub_section = None
121
+ temp: OrderedDict = OrderedDict()
122
+
123
+ for key, value in data.items():
124
+ # make nested loop if found nested values
125
+ if value:
126
+ fixed_value: OrderedDict[str, Any] = _create_subsections(value, sub_section_prefix)
127
+ else:
128
+ fixed_value = value
129
+ if key.startswith(sub_section_prefix):
130
+ # in case of data has already had subsections
131
+ if value:
132
+ result[key] = fixed_value
133
+ continue
134
+ # if previous subsection present save collected data from temporary dict
135
+ if sub_section:
136
+ result[sub_section] = temp
137
+ # find a new subsection and initialize new dict
138
+ sub_section = key
139
+ temp = OrderedDict()
140
+ # put found data to temporary dict
141
+ elif sub_section:
142
+ temp[key] = fixed_value
143
+ else:
144
+ result[key] = fixed_value
145
+ # if data is finished save collected data from temporary dict
146
+ if sub_section:
147
+ result[sub_section] = temp
148
+
149
+ return result
@@ -73,7 +73,7 @@ interface */\w*Ethernet[0-9\/]+$/ %logic=common.permanent %diff_logic=cisco.
73
73
  storm-control * level
74
74
  spanning-tree portfast
75
75
 
76
- router bgp *
76
+ router bgp * %diff_logic=cisco.misc.bgp_diff
77
77
  router-id
78
78
  vrf *
79
79
  router-id
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.1
2
+ Name: annet
3
+ Version: 0.16.17
4
+ Summary: annet
5
+ Home-page: https://github.com/annetutil/annet
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ License-File: LICENSE
9
+ License-File: AUTHORS
10
+ Requires-Dist: colorama>=0.4.6
11
+ Requires-Dist: tabulate>=0.9.0
12
+ Requires-Dist: jsonpatch>=1.33
13
+ Requires-Dist: jsonpointer>=2.4
14
+ Requires-Dist: PyYAML>=6.0.1
15
+ Requires-Dist: Pygments>=2.14.0
16
+ Requires-Dist: Mako>=1.2.4
17
+ Requires-Dist: Jinja2>=3.1.2
18
+ Requires-Dist: psutil>=5.8.0
19
+ Requires-Dist: packaging>=23.2
20
+ Requires-Dist: contextlog>=1.1
21
+ Requires-Dist: valkit>=0.1.4
22
+ Requires-Dist: yarl>=1.8.2
23
+ Requires-Dist: adaptix==3.0.0b7
24
+ Requires-Dist: dataclass-rest==0.4
25
+ Provides-Extra: netbox
26
+ Requires-Dist: annetbox[sync]>=0.1.8; extra == "netbox"
@@ -102,7 +102,7 @@ annet/rulebook/b4com/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
102
102
  annet/rulebook/b4com/file.py,sha256=zK7RwBk1YaVoDSFSg1u7Pt8u0Fk3nhhu27aJRngemwc,137
103
103
  annet/rulebook/cisco/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
104
  annet/rulebook/cisco/iface.py,sha256=WISkzjp_G7WKPpg098FCIm4b7ipOxtRLOQbu-7gMUL0,1792
105
- annet/rulebook/cisco/misc.py,sha256=l9NTR6cAsrfFyeC_yoOeQ0fOFoPiJfFwnRva5W9vyL0,2259
105
+ annet/rulebook/cisco/misc.py,sha256=KBnxBw5vs-GSoldMBzEB8ygyHEntiydn1vchZDBA3No,5286
106
106
  annet/rulebook/cisco/vlandb.py,sha256=pdQ0Ca976_5_cNBbTI6ADN1SP8aAngVBs1AZWltmpsw,3319
107
107
  annet/rulebook/huawei/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
108
  annet/rulebook/huawei/aaa.py,sha256=Xi8nWyBFaUz4SgoN1NQeOcXzBGCfINQDNiC-crq08uA,3445
@@ -127,7 +127,7 @@ annet/rulebook/texts/b4com.order,sha256=G3aToAIHHzKzDCM3q7_lyr9wJvuVOXVbVvF3wm5P
127
127
  annet/rulebook/texts/b4com.rul,sha256=5mqyUg_oLRSny2iH6QdhfDWVu6kzgDURtlSATD7DFno,1056
128
128
  annet/rulebook/texts/cisco.deploy,sha256=XvXWeOMahE8Uc9RF0xkJj8jGknD4vit8H_f24ubPX7w,1226
129
129
  annet/rulebook/texts/cisco.order,sha256=OvNHMNqkCc-DN2dEjLCTKv_7ZhiaHt4q2X4Y4Z8dvR4,1901
130
- annet/rulebook/texts/cisco.rul,sha256=FvMxKy4FOcFvFYdmcye5RZkWkU8mxIwmEedN83fM82I,3019
130
+ annet/rulebook/texts/cisco.rul,sha256=xMJJgTGmg5wZXTIp5SUdLJIgwka7AIv9Uj6-DWBV3UQ,3055
131
131
  annet/rulebook/texts/huawei.deploy,sha256=azEC6_jQRzwnTSrNgag0hHh6L7hezS_eMk6ZDZfWyXI,10444
132
132
  annet/rulebook/texts/huawei.order,sha256=ENllPX4kO6xNw2mUQcx11yhxo3tKStZ5mUyc0C6s3d0,10657
133
133
  annet/rulebook/texts/huawei.rul,sha256=02Fi1RG4YYea2clHCluBuJDKNbT0hS9jtsk6_h6GK8k,12958
@@ -152,10 +152,10 @@ annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn
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
154
  annet_generators/mesh_example/mesh_logic.py,sha256=DJS5JMCTs0rs0LN__0LulNgo2ekUcWiOMe02BlOeFas,1454
155
- annet-0.16.16.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
156
- annet-0.16.16.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
157
- annet-0.16.16.dist-info/METADATA,sha256=HWT2ARwNTk_WK4FcwEtWOa2FrkPAYRZ5BUwr3--hrNA,746
158
- annet-0.16.16.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
159
- annet-0.16.16.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
160
- annet-0.16.16.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
161
- annet-0.16.16.dist-info/RECORD,,
155
+ annet-0.16.17.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
156
+ annet-0.16.17.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
157
+ annet-0.16.17.dist-info/METADATA,sha256=4rLw_7-NNXC4Y55-ZDYyEPUqYVEg3DKCjM7u8CxY2_w,728
158
+ annet-0.16.17.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
159
+ annet-0.16.17.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
160
+ annet-0.16.17.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
161
+ annet-0.16.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: annet
3
- Version: 0.16.16
4
- Summary: annet
5
- Home-page: https://github.com/annetutil/annet
6
- License: MIT
7
- Requires-Python: >=3.10
8
- License-File: LICENSE
9
- License-File: AUTHORS
10
- Requires-Dist: colorama >=0.4.6
11
- Requires-Dist: tabulate >=0.9.0
12
- Requires-Dist: jsonpatch >=1.33
13
- Requires-Dist: jsonpointer >=2.4
14
- Requires-Dist: PyYAML >=6.0.1
15
- Requires-Dist: Pygments >=2.14.0
16
- Requires-Dist: Mako >=1.2.4
17
- Requires-Dist: Jinja2 >=3.1.2
18
- Requires-Dist: psutil >=5.8.0
19
- Requires-Dist: packaging >=23.2
20
- Requires-Dist: contextlog >=1.1
21
- Requires-Dist: valkit >=0.1.4
22
- Requires-Dist: yarl >=1.8.2
23
- Requires-Dist: adaptix ==3.0.0b7
24
- Requires-Dist: dataclass-rest ==0.4
25
- Provides-Extra: netbox
26
- Requires-Dist: annetbox[sync] >=0.1.8 ; extra == 'netbox'
27
-