Registry / devops / genie-libs-ops

genie-libs-ops

JSON →
library26.5pypypiunverified

Genie Libs Ops (Operational State) is a core sub-component of the Cisco pyATS and Genie framework, current version 26.3. It provides a robust, network OS-agnostic abstraction layer to retrieve and model the operational state of network devices. This library is crucial for network test automation, offering structured data representation of device operational states (e.g., BGP, OSPF, interfaces) that can be learned, compared, and validated. Releases are frequent, typically monthly or bi-monthly, aligning with the broader pyATS/Genie ecosystem.

pip install genie-libs-ops
INSTALL
IMPORT
SIG · GENIE-LIBS-OPS
G
genie-libs-ops
devopspythonv26.5
Install
23.3s avg
Import
4319ms
Disk
785MB
Pass rate
7/ 10
Env Coverage7 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ 0.03s
✓ 31.28s
py 3.11
2/6 runs
✓ 30.45s
py 3.12
2/6 runs
✓ 32.77s
py 3.13
2/6 runs
✓ 31.12s
py 3.9
✓ 0.03s
✓ 37.68s
785MB installed
● package 785MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Bgp
from genie.libs.ops.bgp.iosxe.bgp import Bgp
from genie.libs.ops.bgp.iosxe.bgp import Bgp

This quickstart demonstrates how to use `genie.libs.ops` to load a testbed, instantiate an operational state object (e.g., BGP for IOS-XE), learn the device's operational state, and access the structured data. A `testbed.yaml` file is expected for device connection details. For actual execution, ensure device connectivity or mock the device behavior.

import os from pyats.topology import loader from genie.libs.ops.bgp.iosxe.bgp import Bgp # Example: import BGP ops for IOS-XE import pprint # Ensure a testbed.yaml exists or create a dummy one for demonstration # In a real scenario, this would connect to a live device. # For local testing, mock the connection or use a local testbed file. # Example testbed.yaml content (place in same directory as script): # devices: # Router1: # os: iosxe # type: router # connections: # cli: # protocol: ssh # ip: 10.1.1.1 # Replace with actual device IP # port: 22 # credentials: # default: # username: cisco # password: cisco try: testbed = loader.load(os.environ.get('TESTBED_FILE', 'testbed.yaml')) device = testbed.devices.get('Router1') if not device: raise ValueError("Device 'Router1' not found in testbed.yaml") # In a real scenario, device.connect() would be called here: # device.connect(log_stdout=False) # Instantiate the Ops object for BGP on the device bgp_ops = Bgp(device=device) # Learn the operational state of BGP # This would execute 'show' commands on the device and parse output # For this example, it will run against a mocked device or fail if no connection bgp_ops.learn() print(f"\nLearned BGP operational state for {device.name}:") pprint.pprint(bgp_ops.info) # Example: Check if BGP is configured in VRF default if 'vrf' in bgp_ops.info and 'default' in bgp_ops.info['vrf']: print("\nBGP is configured in VRF 'default'.") else: print("\nBGP not found in VRF 'default' or not configured.") except Exception as e: print(f"An error occurred: {e}") print("\nEnsure 'testbed.yaml' is correctly configured and device is reachable, or mock device interaction for testing.")
genie --version
Debug
Known issues
breakingPython 3.6 support officially ended after April 2022. Users on older Python versions (3.6 and below) must upgrade to Python 3.7+ (preferably 3.8+) to use recent versions of Genie Libs Ops and the broader pyATS/Genie framework.
fix
Upgrade your Python environment to 3.7 or newer. Python 3.8+ is generally recommended for the latest Genie releases.
affects: <=22.3
gotchaWhile `pip install genie-libs-ops` is possible, it is highly recommended to install the full `genie` or `pyats[full]` package. `genie.libs.ops` relies heavily on other components of the `genie` and `pyats` ecosystem (e.g., connection handlers, parsers). Installing only `genie-libs-ops` can lead to missing functionalities and runtime errors if dependencies are not met.
fix
Use `pip install genie` or `pip install pyats[full]` to ensure all necessary components are installed.
affects: All versions
gotchaWhen using `device.parse()` or `genie learn` for network commands, shorthand or non-standard command variations might not be recognized by built-in parsers, resulting in 'Could not find parser' or 'ambiguous' errors.
fix
Refer to the Genie Models documentation to find the exact command string and supported features for each OS. Use the full, precise command as expected by the parser.
affects: All versions
deprecatedOlder versions of Genie (pre-19.9) had issues with multi-threaded execution, particularly when integrated with frameworks like Nornir using multiple workers. This could lead to parsing or operational state learning failures.
fix
Upgrade to a more recent version of Genie/pyATS (19.9 or newer) where these concurrency issues have been addressed. If upgrading is not immediately possible, use a single worker/thread for Genie operations.
affects: <19.9
Upgrade
Version history
26.5latest on PyPI · released May 28, 2026
Audit
Dependencies
genierequiredCore framework that provides the testbed management, device connections, and overall Genie infrastructure. genie-libs-ops is a sub-component of Genie.
pyatsrequiredThe underlying Python Automation Test System framework upon which Genie is built.
Agent activity
13 hits · last 30 days
node
12
Resources
genie-libs-ops — pip install genie-libs-ops · libregistry