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
Owner

Summary

This PR implements the Phase 1 discovery tooling as specified in #4. It provides a complete CLI for interactively exploring YANG paths on Arista devices via gNMI.

Features

  • fabric-orch discover capabilities - List device capabilities and supported YANG models
  • fabric-orch discover get - Get configuration or state data at any YANG path
  • fabric-orch discover set - Set configuration with dry-run support (safe by default)
  • fabric-orch discover subscribe - Subscribe to real-time path updates (on-change, sample modes)
  • fabric-orch discover paths - Quick reference of common YANG paths for Arista EOS

Implementation

New Files

  • src/cli.py - Click-based CLI with rich output formatting
  • src/gnmi/client.py - High-level gNMI client wrapper using pygnmi
  • src/gnmi/__init__.py - Module exports
  • src/gnmi/README.md - Client usage documentation
  • docs/cli-guide.md - CLI user guide
  • docs/yang-paths.md - YANG paths reference

Dependencies

  • click - CLI framework
  • pygnmi - gNMI client library
  • rich - Pretty terminal output

Usage Examples

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

# Get interface state
fabric-orch discover get -t leaf1:6030 -P "/interfaces/interface[name=Ethernet1]/state"

# Set with dry-run (default)
fabric-orch discover set -t leaf1:6030 \
  -P "/interfaces/interface[name=Ethernet1]/config/description" \
  -v "Uplink to Spine"

# Subscribe to changes
fabric-orch discover subscribe -t leaf1:6030 \
  -P "/interfaces/interface/state/oper-status" \
  --mode on-change

Testing

Validated against cEOS 4.35.0F lab environment:

  • Capabilities retrieval
  • GET operations (config, state, all)
  • SET operations (dry-run and live)
  • Subscribe operations (on-change, sample modes)
  • Error handling with helpful messages
  • Multiple output formats (pretty, json, file)

Closes #4

## Summary This PR implements the Phase 1 discovery tooling as specified in #4. It provides a complete CLI for interactively exploring YANG paths on Arista devices via gNMI. ## Features - **`fabric-orch discover capabilities`** - List device capabilities and supported YANG models - **`fabric-orch discover get`** - Get configuration or state data at any YANG path - **`fabric-orch discover set`** - Set configuration with dry-run support (safe by default) - **`fabric-orch discover subscribe`** - Subscribe to real-time path updates (on-change, sample modes) - **`fabric-orch discover paths`** - Quick reference of common YANG paths for Arista EOS ## Implementation ### New Files - `src/cli.py` - Click-based CLI with rich output formatting - `src/gnmi/client.py` - High-level gNMI client wrapper using pygnmi - `src/gnmi/__init__.py` - Module exports - `src/gnmi/README.md` - Client usage documentation - `docs/cli-guide.md` - CLI user guide - `docs/yang-paths.md` - YANG paths reference ### Dependencies - `click` - CLI framework - `pygnmi` - gNMI client library - `rich` - Pretty terminal output ## Usage Examples ```bash # List capabilities fabric-orch discover capabilities --target leaf1:6030 # Get interface state fabric-orch discover get -t leaf1:6030 -P "/interfaces/interface[name=Ethernet1]/state" # Set with dry-run (default) fabric-orch discover set -t leaf1:6030 \ -P "/interfaces/interface[name=Ethernet1]/config/description" \ -v "Uplink to Spine" # Subscribe to changes fabric-orch discover subscribe -t leaf1:6030 \ -P "/interfaces/interface/state/oper-status" \ --mode on-change ``` ## Testing Validated against cEOS 4.35.0F lab environment: - ✅ Capabilities retrieval - ✅ GET operations (config, state, all) - ✅ SET operations (dry-run and live) - ✅ Subscribe operations (on-change, sample modes) - ✅ Error handling with helpful messages - ✅ Multiple output formats (pretty, json, file) ## Related Closes #4
Damien added 6 commits 2026-01-07 11:55:45 +00:00
- Replace placeholder deps with click, pygnmi, and rich for CLI functionality
- Add fabric-orch CLI entry point via project.scripts
- Configure hatchling as build backend with wheel/sdist targets
- Add ruff linter configuration for code quality
- Add dev dependency group with ruff
- Alphabetize yang module imports
Add comprehensive documentation for the fabric-orch CLI tool covering:
- Installation and quick start instructions
- Environment variables for gNMI authentication
- All discover subcommands (capabilities, get, set, subscribe, paths)
- YANG path syntax reference and common paths table
- Output formats and error handling guidance
Improve table readability by aligning columns with consistent
spacing and proper markdown table formatting throughout the
YANG paths reference documentation.
- 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
Remove outdated async documentation from GNMIClient module:
- Remove async context manager from feature list
- Remove async usage example from class docstring

The client now only documents synchronous usage patterns.
- Align columns in README.md roadmap and technology stack tables
- Update CLI example to use 'uv run fabric-orch' command prefix
- Improve overall markdown table readability
Damien merged commit 413d87873a into main 2026-01-07 12:00:05 +00:00
Damien deleted branch feat-discoverytools 2026-01-07 12:00:10 +00:00
Sign in to join this conversation.