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
74MB installed
● package 74MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Netconf
✓ from yang.connector import Netconf
✗ from yang import Netconf
This quickstart demonstrates how to connect to a network device using `yang.connector.Netconf` via the pyATS testbed loader. It then retrieves a filtered configuration (e.g., interfaces) and lists the device's NETCONF capabilities. Credentials should be provided via environment variables for security.
import os
from pyats.topology import loader
# Define device connection details using environment variables for security
DEVICE_IP = os.environ.get('YANG_CONNECTOR_DEVICE_IP', 'your_device_ip')
DEVICE_PORT = int(os.environ.get('YANG_CONNECTOR_DEVICE_PORT', 830)) # Default NETCONF port
USERNAME = os.environ.get('YANG_CONNECTOR_USERNAME', 'admin')
PASSWORD = os.environ.get('YANG_CONNECTOR_PASSWORD', 'admin')
# A minimal pyATS Testbed YAML string for demonstration
testbed_yaml = f'''
devices:
my_device:
os: iosxe
connections:
netconf:
class: yang.connector.Netconf
ip: {DEVICE_IP}
port: {DEVICE_PORT}
protocol: netconf
credentials:
default:
username: {USERNAME}
password: {PASSWORD}
'''
try:
# Load the testbed from the YAML string
testbed = loader.load(testbed_yaml)
device = testbed.devices['my_device']
# Establish connection
device.connect(via='netconf', init_exec_alias=False)
print(f"Successfully connected to {device.name} via NETCONF.")
# Example: Get configuration using get_config()
# For a full configuration, an empty filter can be used
# For specific data, provide an XML filter string
filter_xml = '<filter type="subtree"><interfaces/></filter>'
config_data = device.netconf.get_config(source='running', filter=filter_xml)
print("\nRetrieved configuration (filtered for interfaces):\n")
print(config_data.data_xml)
# Example: Get capabilities
print("\nServer Capabilities:")
for cap in device.netconf.server_capabilities:
print(f"- {cap}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Disconnect from the device
if 'device' in locals() and device.is_connected('netconf'):
device.disconnect(via='netconf')
print(f"Disconnected from {device.name}.")
Upgrade
Version history
26.5latest on PyPI · released May 28, 2026
Audit
Dependencies
ncclientrequiredyang.connector.Netconf wraps the ncclient library for NETCONF protocol implementation.
pyatsrequiredyang.connector is integrated into the pyATS framework and its Netconf class is based on pyATS BaseConnection.