gnetcli-adapter 2.4.2__tar.gz → 2.5.1__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.2
3
+ Version: 2.5.1
4
4
  Summary: Gnetcli-server adapter for Annet
5
5
  Author-email: Aleksandr Balezin <gescheit12@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -12,6 +12,7 @@ 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: exceptiongroup>=1.1.3; python_version<'3.11'
15
16
  Requires-Dist: annet>=3.2.0
16
17
  Requires-Dist: gnetclisdk>=1.0.90
17
18
  Requires-Dist: pydantic_settings
@@ -5,6 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
  [project]
6
6
  name = "gnetcli_adapter"
7
7
  dependencies = [
8
+ "exceptiongroup>=1.1.3; python_version<'3.11'",
8
9
  "annet>=3.2.0",
9
10
  "gnetclisdk>=1.0.90",
10
11
  "pydantic_settings",
@@ -32,6 +32,14 @@ import threading
32
32
  import atexit
33
33
  import shutil
34
34
  import os.path
35
+ try:
36
+ from builtins import ( # type: ignore[attr-defined, unused-ignore]
37
+ ExceptionGroup,
38
+ )
39
+ except ImportError:
40
+ from exceptiongroup import ( # type: ignore[no-redef, import-not-found, unused-ignore]
41
+ ExceptionGroup,
42
+ )
35
43
 
36
44
  breed_to_device = {
37
45
  "routeros": "ros",
@@ -160,6 +168,16 @@ def get_device_ip(dev: Device) -> Optional[str]:
160
168
  for iface in dev.interfaces:
161
169
  for ip in iface.ip_addresses:
162
170
  return ip.address.split("/")[0]
171
+ else:
172
+ try:
173
+ if dev.primary_ip:
174
+ return dev.primary_ip.address.split("/")[0]
175
+ if dev.interfaces:
176
+ for iface in dev.interfaces:
177
+ for ip in iface.ip_addresses:
178
+ return ip.address.split("/")[0]
179
+ except Exception as e:
180
+ _logger.warning("get device ip error: %s", e)
163
181
  return None
164
182
 
165
183
 
@@ -467,7 +485,7 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
467
485
  cmds: CommandList,
468
486
  args: DeployOptions,
469
487
  progress_bar: ProgressBar | None = None,
470
- ) -> tuple[list[Exception], list[pb.CMDResult]]:
488
+ ) -> Exception | None:
471
489
  gnetcli_device = breed_to_device.get(device.breed, device.breed)
472
490
  ip = get_device_ip(device)
473
491
  host_params = HostParams(
@@ -506,7 +524,10 @@ class GnetcliDeployer(DeployDriver, AdapterWithConfig, AdapterWithName):
506
524
  tracker.finish_err(f"Seen {len(seen_exc)} exceptions")
507
525
  else:
508
526
  tracker.finish_ok("All done")
509
- return seen_exc, results
527
+
528
+ if seen_exc:
529
+ return ExceptionGroup("Deploy failed with exceptions", seen_exc)
530
+ return None
510
531
 
511
532
  async def _deploy(
512
533
  self,
File without changes