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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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