feat: Add gNMI discovery CLI tools for YANG path exploration #21

Merged
Damien merged 6 commits from feat-discoverytools into main 2026-01-07 12:00:05 +00:00
3 changed files with 4 additions and 19 deletions
Showing only changes of commit 5b3517c355 - Show all commits

View File

@@ -254,12 +254,6 @@ def discover_capabilities(
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(
target: str,
username: str,
@@ -268,7 +262,6 @@ def discover_get(
output: str,
path: str,
data_type: str,
depth: int | None,
):
"""
Get configuration or state data at a YANG path.

View File

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

View File

@@ -159,14 +159,6 @@ class GNMIClient:
pass # Ignore cleanup errors
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
# =========================================================================
@@ -288,7 +280,7 @@ class GNMIClient:
try:
value = json.loads(value)
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:
if operation == "delete":