gnetcli-adapter 2.2.3__tar.gz → 2.4.0__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.
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/PKG-INFO +3 -3
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/pyproject.toml +2 -2
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/src/gnetcli_adapter/gnetcli_adapter.py +28 -5
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/LICENSE +0 -0
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/README.md +0 -0
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/src/gnetcli_adapter/__init__.py +0 -0
- {gnetcli_adapter-2.2.3 → gnetcli_adapter-2.4.0}/src/gnetcli_adapter/progress_tracker.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gnetcli_adapter
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Gnetcli-server adapter for Annet
|
|
5
5
|
Author-email: Aleksandr Balezin <gescheit12@gmail.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,8 +12,8 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: annet>=
|
|
16
|
-
Requires-Dist: gnetclisdk>=1.0.
|
|
15
|
+
Requires-Dist: annet>=3.2.0
|
|
16
|
+
Requires-Dist: gnetclisdk>=1.0.90
|
|
17
17
|
Requires-Dist: pydantic_settings
|
|
18
18
|
Requires-Dist: pydantic
|
|
19
19
|
Requires-Dist: bandit[toml]==1.7.5 ; extra == "test"
|
|
@@ -109,7 +109,7 @@ class AppSettings(BaseSettings):
|
|
|
109
109
|
async def get_config(breed: str) -> List[str]:
|
|
110
110
|
if breed == "routeros":
|
|
111
111
|
return ["/export verbose", "/user export verbose", "/file print terse detail", "/user ssh-keys print terse"]
|
|
112
|
-
elif breed.startswith("ios") or breed.startswith("bcom") or breed.startswith("eltex"):
|
|
112
|
+
elif breed.startswith("ios") or breed.startswith("bcom") or breed.startswith("eltex") or breed.startswith("nxos"):
|
|
113
113
|
return ["show running-config"]
|
|
114
114
|
elif breed.startswith("jun"):
|
|
115
115
|
return ["show configuration"]
|
|
@@ -141,6 +141,16 @@ def cleanup():
|
|
|
141
141
|
atexit.register(cleanup)
|
|
142
142
|
|
|
143
143
|
|
|
144
|
+
async def gather_with_concurrency(n: int, *coros: list[asyncio.Task]):
|
|
145
|
+
semaphore = asyncio.Semaphore(n)
|
|
146
|
+
|
|
147
|
+
async def sem_coro(coro):
|
|
148
|
+
async with semaphore:
|
|
149
|
+
return await coro
|
|
150
|
+
|
|
151
|
+
return await asyncio.gather(*(sem_coro(c) for c in coros))
|
|
152
|
+
|
|
153
|
+
|
|
144
154
|
def get_device_ip(dev: Device) -> Optional[str]:
|
|
145
155
|
if isinstance(dev, NetboxDevice):
|
|
146
156
|
if dev.primary_ip:
|
|
@@ -315,7 +325,7 @@ def parse_annet_qa(qa: list[annet.annlib.command.Question]) -> list[QA]:
|
|
|
315
325
|
q = annet_qa.question
|
|
316
326
|
if annet_qa.is_regexp:
|
|
317
327
|
q = f"/{annet_qa.question}/"
|
|
318
|
-
res.append(QA(question=q, answer=annet_qa.answer))
|
|
328
|
+
res.append(QA(question=q, answer=annet_qa.answer, not_send_nl=annet_qa.not_send_nl))
|
|
319
329
|
return res
|
|
320
330
|
|
|
321
331
|
|
|
@@ -381,8 +391,19 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
|
|
|
381
391
|
if progress_bar:
|
|
382
392
|
for host, cmds in deploy_cmds.items():
|
|
383
393
|
progress_bar.set_progress(host.fqdn, 0, len(cmds))
|
|
394
|
+
max_parallel = 1000
|
|
395
|
+
try:
|
|
396
|
+
# temporary, for supporting of old annet
|
|
397
|
+
arg_max_parallel = args.max_parallel
|
|
398
|
+
if arg_max_parallel > 0:
|
|
399
|
+
max_parallel = arg_max_parallel
|
|
400
|
+
except Exception:
|
|
401
|
+
pass
|
|
384
402
|
deploy_items = deploy_cmds.items()
|
|
385
|
-
result = await
|
|
403
|
+
result = await gather_with_concurrency(
|
|
404
|
+
max_parallel,
|
|
405
|
+
*[asyncio.Task(self.deploy(device, cmds, args, progress_bar)) for device, cmds in deploy_items],
|
|
406
|
+
)
|
|
386
407
|
res = DeployResult(hostnames=[], results={}, durations={}, original_states={})
|
|
387
408
|
res.add_results(results={dev.fqdn: dev_res for (dev, _), dev_res in zip(deploy_items, result)})
|
|
388
409
|
return res
|
|
@@ -533,8 +554,10 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
|
|
|
533
554
|
res = apply_deploy_rulebook(hw=hw, cmd_paths=cmd_paths, do_finalize=do_finalize, do_commit=do_commit)
|
|
534
555
|
return res
|
|
535
556
|
|
|
536
|
-
def build_configuration_cmdlist(
|
|
537
|
-
|
|
557
|
+
def build_configuration_cmdlist(
|
|
558
|
+
self, hw: HardwareView, do_finalize: bool = True, do_commit: bool = True, path: str = None,
|
|
559
|
+
):
|
|
560
|
+
res = common.apply(hw, do_commit=do_commit, do_finalize=do_finalize, path=path)
|
|
538
561
|
return res
|
|
539
562
|
|
|
540
563
|
def build_exit_cmdlist(self, hw: HardwareView) -> CommandList:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|