NETCONF Get Schema¤
Retrieve a YANG module with netconf_get_schema using ncclient or Scrapli.
The device must implement NETCONF monitoring get-schema.
Output¤
Use XML processors to convert replies to
dictionaries (xmltodict), select XML elements (xpath), or extract flat
values (xml-flake).
Per-host XML replies contain the schema text. The operation key is get_schema
for ncclient and rpc for Scrapli, which sends the standard RPC directly.
Missing modules and unsupported operations mark hosts as failed.
Examples¤
nf# nornir netconf get-schema identifier openconfig-system plugin ncclient FL ceos-spine-1
nf# nornir netconf get-schema identifier openconfig-system plugin scrapli FL ceos-spine-1
from norfab.core.nfapi import NorFab
with NorFab(inventory="inventory.yaml") as nf:
client = nf.make_client()
result = client.run_job(
"nornir", "netconf_get_schema",
kwargs={"identifier": "openconfig-system", "plugin": "scrapli",
"FL": ["ceos-spine-1"]},
)
print(result)
Notes¤
- Select an
identifierfrom module names advertised in capabilities, YANG Library, or the NETCONF monitoring schema list. Capabilities may be incomplete and do not guarantee that schema retrieval is available. versionselects a revision, usually YYYY-MM-DD. Omit it for server selection.formatacceptsyang(default) oryin. Imports are not fetched automatically.- Configure the backend in the NETCONF inventory.
Troubleshooting¤
For missing-schema errors, verify the identifier and revision against the device schema list. An unsupported-operation error means the device cannot serve the schema through this RPC.
Task Command Shell Reference¤
nf#man tree nornir.netconf.get_schema
R - required field, M - supports multiline input, D - dynamic key
root
└── nornir: Nornir service
└── netconf: Manage devices using NETCONF
└── get-schema: Retrieve a YANG module
├── timeout: Job timeout
├── workers: Filter workers to target, default 'all'
├── verbose-result: Control output details, default 'False'
├── nowait: Do not wait for job to complete, default 'False'
├── FO: Filter hosts using a Nornir-Salt Filter Object
├── FB: Filter hosts by name using glob patterns
├── FH: Filter hosts by hostname
├── FC: Filter hosts by name containment pattern
├── FR: Filter hosts by name using regular expressions
├── FG: Filter hosts by group
├── FP: Filter hosts by hostname using IP prefix
├── FL: Filter hosts by names list
├── FM: Filter hosts by platform
├── FX: Exclude hosts by name
├── FN: Negate the host filter match
├── on-failed: Run task on hosts currently marked as failed by Nornir, default 'False'
├── to-dict: Return task results as a dictionary keyed by host, default 'True'
├── add-details: Add Nornir task execution details to results, default 'False'
├── progress: Emit progress events during task execution, default 'True'
├── num-workers: RetryRunner number of threads for task execution
├── num-connectors: RetryRunner number of threads for device connections
├── connect-retry: RetryRunner number of connection attempts
├── task-retry: RetryRunner number of attempts to run each task
├── reconnect-on-fail: RetryRunner reconnects to a host after task failure
├── connect-check: RetryRunner tests TCP connectivity before opening connection
├── connect-timeout: RetryRunner TCP connection check timeout in seconds
├── creds-retry: RetryRunner connection credentials and parameters to retry
├── tf: File group name to save task results on the worker
├── tf-skip-failed: Skip failed task results when saving to file
├── diff: File group name to diff task results against
├── diff-last: Previous saved file version to diff against
├── identifier (R): YANG module name
├── version: Module revision
├── format: Schema format, default 'NetconfSchemaFormat.yang'
├── xmltodict: Convert XML replies to dictionaries with DataProcessor, default 'False'
├── xpath: XPath expression to run with DataProcessor
├── xml-flake: XML flake pattern for DataProcessor
└── plugin: NETCONF backend, default 'NetconfPlugin.ncclient'
nf#
Common host filters and job options apply.
Python API Reference¤
Retrieve a YANG module using NETCONF monitoring get-schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
NorFab job metadata. |
required |
identifier
|
str
|
Module name from capabilities, YANG Library, or the NETCONF monitoring schema list. Capabilities may be incomplete. |
required |
version
|
str
|
Optional module revision, normally YYYY-MM-DD. Omit to let the server select a version. |
None
|
format
|
str
|
Schema format: yang (default) or yin. |
'yang'
|
plugin
|
str
|
Backend name: ncclient (default) or scrapli. |
'ncclient'
|
**kwargs
|
Any
|
Common host filters, retries, XML processors (xmltodict, xpath, xml_flake) and serialization options applicable to this task. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
XML replies containing schema text under get_schema for ncclient or rpc for Scrapli. Missing modules and unsupported schema retrieval mark hosts as failed. Unmatched hosts return status no_match. Imports are not downloaded automatically. Requires the device to implement NETCONF monitoring get-schema. |
Source code in norfab\workers\nornir_worker\netconf_task.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |