fix: resolve import paths, remove async context managers, clean up CLI

- Change absolute imports to relative imports in gnmi module
- Remove async context manager methods (pygnmi is synchronous)
- Remove unimplemented --depth option from CLI
- Update documentation to reflect sync-only usage
This commit is contained in:
darnodo
2025-12-31 17:44:21 +01:00
parent 8e460225c2
commit 5b3517c355
3 changed files with 4 additions and 19 deletions

View File

@@ -254,12 +254,6 @@ def discover_capabilities(
default="all", default="all",
help="Type of data to retrieve (default: all)", help="Type of data to retrieve (default: all)",
) )
@click.option(
"--depth", "-d",
type=int,
default=None,
help="Maximum depth to explore (not implemented yet)",
)
def discover_get( def discover_get(
target: str, target: str,
username: str, username: str,
@@ -268,7 +262,6 @@ def discover_get(
output: str, output: str,
path: str, path: str,
data_type: str, data_type: str,
depth: int | None,
): ):
""" """
Get configuration or state data at a YANG path. Get configuration or state data at a YANG path.

View File

@@ -7,17 +7,17 @@ Arista devices using pygnmi.
Usage: Usage:
from gnmi import GNMIClient from gnmi import GNMIClient
async with GNMIClient( with GNMIClient(
host="leaf1", host="leaf1",
port=6030, port=6030,
username="admin", username="admin",
password="admin", password="admin",
insecure=True insecure=True
) as client: ) as client:
caps = await client.capabilities() caps = client.capabilities()
print(caps) print(caps)
""" """
from src.gnmi.client import GNMIClient, GNMIConnectionError, GNMIError, GNMIPathError from .client import GNMIClient, GNMIConnectionError, GNMIError, GNMIPathError
__all__ = ["GNMIClient", "GNMIError", "GNMIConnectionError", "GNMIPathError"] __all__ = ["GNMIClient", "GNMIError", "GNMIConnectionError", "GNMIPathError"]

View File

@@ -159,14 +159,6 @@ class GNMIClient:
pass # Ignore cleanup errors pass # Ignore cleanup errors
self._client = None self._client = None
async def __aenter__(self) -> GNMIClient:
"""Enter async context manager."""
return self.__enter__()
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
"""Exit async context manager."""
self.__exit__(exc_type, exc_val, exc_tb)
# ========================================================================= # =========================================================================
# gNMI Operations # gNMI Operations
# ========================================================================= # =========================================================================
@@ -288,7 +280,7 @@ class GNMIClient:
try: try:
value = json.loads(value) value = json.loads(value)
except json.JSONDecodeError: except json.JSONDecodeError:
pass # Keep as string if not valid JSON pass # Keep as string - not valid JSON, will be set as string value
try: try:
if operation == "delete": if operation == "delete":