Skip to main content

Overview

This module is intended to be installed on the production NCS nodes and imported in other services/actions that need to gather state from the network. It uses the NCS device manager and the standard python multiprocessing library to connect to devices in-parallel and issue commands, returning results as structured data.

Usage information

Basic usage example in an NCS callback:

from umnet_pyncs.state import StateManager
...


class DemoAction(Action):
    @Action.action
    def cb_action(self, uinfo, name, kp, input, output, trans):
        ...
        with StateManager() as m:
            interfaces = m.get_state(al_devices, ["get-interface-details"])
            arp = m.get_state(dl_devices, ["get-arp-table"])
            ...

Supported commands

Currently supported commands are:

  • get-mac-table
  • get-arp-table
  • get-interface-details
  • get-transciever-details
  • get-lldp-neighbors
  • get-bfd-neighbors
  • get-ospf-neighbors

Developer testing

Use the run_cmds script to start a session with the local ncs daemon and test the various state gathering commands

[grundler@ncs-1 umnet-pyncs]$ ./run_cmds -h
usage: run_cmds [-h] -c CMD -d DEV

optional arguments:
  -h, --help            show this help message and exit
  -c CMD, --cmd CMD
  -d DEV, --device DEV
[grundler@ncs-1 umnet-pyncs]$
[grundler@ncs-1 umnet-pyncs]$
[grundler@ncs-1 umnet-pyncs]$ ./run_cmds -d s-ehall-2012p-1 -c get-interface-details
INFO:root:connecting to ncs...
INFO:root:transaction started...
INFO:root:submitting commands to worker pool (1)
DEBUG:root:pid: 19275: invoking get-interface-details against s-ehall-2012p-1
DEBUG:root:sending 'show interfaces' to s-ehall-2012p-1
...

For any given command, the various platform-specific models are responsible for implementing how the data is fetched and parsed from the remote device. Each command corresponds to a method that can be invoked to retrieve the data, e.g. get-interface-details maps to the get_interface_details() instance method of the model(s).

For Cisco IOS and NXOS devices (which use CLI-based NEDs), the built-in NCS live-status action(s) are used to send raw CLI commands to the device. For example, the get_mac_address() method will send a show mac address-table CLI command. For both IOS and NXOS we use ntc_templates to parse the raw text output into structured data.

For Juniper devices, since the NED uses NETCONF for all device communications, we instead call the <get-ethernet-switching-table-information> RPC directly. Since this RPC is modelled in YANG, we can then parse the results directly using the maagic API.

All the nitty-gritty details of parsing the data retrieved directly from the remote device is handled by the platform-specific model implementation for that device. Each model normalizes the data using the dataclasses defined in base.py. The intention is to makes it simpler for NCS actions/services to use this module, as well as making it easier to develop/maintain.

NB: this implementation currently relies on an additional template for NXOS that handles parsing show ip arp detail vrf all -- see PR# 1204.

Metadata

Release files for umnet-pyncs 0.1.45

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for umnet-pyncs 0.1.45
File Size Uploaded
umnet_pyncs-0.1.45.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for umnet-pyncs 0.1.45
File Interpreter ABI Platform
umnet_pyncs-0.1.45-py3-none-any.whl Python 3 none any Details

Total release size: 40.0 kB

Release files / umnet_pyncs-0.1.45.tar.gz

Download URL umnet_pyncs-0.1.45.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
949d55907294d55ab895abda1dca2e8e73b1312f0473807fa7a0f50819c9fe75
BLAKE2b-256 checksum
How to use checksums
cfba5ca373415ff87ff50a86eb087b4b9502889cf6c6e1f4c4ba710e3582bbd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.11.2 Linux/6.1.0-37-amd64

Release files / umnet_pyncs-0.1.45-py3-none-any.whl

Download URL umnet_pyncs-0.1.45-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdfdd40d5bf60035d87383df738e368c34c6e8b4ac9515030aaeb18ce88c22ea
BLAKE2b-256 checksum
How to use checksums
67486f72a4309ad45ee068bac74ee2fa2426adb269687737b0dea9ac01baa0ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.11.2 Linux/6.1.0-37-amd64

Release history Release notifications | RSS feed

This release

0.1.45 This release

2 release files

0.1.44

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.37

2 release files

0.1.35

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page