gnetcli-adapter 2.4.1__tar.gz → 2.4.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gnetcli_adapter
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: Gnetcli-server adapter for Annet
5
5
  Author-email: Aleksandr Balezin <gescheit12@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -142,6 +142,8 @@ atexit.register(cleanup)
142
142
 
143
143
 
144
144
  async def gather_with_concurrency(n: int, *coros: list[asyncio.Task]):
145
+ if n == 0:
146
+ return await asyncio.gather(*coros)
145
147
  semaphore = asyncio.Semaphore(n)
146
148
 
147
149
  async def sem_coro(coro):
@@ -400,10 +402,13 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
400
402
  except Exception:
401
403
  pass
402
404
  deploy_items = deploy_cmds.items()
403
- result = await gather_with_concurrency(
404
- max_parallel,
405
- *[self.deploy(device, cmds, args, progress_bar) for device, cmds in deploy_items],
406
- )
405
+ if max_parallel == 1:
406
+ result = await self.serial_deploy(deploy_items, args, progress_bar)
407
+ else:
408
+ result = await gather_with_concurrency(
409
+ max_parallel,
410
+ *[self.deploy(device, cmds, args, progress_bar) for device, cmds in deploy_items],
411
+ )
407
412
  res = DeployResult(hostnames=[], results={}, durations={}, original_states={})
408
413
  res.add_results(results={dev.fqdn: dev_res for (dev, _), dev_res in zip(deploy_items, result)})
409
414
  return res
@@ -440,6 +445,22 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
440
445
  tracker.add_tracker(FileProgressTracker(device, self.logs_dir))
441
446
  return tracker
442
447
 
448
+ async def serial_deploy(self, deploy_items, args, progress_bar: ProgressBar | None = None):
449
+ res = {}
450
+ for device, cmds in deploy_items:
451
+ if progress_bar:
452
+ try:
453
+ # hack, no way to do this using interface ProgressBar
454
+ for no, fqdn in enumerate(progress_bar.tiles_params):
455
+ if fqdn == device.fqdn:
456
+ progress_bar._set_active_tile(no)
457
+ break
458
+ except Exception:
459
+ pass
460
+ dev_res = await self.deploy(device, cmds, args, progress_bar)
461
+ res[device] = dev_res
462
+ return res
463
+
443
464
  async def deploy(
444
465
  self,
445
466
  device: Device,
File without changes