annet 0.16.4__py3-none-any.whl → 0.16.6__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/annlib/patching.py CHANGED
@@ -180,6 +180,9 @@ class Orderer:
180
180
  return (f_order or 0), cmd_direct, odict(children), f_rule
181
181
 
182
182
  def order_config(self, config):
183
+ if self.vendor not in platform.VENDOR_REVERSES:
184
+ return config
185
+
183
186
  ordered = []
184
187
  reverse_prefix = platform.VENDOR_REVERSES[self.vendor]
185
188
  if not config:
annet/api/__init__.py CHANGED
@@ -359,8 +359,14 @@ def diff(
359
359
  pc_diff_files.sort(key=lambda f: f.label)
360
360
  ret[device] = PCDiff(hostname=device.hostname, diff_files=pc_diff_files)
361
361
  elif old is not None:
362
+ orderer = patching.Orderer.from_hw(device.hw)
362
363
  rb = rulebook.get_rulebook(device.hw)
363
- diff_tree = patching.make_diff(old, new, rb, [acl_rules, res.filter_acl_rules])
364
+ diff_tree = patching.make_diff(
365
+ old,
366
+ orderer.order_config(new),
367
+ rb,
368
+ [acl_rules, res.filter_acl_rules],
369
+ )
364
370
  diff_tree = patching.strip_unchanged(diff_tree)
365
371
  ret[device] = diff_tree
366
372
 
annet/gen.py CHANGED
@@ -27,7 +27,6 @@ from contextlog import get_logger
27
27
 
28
28
  from annet import generators, implicit, patching, tabparser, tracing
29
29
  from annet.annlib import jsontools
30
- from annet.annlib.rbparser import platform
31
30
  from annet.annlib.rbparser.acl import compile_acl_text
32
31
  from annet.cli_args import DeployOptions, GenOptions, ShowGenOptions
33
32
  from annet.deploy import scrub_config, get_fetcher
@@ -512,12 +511,11 @@ def worker(device_id, args: ShowGenOptions, stdin, loader: "Loader", filterer: F
512
511
  for (path, (data, _)) in sorted(new_file_fragments.items(), key=itemgetter(0)):
513
512
  dumped_data = json.dumps(data, indent=4, sort_keys=True, ensure_ascii=False)
514
513
  yield (output_driver.entire_config_dest_path(device, path), dumped_data, False)
515
-
516
514
  # Consider result of partial run empty and create an empty dest file
517
515
  # only if there are some acl rules that has been matched.
518
516
  # Otherwise treat it as if no supported generators have been found.
519
517
  acl_rules = res.get_acl_rules(args.acl_safe)
520
- if device.hw.vendor in platform.VENDOR_REVERSES and acl_rules:
518
+ if acl_rules:
521
519
  orderer = patching.Orderer.from_hw(device.hw)
522
520
  yield (output_driver.cfg_file_names(device)[0],
523
521
  format_config_blocks(
@@ -383,8 +383,15 @@ def _get_generators(module_paths: Union[List[str], dict], storage, device=None):
383
383
  else:
384
384
  modules = []
385
385
  seen = set()
386
+ matched_property = None
386
387
  for prop, prop_modules in module_paths.get("per_device_property", {}).items():
387
388
  if getattr(device, prop, False) is True:
389
+ if matched_property is not None:
390
+ raise RuntimeError(
391
+ f"Device {device.hostname} is matched by more than one "
392
+ f"per_device_property: {matched_property} and {prop}"
393
+ )
394
+ matched_property = prop
388
395
  for module in prop_modules:
389
396
  if module not in seen:
390
397
  modules.append(module)
annet/lib.py CHANGED
@@ -44,7 +44,7 @@ _DEFAULT_CONTEXT_PATH: Optional[str] = None # defaults to ~/.annet/context.yml
44
44
 
45
45
  def get_homedir_path() -> str:
46
46
  if _HOMEDIR_PATH is None:
47
- set_homedir_path("~/.annet/")
47
+ set_homedir_path(os.path.expanduser("~/.annet/"))
48
48
  return _HOMEDIR_PATH
49
49
 
50
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.16.4
3
+ Version: 0.16.6
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -8,10 +8,10 @@ annet/deploy.py,sha256=pM7r8ipk7y-b4OIenc8FMqZpy5F6TmKdo8DDUJNRBlY,18956
8
8
  annet/diff.py,sha256=zLcaCnb4lZRUb7frpH1CstQ3kacRcCblZs1uLG8J5lk,3391
9
9
  annet/executor.py,sha256=FrYAUuh2TpSVX42SlTN_PhuSHmXG4Wj1nieY9Wqv9so,19122
10
10
  annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
11
- annet/gen.py,sha256=Xy4VyK8pfH97wZ8Zv2bD2SNxhEx9-S93Zp7pQm-VnuU,33592
11
+ annet/gen.py,sha256=rOAveprvBaEXbLyaQUhQ0QtOvcDfndlIOpchNhu8M1U,33499
12
12
  annet/hardware.py,sha256=_iR28dWiPtt6ZYdk-qg1sxazkSRJE3ukqKB-fFFfQak,1141
13
13
  annet/implicit.py,sha256=_3eY9NKqpLUm25vlJIP2cHN4gdTgzO6rG6mwCKJYMnQ,5439
14
- annet/lib.py,sha256=z-qhs68ap0xHZjGdn-vTUqE91IPaUM6eU_Pee7Exniw,4218
14
+ annet/lib.py,sha256=lOdz3UJFYkO0wnuzIRRq3FpULQliqBtfmGmKOGVFO4Q,4238
15
15
  annet/output.py,sha256=BNPzjuhMa7gSJ8ze_1O-Ey0tTxSyhAiwfztZMQwhMzk,7176
16
16
  annet/parallel.py,sha256=hLkzEht0KhzmzUWDdO4QFYQHzhxs3wPlTA8DxbB2ziw,17160
17
17
  annet/patching.py,sha256=nILbY5oJajN0b1j3f0HEJm05H3HVThnWvB7vDVh7UQw,559
@@ -43,7 +43,7 @@ annet/annlib/filter_acl.py,sha256=0w1VF6WcONiTYTQh0yWi6_j9rCTc_kMLAUMr0hbdkNU,72
43
43
  annet/annlib/jsontools.py,sha256=4-2r_mPNbecKreuUr3vlLv3ykJdhRmyUD8AdF2nSAxc,5430
44
44
  annet/annlib/lib.py,sha256=eJ4hcVuQ6pdYBzLs4YKCHFtq45idOfZCYp92XfF7_QI,15317
45
45
  annet/annlib/output.py,sha256=_SjJ6G6bejvnTKqNHw6xeio0FT9oO3OIkLaOC3cEga4,7569
46
- annet/annlib/patching.py,sha256=Ojfl-LJHHTBLWx_6gV_02FjigqRt1DNaJD64L9iWp_0,19854
46
+ annet/annlib/patching.py,sha256=2CpAT3T43IUFJR57qTYSwjQ0smg0uHWN43df4n1WArs,19937
47
47
  annet/annlib/tabparser.py,sha256=9ry4DxZn6ibShd7fFtH_TElm3lT5tgMGkHcpGXNVuUY,25997
48
48
  annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
49
49
  annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -61,10 +61,10 @@ annet/annlib/rbparser/platform.py,sha256=QI9KuCrel3X19PW5u56hWi1UhJ9mxlTYtUIpmcm
61
61
  annet/annlib/rbparser/syntax.py,sha256=iZ7Y-4QQBw4L3UtjEh54qisiRDhobl7HZxFNdP8mi54,3577
62
62
  annet/annlib/rulebook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  annet/annlib/rulebook/common.py,sha256=Kd9Xout0xC6ZZDnyaORx0W-1kSM-gTgjQbp1iIXWxic,16489
64
- annet/api/__init__.py,sha256=KWoJfo2ByHC8EsIhU4szuhGwE8OKYS7Y1TN2xkhe0qA,33563
64
+ annet/api/__init__.py,sha256=7EB3d89kGXKf4Huw7cqyOULTGC9ydL4sHiVw8K0Aeqg,33722
65
65
  annet/configs/context.yml,sha256=rXbeCmeYGaCEVVncwdouZIx5O7-PzABe4q-tfke0sSA,389
66
66
  annet/configs/logging.yaml,sha256=Hu42lRK248dssp9TgkbHCaZNl0E6f4IChGb0XaQnTVo,970
67
- annet/generators/__init__.py,sha256=ACMH9UQ4I3uq2b8nDzOn2dgYxreDq4_3ojOGwht0-No,15543
67
+ annet/generators/__init__.py,sha256=rQAA_ghWRY2PcPYU6HArtt6sPEJXuBEEAvyUT9uDDms,15913
68
68
  annet/generators/base.py,sha256=rgQLcQBPZm4ecbKmRhVOpBR-GFJAiVfdb_y5f2-LUR8,3670
69
69
  annet/generators/entire.py,sha256=7WySkVaXNT3ZAiHcQ0JUKdlhGJAN8cNUxF6c7ilYnO8,2928
70
70
  annet/generators/exceptions.py,sha256=GPXTBgn2xZ3Ev_bdOPlfCLGRC1kQHe_dEq88S-uyi5s,151
@@ -133,10 +133,10 @@ annet/rulebook/texts/routeros.rul,sha256=ipfxjj0mjFef6IsUlupqx4BY_Je_OUb8u_U1019
133
133
  annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
134
  annet_generators/example/__init__.py,sha256=zVd8_DrXuOASrNzg2Ab94rPyvJff83L-_HppDFxnUjM,228
135
135
  annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn6yo,2100
136
- annet-0.16.4.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
137
- annet-0.16.4.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
138
- annet-0.16.4.dist-info/METADATA,sha256=EbbpV0pTkqx0-Q0g3IZgFr9wyQkIHAxeYrMFOafVOm8,694
139
- annet-0.16.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
140
- annet-0.16.4.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
141
- annet-0.16.4.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
142
- annet-0.16.4.dist-info/RECORD,,
136
+ annet-0.16.6.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
137
+ annet-0.16.6.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
138
+ annet-0.16.6.dist-info/METADATA,sha256=IdPHd6vyAZE-Esfiin603XZKEGGSFT1lpbi9ovqLck8,694
139
+ annet-0.16.6.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
140
+ annet-0.16.6.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
141
+ annet-0.16.6.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
142
+ annet-0.16.6.dist-info/RECORD,,
File without changes