annet 0.12.7__tar.gz → 0.12.9__tar.gz

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.

Files changed (144) hide show
  1. {annet-0.12.7/annet.egg-info → annet-0.12.9}/PKG-INFO +1 -1
  2. {annet-0.12.7 → annet-0.12.9}/annet/executor.py +18 -13
  3. {annet-0.12.7 → annet-0.12.9}/annet/gen.py +22 -9
  4. {annet-0.12.7 → annet-0.12.9}/annet/lib.py +1 -0
  5. {annet-0.12.7 → annet-0.12.9/annet.egg-info}/PKG-INFO +1 -1
  6. {annet-0.12.7 → annet-0.12.9}/AUTHORS +0 -0
  7. {annet-0.12.7 → annet-0.12.9}/LICENSE +0 -0
  8. {annet-0.12.7 → annet-0.12.9}/MANIFEST.in +0 -0
  9. {annet-0.12.7 → annet-0.12.9}/README.md +0 -0
  10. {annet-0.12.7 → annet-0.12.9}/annet/__init__.py +0 -0
  11. {annet-0.12.7 → annet-0.12.9}/annet/adapters/__init__.py +0 -0
  12. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/__init__.py +0 -0
  13. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/__init__.py +0 -0
  14. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/client.py +0 -0
  15. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/manufacturer.py +0 -0
  16. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/models.py +0 -0
  17. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/query.py +0 -0
  18. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/status_client.py +0 -0
  19. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/common/storage_opts.py +0 -0
  20. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/provider.py +0 -0
  21. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v24/__init__.py +0 -0
  22. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v24/api_models.py +0 -0
  23. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v24/client.py +0 -0
  24. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v24/storage.py +0 -0
  25. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v37/__init__.py +0 -0
  26. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v37/api_models.py +0 -0
  27. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v37/client.py +0 -0
  28. {annet-0.12.7 → annet-0.12.9}/annet/adapters/netbox/v37/storage.py +0 -0
  29. {annet-0.12.7 → annet-0.12.9}/annet/annet.py +0 -0
  30. {annet-0.12.7 → annet-0.12.9}/annet/annlib/__init__.py +0 -0
  31. {annet-0.12.7 → annet-0.12.9}/annet/annlib/command.py +0 -0
  32. {annet-0.12.7 → annet-0.12.9}/annet/annlib/diff.py +0 -0
  33. {annet-0.12.7 → annet-0.12.9}/annet/annlib/errors.py +0 -0
  34. {annet-0.12.7 → annet-0.12.9}/annet/annlib/filter_acl.py +0 -0
  35. {annet-0.12.7 → annet-0.12.9}/annet/annlib/jsontools.py +0 -0
  36. {annet-0.12.7 → annet-0.12.9}/annet/annlib/lib.py +0 -0
  37. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/__init__.py +0 -0
  38. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/db.py +0 -0
  39. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/devdb/__init__.py +0 -0
  40. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/devdb/data/devdb.json +0 -0
  41. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/views/__init__.py +0 -0
  42. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/views/dump.py +0 -0
  43. {annet-0.12.7 → annet-0.12.9}/annet/annlib/netdev/views/hardware.py +0 -0
  44. {annet-0.12.7 → annet-0.12.9}/annet/annlib/output.py +0 -0
  45. {annet-0.12.7 → annet-0.12.9}/annet/annlib/patching.py +0 -0
  46. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/__init__.py +0 -0
  47. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/acl.py +0 -0
  48. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/deploying.py +0 -0
  49. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/ordering.py +0 -0
  50. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/platform.py +0 -0
  51. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rbparser/syntax.py +0 -0
  52. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rulebook/__init__.py +0 -0
  53. {annet-0.12.7 → annet-0.12.9}/annet/annlib/rulebook/common.py +0 -0
  54. {annet-0.12.7 → annet-0.12.9}/annet/annlib/tabparser.py +0 -0
  55. {annet-0.12.7 → annet-0.12.9}/annet/annlib/types.py +0 -0
  56. {annet-0.12.7 → annet-0.12.9}/annet/api/__init__.py +0 -0
  57. {annet-0.12.7 → annet-0.12.9}/annet/argparse.py +0 -0
  58. {annet-0.12.7 → annet-0.12.9}/annet/cli.py +0 -0
  59. {annet-0.12.7 → annet-0.12.9}/annet/cli_args.py +0 -0
  60. {annet-0.12.7 → annet-0.12.9}/annet/configs/context.yml +0 -0
  61. {annet-0.12.7 → annet-0.12.9}/annet/configs/logging.yaml +0 -0
  62. {annet-0.12.7 → annet-0.12.9}/annet/connectors.py +0 -0
  63. {annet-0.12.7 → annet-0.12.9}/annet/deploy.py +0 -0
  64. {annet-0.12.7 → annet-0.12.9}/annet/diff.py +0 -0
  65. {annet-0.12.7 → annet-0.12.9}/annet/filtering.py +0 -0
  66. {annet-0.12.7 → annet-0.12.9}/annet/generators/__init__.py +0 -0
  67. {annet-0.12.7 → annet-0.12.9}/annet/generators/base.py +0 -0
  68. {annet-0.12.7 → annet-0.12.9}/annet/generators/common/__init__.py +0 -0
  69. {annet-0.12.7 → annet-0.12.9}/annet/generators/common/initial.py +0 -0
  70. {annet-0.12.7 → annet-0.12.9}/annet/generators/entire.py +0 -0
  71. {annet-0.12.7 → annet-0.12.9}/annet/generators/exceptions.py +0 -0
  72. {annet-0.12.7 → annet-0.12.9}/annet/generators/jsonfragment.py +0 -0
  73. {annet-0.12.7 → annet-0.12.9}/annet/generators/partial.py +0 -0
  74. {annet-0.12.7 → annet-0.12.9}/annet/generators/perf.py +0 -0
  75. {annet-0.12.7 → annet-0.12.9}/annet/generators/ref.py +0 -0
  76. {annet-0.12.7 → annet-0.12.9}/annet/generators/result.py +0 -0
  77. {annet-0.12.7 → annet-0.12.9}/annet/hardware.py +0 -0
  78. {annet-0.12.7 → annet-0.12.9}/annet/implicit.py +0 -0
  79. {annet-0.12.7 → annet-0.12.9}/annet/output.py +0 -0
  80. {annet-0.12.7 → annet-0.12.9}/annet/parallel.py +0 -0
  81. {annet-0.12.7 → annet-0.12.9}/annet/patching.py +0 -0
  82. {annet-0.12.7 → annet-0.12.9}/annet/reference.py +0 -0
  83. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/__init__.py +0 -0
  84. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/arista/__init__.py +0 -0
  85. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/arista/iface.py +0 -0
  86. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/aruba/__init__.py +0 -0
  87. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/aruba/ap_env.py +0 -0
  88. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/aruba/misc.py +0 -0
  89. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/cisco/__init__.py +0 -0
  90. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/cisco/iface.py +0 -0
  91. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/cisco/misc.py +0 -0
  92. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/cisco/vlandb.py +0 -0
  93. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/common.py +0 -0
  94. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/deploying.py +0 -0
  95. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/__init__.py +0 -0
  96. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/aaa.py +0 -0
  97. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/bgp.py +0 -0
  98. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/iface.py +0 -0
  99. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/misc.py +0 -0
  100. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/huawei/vlandb.py +0 -0
  101. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/juniper/__init__.py +0 -0
  102. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/nexus/__init__.py +0 -0
  103. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/nexus/iface.py +0 -0
  104. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/patching.py +0 -0
  105. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/ribbon/__init__.py +0 -0
  106. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/arista.deploy +0 -0
  107. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/arista.order +0 -0
  108. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/arista.rul +0 -0
  109. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/aruba.deploy +0 -0
  110. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/aruba.order +0 -0
  111. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/aruba.rul +0 -0
  112. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/cisco.deploy +0 -0
  113. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/cisco.order +0 -0
  114. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/cisco.rul +0 -0
  115. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/huawei.deploy +0 -0
  116. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/huawei.order +0 -0
  117. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/huawei.rul +0 -0
  118. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/juniper.rul +0 -0
  119. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/nexus.deploy +0 -0
  120. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/nexus.order +0 -0
  121. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/nexus.rul +0 -0
  122. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/nokia.rul +0 -0
  123. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/pc.order +0 -0
  124. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/pc.rul +0 -0
  125. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/ribbon.deploy +0 -0
  126. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/ribbon.rul +0 -0
  127. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/routeros.order +0 -0
  128. {annet-0.12.7 → annet-0.12.9}/annet/rulebook/texts/routeros.rul +0 -0
  129. {annet-0.12.7 → annet-0.12.9}/annet/storage.py +0 -0
  130. {annet-0.12.7 → annet-0.12.9}/annet/tabparser.py +0 -0
  131. {annet-0.12.7 → annet-0.12.9}/annet/text_term_format.py +0 -0
  132. {annet-0.12.7 → annet-0.12.9}/annet/tracing.py +0 -0
  133. {annet-0.12.7 → annet-0.12.9}/annet/types.py +0 -0
  134. {annet-0.12.7 → annet-0.12.9}/annet.egg-info/SOURCES.txt +0 -0
  135. {annet-0.12.7 → annet-0.12.9}/annet.egg-info/dependency_links.txt +0 -0
  136. {annet-0.12.7 → annet-0.12.9}/annet.egg-info/entry_points.txt +0 -0
  137. {annet-0.12.7 → annet-0.12.9}/annet.egg-info/requires.txt +0 -0
  138. {annet-0.12.7 → annet-0.12.9}/annet.egg-info/top_level.txt +0 -0
  139. {annet-0.12.7 → annet-0.12.9}/annet_generators/__init__.py +0 -0
  140. {annet-0.12.7 → annet-0.12.9}/annet_generators/example/__init__.py +0 -0
  141. {annet-0.12.7 → annet-0.12.9}/annet_generators/example/lldp.py +0 -0
  142. {annet-0.12.7 → annet-0.12.9}/requirements.txt +0 -0
  143. {annet-0.12.7 → annet-0.12.9}/setup.cfg +0 -0
  144. {annet-0.12.7 → annet-0.12.9}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.12.7
3
+ Version: 0.12.9
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -359,7 +359,7 @@ async def bulk(
359
359
  tasks = []
360
360
  res = {}
361
361
  pending = set()
362
- tasks_to_hostname = {}
362
+ tasks_to_device = {}
363
363
  time_of_start = {}
364
364
  deploy_durations = {}
365
365
  now = None
@@ -391,10 +391,15 @@ async def bulk(
391
391
  return task.result()
392
392
 
393
393
  for device in devices:
394
- conn = await executor.amake_connection(device=device)
394
+ try:
395
+ conn = await executor.amake_connection(device=device)
396
+ except Exception as exc:
397
+ _logger.error("failed to connect to %s %r", device.hostname, exc)
398
+ res[device] = exc
399
+ continue
395
400
  start_hook(device)
396
401
  task = asyncio.create_task(coro_gen(conn=conn, device=device, **kwargs))
397
- tasks_to_hostname[task] = device
402
+ tasks_to_device[task] = device
398
403
  tasks.append(task)
399
404
  try:
400
405
  ndone = 0
@@ -415,21 +420,21 @@ async def bulk(
415
420
 
416
421
  now = time.monotonic()
417
422
  for task in done:
418
- hostname = tasks_to_hostname[task]
419
- res[hostname] = end_hook(hostname, task)
423
+ device = tasks_to_device[task]
424
+ res[device] = end_hook(device, task)
420
425
  ndone += 1
421
426
  except CancelAllTasks:
422
427
  exc = asyncio.CancelledError()
423
428
 
424
429
  now = time.monotonic()
425
- for hostname, task in _get_remaining(tasks, pending, tasks_to_hostname):
426
- res[hostname] = exc
430
+ for device, task in _get_remaining(tasks, pending, tasks_to_device):
431
+ res[device] = exc
427
432
 
428
- if hostname in time_of_start:
429
- duration = now - time_of_start[hostname]
433
+ if device.hostname in time_of_start:
434
+ duration = now - time_of_start[device.hostname]
430
435
  else:
431
436
  duration = None
432
- deploy_durations[hostname] = duration
437
+ deploy_durations[device.hostname] = duration
433
438
 
434
439
  if not asyncio.iscoroutine(task):
435
440
  _logger.info("task %s", task)
@@ -471,11 +476,11 @@ class CancelAllTasks(Exception):
471
476
  pass
472
477
 
473
478
 
474
- def _get_remaining(tasks, pending, tasks_to_hostname):
479
+ def _get_remaining(tasks, pending, tasks_to_device):
475
480
  for task in pending:
476
- yield (tasks_to_hostname[task], task)
481
+ yield (tasks_to_device[task], task)
477
482
  for task in tasks:
478
- yield (tasks_to_hostname[task], task)
483
+ yield (tasks_to_device[task], task)
479
484
 
480
485
 
481
486
  _platform = platform.system()
@@ -79,6 +79,19 @@ class DeviceGenerators:
79
79
  for gen in gen_list:
80
80
  yield gen
81
81
 
82
+ def for_devices(self, devices: Iterable[Device]) -> "DeviceGenerators":
83
+ result = DeviceGenerators()
84
+ for device in devices:
85
+ if device in self.partial:
86
+ result.partial[device] = self.partial[device]
87
+ if device in self.ref:
88
+ result.ref[device] = self.ref[device]
89
+ if device in self.entire:
90
+ result.entire[device] = self.entire[device]
91
+ if device in self.json_fragment:
92
+ result.json_fragment[device] = self.json_fragment[device]
93
+ return result
94
+
82
95
  def file_gens(self, device: Any) -> Iterator[Union[Entire, JSONFragment]]:
83
96
  """Iterate over generators that generate files or file parts."""
84
97
  yield from itertools.chain(
@@ -514,7 +527,7 @@ def worker(device_id, args: ShowGenOptions, stdin, loader: "Loader", filterer: F
514
527
 
515
528
 
516
529
  def old_new_worker(device_id, args: DeployOptions, config, stdin, loader: "Loader", filterer: Filterer):
517
- yield from old_new(
530
+ for res in old_new(
518
531
  args,
519
532
  config=config,
520
533
  loader=loader,
@@ -523,7 +536,10 @@ def old_new_worker(device_id, args: DeployOptions, config, stdin, loader: "Loade
523
536
  device_ids=[device_id],
524
537
  no_new=args.clear,
525
538
  do_files_download=True,
526
- )
539
+ ):
540
+ if res.err is not None and not args.tolerate_fails:
541
+ raise res.err
542
+ yield res
527
543
 
528
544
 
529
545
  class OldNewParallel(Parallel):
@@ -538,12 +554,13 @@ class OldNewParallel(Parallel):
538
554
  filterer=filterer,
539
555
  )
540
556
  self.tune_args(args)
557
+ self.tolerate_fails = args.tolerate_fails
541
558
 
542
559
  def generated_configs(self, devices: List[Device]) -> Generator[OldNewResult, None, None]:
543
560
  devices_by_id = {device.id: device for device in devices}
544
561
  device_ids = list(devices_by_id)
545
562
 
546
- for task_result in self.irun(device_ids):
563
+ for task_result in self.irun(device_ids, self.tolerate_fails):
547
564
  if task_result.exc is not None:
548
565
  device = devices_by_id.pop(task_result.device_id)
549
566
  yield OldNewResult(device=device, err=task_result.exc)
@@ -711,7 +728,7 @@ def _old_new_get_config_cli(ctx: OldNewDeviceContext, device: Device) -> str:
711
728
  if text is None:
712
729
  exc = (ctx.failed_running.get(device) or
713
730
  Exception("I can't get device config and I don't know why"))
714
- get_logger(host=device.hostname).error("config error %s", exc)
731
+ get_logger(host=device.hostname).error("config error %r", exc)
715
732
  raise exc
716
733
  elif ctx.config == "-":
717
734
  text = ctx.stdin["config"]
@@ -868,8 +885,4 @@ class Loader:
868
885
  return []
869
886
 
870
887
  def resolve_gens(self, devices: Iterable[Device]) -> DeviceGenerators:
871
- if self._gens is not None:
872
- return self._gens
873
-
874
- with tracing_connector.get().start_as_current_span("Resolve gens"):
875
- return _old_resolve_gens(self._args, self._storage, devices)
888
+ return self._gens.for_devices(devices)
@@ -84,6 +84,7 @@ def get_context_path(touch: Optional[bool] = False) -> str:
84
84
  return str(path)
85
85
 
86
86
 
87
+ @lru_cache(maxsize=1)
87
88
  def get_context() -> dict:
88
89
  with open(get_context_path()) as f:
89
90
  raw = yaml.safe_load(f)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.12.7
3
+ Version: 0.12.9
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes