Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Hier Config CLI

PyPI version Python Versions License Tests

A powerful command-line interface tool for network configuration analysis, remediation, and rollback built on top of the Hier Config library.

Overview

hier-config-cli helps network engineers analyze configuration differences, generate remediation commands, prepare rollback procedures, and predict configuration states across multiple network platforms. It's an essential tool for network automation workflows, change management, and configuration compliance.

Key Features

  • 🔄 Remediation Generation: Automatically generate commands to transform running config into intended config
  • ⏮️ Rollback Planning: Create rollback procedures before making changes
  • 🔮 Future State Prediction: Preview the complete configuration after applying changes
  • 🌐 Multi-Platform Support: Works with Cisco, Juniper, Arista, HP, Fortinet, VyOS, and more
  • 📊 Multiple Output Formats: Export as text, JSON, or YAML
  • 🎯 Type-Safe: Fully typed Python code with mypy support
  • Well-Tested: Comprehensive test suite with high code coverage
  • 📝 Detailed Logging: Verbose and debug modes for troubleshooting

Installation

Via pip (recommended)

pip install hier-config-cli

Via Poetry

poetry add hier-config-cli

From Source

git clone https://github.com/netdevops/hier-config-cli.git
cd hier-config-cli
poetry install

Quick Start

1. List Available Platforms

hier-config-cli list-platforms

Output:

=== Available Platforms ===
  aruba_aoscx
  eos
  fortios
  generic
  hp_comware5
  hp_procurve
  huawei_vrp
  ios
  iosxr
  junos
  nokia_srl
  nxos
  vyos

2. Generate Remediation Configuration

Compare your running configuration with the intended configuration and generate the commands needed to remediate:

hier-config-cli remediation \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf

3. Generate Rollback Configuration

Prepare rollback commands before making changes:

hier-config-cli rollback \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf

4. Preview Future Configuration

See what the complete configuration will look like after applying changes:

hier-config-cli future \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf

Usage Examples

Basic Remediation

hier-config-cli remediation \
  --platform ios \
  --running-config examples/cisco_ios_running.conf \
  --generated-config examples/cisco_ios_intended.conf

Output:

=== Remediation Configuration ===
no hostname router-01
hostname router-01-updated
interface GigabitEthernet0/0
 no description WAN Interface
 description WAN Interface - Updated
interface Vlan20
 description Guest VLAN
 ip address 10.0.20.1 255.255.255.0
router ospf 1
 network 10.0.20.0 0.0.0.255 area 0
ntp server 192.0.2.1

Export to JSON

hier-config-cli remediation \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf \
  --format json

Export to YAML

hier-config-cli remediation \
  --platform nxos \
  --running-config running.conf \
  --generated-config intended.conf \
  --format yaml

Save Output to File

hier-config-cli remediation \
  --platform iosxr \
  --running-config running.conf \
  --generated-config intended.conf \
  --output remediation_commands.txt

Enable Verbose Logging

# INFO level logging
hier-config-cli -v remediation \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf

# DEBUG level logging
hier-config-cli -vv remediation \
  --platform ios \
  --running-config running.conf \
  --generated-config intended.conf

Commands

remediation

Generates the commands needed to transform the running configuration into the intended configuration.

Options:

  • --platform: Target platform (required) - see list-platforms for options
  • --running-config: Path to running configuration file (required)
  • --generated-config: Path to intended/generated configuration file (required)
  • --format: Output format - text, json, or yaml (default: text)
  • --output, -o: Write output to file instead of stdout

rollback

Generates the commands needed to revert from the intended configuration back to the running configuration. Useful for preparing rollback procedures before making changes.

Options: Same as remediation

future

Predicts what the complete configuration will look like after applying the intended configuration to the running configuration.

Options: Same as remediation

list-platforms

Lists all supported network platforms.

version

Shows the installed version of hier-config-cli.

Supported Platforms

Platform Code Description
Cisco IOS ios Cisco IOS routers and switches
Cisco NX-OS nxos Cisco Nexus switches
Cisco IOS XR iosxr Cisco IOS XR routers
Arista EOS eos Arista switches
Juniper JunOS junos Juniper routers and switches
VyOS vyos VyOS routers
Fortinet FortiOS fortios Fortinet firewalls
HP Comware5 hp_comware5 HP Comware5 switches
HP ProCurve hp_procurve HP ProCurve switches
Aruba AOS-CX aruba_aoscx Aruba AOS-CX switches
Huawei VRP huawei_vrp Huawei VRP routers and switches
Nokia SR Linux nokia_srl Nokia SR Linux switches
Generic generic Generic/unknown platform

Integration Examples

With Nornir

from nornir import InitNornir
from nornir.core.task import Task
import subprocess

def generate_remediation(task: Task) -> None:
    """Generate remediation for a device."""
    result = subprocess.run(
        [
            "hier-config-cli",
            "remediation",
            "--platform", task.host.platform,
            "--running-config", f"configs/{task.host.name}_running.conf",
            "--generated-config", f"configs/{task.host.name}_intended.conf",
            "--output", f"remediation/{task.host.name}_remediation.txt",
        ],
        capture_output=True,
        text=True,
    )
    return result.stdout

nr = InitNornir(config_file="config.yaml")
results = nr.run(task=generate_remediation)

With Ansible

- name: Generate configuration remediation
  hosts: network_devices
  tasks:
    - name: Run hier-config-cli remediation
      command: >
        hier-config-cli remediation
        --platform {{ platform }}
        --running-config /tmp/{{ inventory_hostname }}_running.conf
        --generated-config /tmp/{{ inventory_hostname }}_intended.conf
        --output /tmp/{{ inventory_hostname }}_remediation.txt
      register: remediation_result

    - name: Display remediation
      debug:
        msg: "{{ remediation_result.stdout }}"

In CI/CD Pipeline

# .github/workflows/config-validation.yml
name: Validate Network Configs

on: [push, pull_request]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install hier-config-cli
        run: pip install hier-config-cli

      - name: Generate remediation
        run: |
          hier-config-cli remediation \
            --platform ios \
            --running-config prod/running.conf \
            --generated-config staging/intended.conf \
            --output remediation.txt

      - name: Upload remediation
        uses: actions/upload-artifact@v4
        with:
          name: remediation-config
          path: remediation.txt

Development

Prerequisites

  • Python 3.10 or higher
  • Poetry (for dependency management)

Setup Development Environment

# Clone the repository
git clone https://github.com/netdevops/hier-config-cli.git
cd hier-config-cli

# Install dependencies
poetry install

# Activate virtual environment
poetry shell

Running Tests

# Full lint + test suite (what CI runs)
poetry run python scripts/build.py lint-and-test

# Tests only (95% coverage required)
poetry run python scripts/build.py pytest --coverage

# Run a specific test file
poetry run pytest tests/test_cli.py -v

Code Quality

All linters and type checkers run in parallel via the build script:

# Lint only (ruff format + check, mypy, pyright, pylint, yamllint, flynt)
poetry run python scripts/build.py lint

# Auto-fix formatting and fixable lint issues
poetry run python scripts/build.py lint --fix

# Auto-format code
poetry run ruff format src tests scripts

Standards: ruff format (not black), ruff select = ["ALL"] with preview rules at line length 88, mypy strict, pyright strict, pylint with extension plugins, and full type annotations everywhere — including tests.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details on:

  • Code of conduct
  • Development workflow
  • Pull request process
  • Coding standards

Security

For security issues, please see SECURITY.md for our security policy and how to report vulnerabilities.

Changelog

See CHANGELOG.md for a detailed list of changes between versions.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Links

Acknowledgments

Built on top of the excellent Hier Config library by James Williams and contributors.

Support

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hier_config_cli-0.2.1a0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hier_config_cli-0.2.1a0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file hier_config_cli-0.2.1a0.tar.gz.

File metadata

  • Download URL: hier_config_cli-0.2.1a0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Darwin/25.5.0

File hashes

Hashes for hier_config_cli-0.2.1a0.tar.gz
Algorithm Hash digest
SHA256 8d74353c3ee76610c8f790d306d811f100e47e7c3c8530ba01fc973f4d430afb
MD5 76cdbc2b124e701109610851c1c860e9
BLAKE2b-256 803a8a74e5c51c4e0da36aa11c3f26789b39a39233264f9e9af7d96d816ee371

See more details on using hashes here.

File details

Details for the file hier_config_cli-0.2.1a0-py3-none-any.whl.

File metadata

  • Download URL: hier_config_cli-0.2.1a0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Darwin/25.5.0

File hashes

Hashes for hier_config_cli-0.2.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb01535c0c8d57083b5a9eb490920c90797758671ee1e0b5922bb59049650e33
MD5 55e353ca30ba9fc978ae3d9079f4b61b
BLAKE2b-256 fad655d1b537c17923e92567ab3ec2f420c9ccd5050fae4d737fcb4e790f566b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page