annet 1.1.0__py3-none-any.whl → 1.1.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/query.py +3 -1
- annet/annlib/patching.py +9 -3
- annet/annlib/rbparser/ordering.py +6 -1
- annet/annlib/tabparser.py +8 -1
- annet/executor.py +1 -23
- annet/rulebook/texts/juniper.order +2 -2
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/METADATA +2 -2
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/RECORD +13 -13
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/AUTHORS +0 -0
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/LICENSE +0 -0
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/WHEEL +0 -0
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/entry_points.txt +0 -0
- {annet-1.1.0.dist-info → annet-1.1.1.dist-info}/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@ from typing import cast, List, Union, Iterable, Optional, TypedDict
|
|
|
5
5
|
from annet.storage import Query
|
|
6
6
|
|
|
7
7
|
FIELD_VALUE_SEPARATOR = ":"
|
|
8
|
-
ALLOWED_GLOB_GROUPS = ["site", "tag", "role", "device_type"]
|
|
8
|
+
ALLOWED_GLOB_GROUPS = ["site", "tag", "role", "device_type", "status", "tenant"]
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Filter(TypedDict, total=False):
|
|
@@ -14,6 +14,8 @@ class Filter(TypedDict, total=False):
|
|
|
14
14
|
role: list[str]
|
|
15
15
|
name: list[str]
|
|
16
16
|
device_type: list[str]
|
|
17
|
+
status: list[str]
|
|
18
|
+
tenant: list[str]
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
@dataclass
|
annet/annlib/patching.py
CHANGED
|
@@ -2,7 +2,7 @@ import copy
|
|
|
2
2
|
import operator
|
|
3
3
|
import textwrap
|
|
4
4
|
from collections import OrderedDict as odict
|
|
5
|
-
from typing import (
|
|
5
|
+
from typing import (
|
|
6
6
|
Any,
|
|
7
7
|
Dict,
|
|
8
8
|
Iterator,
|
|
@@ -177,7 +177,7 @@ class Orderer:
|
|
|
177
177
|
def rule_weight(self, row, rule, regexp_key):
|
|
178
178
|
return len(set(row).intersection(set(rule["attrs"][regexp_key].pattern))) / len(row)
|
|
179
179
|
|
|
180
|
-
def get_order(self, row, cmd_direct):
|
|
180
|
+
def get_order(self, row, cmd_direct, scope: str | None = None):
|
|
181
181
|
f_order = None
|
|
182
182
|
f_weight = 0
|
|
183
183
|
f_rule = ""
|
|
@@ -186,6 +186,12 @@ class Orderer:
|
|
|
186
186
|
block_exit = platform.VENDOR_EXIT[self.vendor]
|
|
187
187
|
|
|
188
188
|
for (order, (raw_rule, rule)) in enumerate(ordering.items()):
|
|
189
|
+
if (
|
|
190
|
+
(rule_scope := rule["attrs"]["scope"]) is not None
|
|
191
|
+
and scope not in rule_scope
|
|
192
|
+
):
|
|
193
|
+
continue
|
|
194
|
+
|
|
189
195
|
if rule["attrs"]["global"]:
|
|
190
196
|
children.append((raw_rule, rule))
|
|
191
197
|
|
|
@@ -419,7 +425,7 @@ def make_patch(pre, rb, hw, add_comments, orderer=None, _root_pre=None, do_commi
|
|
|
419
425
|
patch_row = "%s %s" % (row, comments)
|
|
420
426
|
|
|
421
427
|
# pylint: disable=unused-variable
|
|
422
|
-
(order, order_direct, ordering, order_rule) = orderer.get_order(row, direct)
|
|
428
|
+
(order, order_direct, ordering, order_rule) = orderer.get_order(row, direct, scope="patch")
|
|
423
429
|
fmt_row = patch_row
|
|
424
430
|
# fmt_row += " # %s" % str(order_rule) # uncomment to debug ordering
|
|
425
431
|
|
|
@@ -2,7 +2,7 @@ import functools
|
|
|
2
2
|
import re
|
|
3
3
|
from collections import OrderedDict as odict
|
|
4
4
|
|
|
5
|
-
from valkit.common import valid_bool
|
|
5
|
+
from valkit.common import valid_bool, valid_string_list
|
|
6
6
|
|
|
7
7
|
from . import platform, syntax
|
|
8
8
|
|
|
@@ -19,6 +19,10 @@ def compile_ordering_text(text, vendor):
|
|
|
19
19
|
"global": {
|
|
20
20
|
"validator": valid_bool,
|
|
21
21
|
"default": False,
|
|
22
|
+
},
|
|
23
|
+
"scope": {
|
|
24
|
+
"validator": valid_string_list,
|
|
25
|
+
"default": None,
|
|
22
26
|
}
|
|
23
27
|
}),
|
|
24
28
|
reverse_prefix=platform.VENDOR_REVERSES[vendor],
|
|
@@ -49,6 +53,7 @@ def _compile_ordering(tree, reverse_prefix):
|
|
|
49
53
|
),
|
|
50
54
|
"order_reverse": attrs["params"]["order_reverse"],
|
|
51
55
|
"global": attrs["params"]["global"],
|
|
56
|
+
"scope": attrs["params"]["scope"],
|
|
52
57
|
"raw_rule": attrs["raw_rule"],
|
|
53
58
|
"context": attrs["context"],
|
|
54
59
|
},
|
annet/annlib/tabparser.py
CHANGED
|
@@ -458,6 +458,13 @@ class JuniperFormatter(CommonFormatter):
|
|
|
458
458
|
def patch_plain(self, patch):
|
|
459
459
|
return list(self.cmd_paths(patch).keys())
|
|
460
460
|
|
|
461
|
+
def _blocks(self, tree: "PatchTree", is_patch: bool):
|
|
462
|
+
for row in super()._blocks(tree, is_patch):
|
|
463
|
+
if isinstance(row, str) and row.startswith(self.Comment.begin):
|
|
464
|
+
yield f"{self.Comment.begin} {self.Comment.loads(row).comment} {self.Comment.end}"
|
|
465
|
+
else:
|
|
466
|
+
yield row
|
|
467
|
+
|
|
461
468
|
def _formatted_blocks(self, blocks):
|
|
462
469
|
level = 0
|
|
463
470
|
line = None
|
|
@@ -469,7 +476,7 @@ class JuniperFormatter(CommonFormatter):
|
|
|
469
476
|
elif new_line is BlockEnd:
|
|
470
477
|
level -= 1
|
|
471
478
|
if isinstance(line, str):
|
|
472
|
-
yield line + self._statement_end
|
|
479
|
+
yield line + ("" if line.endswith(self.Comment.end) else self._statement_end)
|
|
473
480
|
yield self._indent * level + self._block_end
|
|
474
481
|
elif isinstance(line, str):
|
|
475
482
|
yield line + ("" if line.endswith(self.Comment.end) else self._statement_end)
|
annet/executor.py
CHANGED
|
@@ -4,7 +4,7 @@ import statistics
|
|
|
4
4
|
from abc import ABC, abstractmethod
|
|
5
5
|
from functools import partial
|
|
6
6
|
from operator import itemgetter
|
|
7
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, List, Optional
|
|
8
8
|
|
|
9
9
|
import colorama
|
|
10
10
|
from annet.annlib.command import Command, CommandList, Question # noqa: F401
|
|
@@ -16,28 +16,6 @@ class CommandResult(ABC):
|
|
|
16
16
|
pass
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class Connector(ABC):
|
|
20
|
-
@abstractmethod
|
|
21
|
-
async def cmd(self, cmd: Union[Command, str]) -> CommandResult:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
@abstractmethod
|
|
25
|
-
async def download(self, files: List[str]) -> Dict[str, str]:
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
@abstractmethod
|
|
29
|
-
async def upload(self, files: Dict[str, str]):
|
|
30
|
-
pass
|
|
31
|
-
|
|
32
|
-
@abstractmethod
|
|
33
|
-
def get_conn_trace(self) -> str:
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
|
-
@abstractmethod
|
|
37
|
-
async def aclose(self) -> str:
|
|
38
|
-
pass
|
|
39
|
-
|
|
40
|
-
|
|
41
19
|
class ExecutorException(Exception):
|
|
42
20
|
def __init__(self, *args: List[Any], auxiliary: Optional[Any] = None, **kwargs: object):
|
|
43
21
|
self.auxiliary = auxiliary
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Правило на все команды
|
|
2
2
|
* %global
|
|
3
|
-
# Добавляем веса комментам, чтобы они катились всегда после
|
|
4
|
-
*/\/\*(?:(?!\*\/).)*\*\// %global
|
|
3
|
+
# Добавляем веса комментам, чтобы они катились всегда после команд, но только в патче
|
|
4
|
+
*/\/\*(?:(?!\*\/).)*\*\// %global %scope=patch
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: annet
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: annet
|
|
5
5
|
Home-page: https://github.com/annetutil/annet
|
|
6
6
|
License: MIT
|
|
@@ -22,7 +22,7 @@ Requires-Dist: yarl>=1.8.2
|
|
|
22
22
|
Requires-Dist: adaptix==3.0.0b7
|
|
23
23
|
Requires-Dist: dataclass-rest==0.4
|
|
24
24
|
Provides-Extra: netbox
|
|
25
|
-
Requires-Dist: annetbox[sync]>=0.2.
|
|
25
|
+
Requires-Dist: annetbox[sync]>=0.2.1; extra == "netbox"
|
|
26
26
|
Dynamic: home-page
|
|
27
27
|
Dynamic: license
|
|
28
28
|
Dynamic: provides-extra
|
|
@@ -8,7 +8,7 @@ annet/connectors.py,sha256=aoiDVLPizx8CW2p8SAwGCzyO_WW8H9xc2aujbGC4bDg,4882
|
|
|
8
8
|
annet/deploy.py,sha256=3O96k17FbVt8KCvxF4gujXAB81U2-XRJyHLpbc9ekSQ,7529
|
|
9
9
|
annet/deploy_ui.py,sha256=SDTJ-CF6puW0KHQ0g_NDp61Tqh6xkTBMxv8PrBhGyNI,27977
|
|
10
10
|
annet/diff.py,sha256=zLcaCnb4lZRUb7frpH1CstQ3kacRcCblZs1uLG8J5lk,3391
|
|
11
|
-
annet/executor.py,sha256=
|
|
11
|
+
annet/executor.py,sha256=lcKI-EbYqeCiBNpL729kSltduzxbAzOkQ1L_QK7tNv8,5112
|
|
12
12
|
annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
|
|
13
13
|
annet/gen.py,sha256=A718tYqIcxAa8tQEdjR6PjQ2ovWBnwPH7STKh38lmFY,33567
|
|
14
14
|
annet/hardware.py,sha256=_iR28dWiPtt6ZYdk-qg1sxazkSRJE3ukqKB-fFFfQak,1141
|
|
@@ -35,7 +35,7 @@ annet/adapters/netbox/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
|
35
35
|
annet/adapters/netbox/common/client.py,sha256=PaxHG4W9H8_uunIwMBNYkLq4eQJYoO6p6gY-ciQs7Nc,2563
|
|
36
36
|
annet/adapters/netbox/common/manufacturer.py,sha256=Y9kqU13q6fwYu0_HiotUKAy7OHFZngkC2s3s4IDAbDg,1745
|
|
37
37
|
annet/adapters/netbox/common/models.py,sha256=cnNf2oB_BDRz4ZYkHpib1qPxwY1iREJMiWlg8T0lORY,7559
|
|
38
|
-
annet/adapters/netbox/common/query.py,sha256=
|
|
38
|
+
annet/adapters/netbox/common/query.py,sha256=kbNQSZwkjFeDArHwA8INHUauxCxYElXtNh58pZipWdo,1867
|
|
39
39
|
annet/adapters/netbox/common/status_client.py,sha256=XXx0glomaBaglmkUEy6YtFOxQQkHb59CDA0h1I-IhxM,592
|
|
40
40
|
annet/adapters/netbox/common/storage_opts.py,sha256=wfv1spElomwgVYMCgGth3SWVF0RsRgtUgq9GpFL9hJs,1520
|
|
41
41
|
annet/adapters/netbox/v24/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -50,8 +50,8 @@ annet/annlib/filter_acl.py,sha256=0w1VF6WcONiTYTQh0yWi6_j9rCTc_kMLAUMr0hbdkNU,72
|
|
|
50
50
|
annet/annlib/jsontools.py,sha256=BS7s4rI8R9c_y3zz0zYl1l6con65oQ0MvfsC1dsXZts,5535
|
|
51
51
|
annet/annlib/lib.py,sha256=eJ4hcVuQ6pdYBzLs4YKCHFtq45idOfZCYp92XfF7_QI,15317
|
|
52
52
|
annet/annlib/output.py,sha256=_SjJ6G6bejvnTKqNHw6xeio0FT9oO3OIkLaOC3cEga4,7569
|
|
53
|
-
annet/annlib/patching.py,sha256=
|
|
54
|
-
annet/annlib/tabparser.py,sha256=
|
|
53
|
+
annet/annlib/patching.py,sha256=IZYW4kydEzBmRi_PZ8Lk0g7hx-sSYl2wjd6lDaI0D4k,21435
|
|
54
|
+
annet/annlib/tabparser.py,sha256=dLH6idK7zr6ZDhdIugjdohTHURcEIXQVN7vPIv5qsjA,31208
|
|
55
55
|
annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
|
|
56
56
|
annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
annet/annlib/netdev/db.py,sha256=fI_u5aya4l61mbYSjj4JwlVfi3s7obt2jqERSuXGRUI,1634
|
|
@@ -63,7 +63,7 @@ annet/annlib/netdev/views/hardware.py,sha256=3JCZLH7deIHhCguwPJTUX-WDvWjG_xt6BdS
|
|
|
63
63
|
annet/annlib/rbparser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
64
64
|
annet/annlib/rbparser/acl.py,sha256=RR8yPt6t96_IiyuKVbeZ-3x32cyhBAT2wC1y99oWBO8,3931
|
|
65
65
|
annet/annlib/rbparser/deploying.py,sha256=ACT8QNhDAhJx3ZKuGh2nYBOrpdka2qEKuLDxvQAGKLk,1649
|
|
66
|
-
annet/annlib/rbparser/ordering.py,sha256=
|
|
66
|
+
annet/annlib/rbparser/ordering.py,sha256=SmN_22pIJSIkmyT1-HSjWsqid7UJ0DgkqyQu7IO3bS4,2142
|
|
67
67
|
annet/annlib/rbparser/platform.py,sha256=Q9HtqmhyzV3JK_236_4LjC2wgp5fgxY6seDfWYl1oHU,1558
|
|
68
68
|
annet/annlib/rbparser/syntax.py,sha256=iZ7Y-4QQBw4L3UtjEh54qisiRDhobl7HZxFNdP8mi54,3577
|
|
69
69
|
annet/annlib/rulebook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -151,7 +151,7 @@ annet/rulebook/texts/cisco.rul,sha256=jgL5_xnSwd_H4E8cx4gcneSvJC5W1zz6_BWSb64iux
|
|
|
151
151
|
annet/rulebook/texts/huawei.deploy,sha256=uUsZCHUrC5Zyb_MePrR5svnE1QyGQlg7UxcKf00sJyg,10451
|
|
152
152
|
annet/rulebook/texts/huawei.order,sha256=_X2LmxD9FGcIcb8ziwc13Imy1tBtQJgafrQGmvHPZLM,10649
|
|
153
153
|
annet/rulebook/texts/huawei.rul,sha256=02Fi1RG4YYea2clHCluBuJDKNbT0hS9jtsk6_h6GK8k,12958
|
|
154
|
-
annet/rulebook/texts/juniper.order,sha256=
|
|
154
|
+
annet/rulebook/texts/juniper.order,sha256=PpxmcCgeaeP3TyYe3BWvtb24MKYV_BujjCH3HD4lsc8,256
|
|
155
155
|
annet/rulebook/texts/juniper.rul,sha256=EmtrEJZesnmc2nXjURRD2G0WOq4zLluI_PNupKhSOJs,2654
|
|
156
156
|
annet/rulebook/texts/nexus.deploy,sha256=9YNAQEw7aQxtYZJbE-dMD6qJrTzs_G92Ifrx3Ft4Wn4,1120
|
|
157
157
|
annet/rulebook/texts/nexus.order,sha256=AZMKCD5Zf_mBOlE36aMDvO4w5rdbepTz1Dsyv7xP9Qs,1834
|
|
@@ -178,10 +178,10 @@ annet_generators/rpl_example/generator.py,sha256=zndIGfV4ZlTxPgAGYs7bMQvTc_tYScO
|
|
|
178
178
|
annet_generators/rpl_example/items.py,sha256=Ez1RF5YhcXNCusBmeApIjRL3rBlMazNZd29Gpw1_IsA,766
|
|
179
179
|
annet_generators/rpl_example/mesh.py,sha256=z_WgfDZZ4xnyh3cSf75igyH09hGvtexEVwy1gCD_DzA,288
|
|
180
180
|
annet_generators/rpl_example/route_policy.py,sha256=z6nPb0VDeQtKD1NIg9sFvmUxBD5tVs2frfNIuKdM-5c,2318
|
|
181
|
-
annet-1.1.
|
|
182
|
-
annet-1.1.
|
|
183
|
-
annet-1.1.
|
|
184
|
-
annet-1.1.
|
|
185
|
-
annet-1.1.
|
|
186
|
-
annet-1.1.
|
|
187
|
-
annet-1.1.
|
|
181
|
+
annet-1.1.1.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
|
|
182
|
+
annet-1.1.1.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
|
|
183
|
+
annet-1.1.1.dist-info/METADATA,sha256=M6zpUiTyWxk5rg5WDIdJBv1XGl86GYa8v9_-4HlG26I,822
|
|
184
|
+
annet-1.1.1.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
185
|
+
annet-1.1.1.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
|
|
186
|
+
annet-1.1.1.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
|
|
187
|
+
annet-1.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|