Skip to main content

Lightweight pluggable CLI for nornir scripts

Project description

NORNIR-APPS

Pluggable Network CLI tool built on top of Nornir and Napalm

Why do I need this?

nornir_apps is a lightweight wrapper around Nornir and Napalm and it provides a CLI that makes it easy to plugin Nornir-based scripts you have. The ClI tool comes with a few plugins that use the nornir_napalm tools that may already be suitable for quick tasks. However, you can easily add to the CLI by writing your own plugin.

Getting Started

Installation

Install nornir_apps using pip:

pip install nornir-apps

Configure your Nornir inventory and Initialization config

You can use your existing nornir configuration files and inventory without any modifications. By default, nornir_apps looks for a config.yaml file in the root of directory from which you're using the nornir-app CLI command. You can pass another file using the -i or --init-file flag as well. You can review sample configuration and inventory files below. They are samples from the examples directory in the root of this repo.

Sample hosts file
# examples/inventory/hosts.yaml
cat9k:
  hostname: 10.253.175.87
  port: 22
  username: cisco
  password: cisco
  groups:
    - cisco_iosxe
Sample Groups file
# examples/inventory/groups.yaml
---
cisco_iosxe:
  platform: ios
  data:
    role: router
  connection_options:
    napalm:
      extras:
        optional_args:
          fast_cli: False
          secret: cisco
          conn_timeout: 30
Nornir Initialization file
---
core:
  raise_on_error: False

runner:
  plugin: threaded
  options:
    num_workers: 100

logging:
  enabled: True

inventory:
  plugin: SimpleInventory
  options:
    host_file: "inventory/hosts.yaml"
    group_file: "inventory/groups.yaml"
    defaults_file: "inventory/defaults.yaml"

Getting Started with the CLI

View available commands

Use nornir_apps --help to view the included commands based on the napalm_nornir project. Any plugin that you create and register will show as an available command in the future.

 nornir_app --help

<OUPUT OMMITTED>

Commands:
  napalm-configure  Retrieve device configuration
  napalm-get        Retrieve device configuration using napalm getters
  napalm-ping       Ping device
  napalm-validate   Validate device compliance using napalm_validate

Examples

nornir_app -i inventory/config.yaml -h cat9k napalm-ping -d 8.8.8.8

Note: the CLI looks for a config.yaml file by default to initiliaze Nornir

If you have a config.yaml file present in the current directory, you can omit the -i flag:

nornir_app -h cat9k napalm-ping -d 8.8.8.8

The -h or --host-filter option allows you to pass a simple filter to the inventory for host selection.

nornir_app -h platform=ios,role=router napalm-ping -d 8.8.8.8

Project details


Download files

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

Source Distribution

nornir-apps-0.0.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

nornir_apps-0.0.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file nornir-apps-0.0.3.tar.gz.

File metadata

  • Download URL: nornir-apps-0.0.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for nornir-apps-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ef74679cbfae03fc66a064a8f4a86a9c512383d1287624d17c4994c34fa675ea
MD5 499db7ffb7e3ca68d88ab34a0df1f47f
BLAKE2b-256 76f94b865d454c3f6742ad0604b721c9d900ab6498bb77ccdd9dd721123b3953

See more details on using hashes here.

File details

Details for the file nornir_apps-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nornir_apps-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for nornir_apps-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2064105d6e27baa569d239caa77a6bef4e23f5cecefea500eb70dbcd3e44dafe
MD5 195380678280f37fc876bf7848018c4d
BLAKE2b-256 fcb9a109a9358725d6262b264f9b8d4c25210f5a7ef3ac2389f911a80c616594

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page