[Phase 1] Create discovery tooling for YANG path exploration #4

Closed
opened 2025-12-20 15:40:16 +00:00 by Damien · 1 comment
Owner

Description

Build a CLI tool to interactively explore YANG paths on live devices, making path discovery easier.

Features

  • Connect to device via gNMI
  • List capabilities (supported models)
  • Get configuration at any path
  • Get state/operational data at any path
  • Set configuration (for testing)
  • Pretty-print JSON/YANG output
  • Save results to file for documentation

CLI Interface

# List capabilities
fabric-orch discover capabilities --target leaf1:6030

# Get config at path
fabric-orch discover get --target leaf1:6030 \
  --path "/openconfig-interfaces:interfaces"

# Get specific interface
fabric-orch discover get --target leaf1:6030 \
  --path "/openconfig-interfaces:interfaces/interface[name=Ethernet1]"

# Test set operation
fabric-orch discover set --target leaf1:6030 \
  --path "/path/to/config" \
  --value '{"config": {...}}' \
  --dry-run

Implementation

  • Use pygnmi for gNMI operations
  • Use click for CLI
  • Use rich for pretty output

Output

  • src/cli.py with discover commands
  • src/gnmi/client.py wrapper
## Description Build a CLI tool to interactively explore YANG paths on live devices, making path discovery easier. ## Features - [x] Connect to device via gNMI - [x] List capabilities (supported models) - [x] Get configuration at any path - [x] Get state/operational data at any path - [x] Set configuration (for testing) - [x] Pretty-print JSON/YANG output - [x] Save results to file for documentation ## CLI Interface ```bash # List capabilities fabric-orch discover capabilities --target leaf1:6030 # Get config at path fabric-orch discover get --target leaf1:6030 \ --path "/openconfig-interfaces:interfaces" # Get specific interface fabric-orch discover get --target leaf1:6030 \ --path "/openconfig-interfaces:interfaces/interface[name=Ethernet1]" # Test set operation fabric-orch discover set --target leaf1:6030 \ --path "/path/to/config" \ --value '{"config": {...}}' \ --dry-run ``` ## Implementation - Use `pygnmi` for gNMI operations - Use `click` for CLI - Use `rich` for pretty output ## Output - `src/cli.py` with discover commands - `src/gnmi/client.py` wrapper
Damien added the phase-1-yang-discovery label 2025-12-20 15:40:21 +00:00
Author
Owner

Implementation Complete

All features from this issue have been implemented and tested in PR #21.

Completed Features

  • Connect to device via gNMI - GNMIClient wrapper with context manager support
  • List capabilities (supported models) - fabric-orch discover capabilities
  • Get configuration at any path - fabric-orch discover get --type config
  • Get state/operational data at any path - fabric-orch discover get --type state
  • Set configuration (for testing) - fabric-orch discover set with dry-run default
  • Pretty-print JSON/YANG output - Rich library integration with tables and panels
  • Save results to file for documentation - --output file:path option

Additional Features Implemented

  • Subscribe to real-time updates (on-change, sample modes)
  • Quick reference of common YANG paths (fabric-orch discover paths)
  • Environment variable support (GNMI_TARGET, GNMI_USERNAME, GNMI_PASSWORD)
  • Comprehensive error handling with helpful hints
  • Documentation: CLI guide and YANG paths reference

Testing

Validated against cEOS 4.35.0F lab:

  • All CLI commands working
  • GET/SET/Subscribe operations
  • Multiple output formats
  • Error handling

Files Added

src/cli.py                 # CLI implementation
src/gnmi/client.py         # gNMI client wrapper
src/gnmi/__init__.py       # Module exports
src/gnmi/README.md         # Client documentation
docs/cli-guide.md          # CLI user guide
docs/yang-paths.md         # YANG paths reference

Ready for merge via PR #21.

## ✅ Implementation Complete All features from this issue have been implemented and tested in PR #21. ### Completed Features - [x] **Connect to device via gNMI** - `GNMIClient` wrapper with context manager support - [x] **List capabilities (supported models)** - `fabric-orch discover capabilities` - [x] **Get configuration at any path** - `fabric-orch discover get --type config` - [x] **Get state/operational data at any path** - `fabric-orch discover get --type state` - [x] **Set configuration (for testing)** - `fabric-orch discover set` with dry-run default - [x] **Pretty-print JSON/YANG output** - Rich library integration with tables and panels - [x] **Save results to file for documentation** - `--output file:path` option ### Additional Features Implemented - Subscribe to real-time updates (`on-change`, `sample` modes) - Quick reference of common YANG paths (`fabric-orch discover paths`) - Environment variable support (`GNMI_TARGET`, `GNMI_USERNAME`, `GNMI_PASSWORD`) - Comprehensive error handling with helpful hints - Documentation: CLI guide and YANG paths reference ### Testing Validated against cEOS 4.35.0F lab: - ✅ All CLI commands working - ✅ GET/SET/Subscribe operations - ✅ Multiple output formats - ✅ Error handling ### Files Added ``` src/cli.py # CLI implementation src/gnmi/client.py # gNMI client wrapper src/gnmi/__init__.py # Module exports src/gnmi/README.md # Client documentation docs/cli-guide.md # CLI user guide docs/yang-paths.md # YANG paths reference ``` Ready for merge via PR #21.
Damien added reference feat-discoverytools 2026-01-07 11:59:38 +00:00
Sign in to join this conversation.