NETCONF Discard Changes¤
Use netconf_discard_changes to abandon uncommitted candidate edits and restore candidate configuration from running.
Use Cases¤
Abandon a staged rollout after review or validation fails, without changing running configuration.
How It Works¤
The task discards all pending candidate changes, including changes made by other sessions. It requires candidate support. It does not undo running changes or cancel a pending confirmed commit.
Output¤
Each host's XML reply appears under discard_changes for ncclient or
discard for Scrapli, normally containing <ok/> on success. RPC and connection
errors mark hosts as failed. add_details=True includes execution metadata;
to_dict=False returns serialized records. XML processors
can convert or filter replies.
Examples¤
nf# nornir netconf discard-changes FL router-1
from norfab.core.nfapi import NorFab
with NorFab(inventory="inventory.yaml") as nf:
client = nf.make_client()
result = client.run_job(
"nornir", "netconf_discard_changes",
kwargs={'FL': ['router-1']},
)
print(result)
Task Command Shell Reference¤
nf#man tree nornir.netconf.discard_changes
R - required field, M - supports multiline input, D - dynamic key
root
└── nornir: Nornir service
└── netconf: Manage devices using NETCONF
└── discard-changes: Discard uncommitted candidate changes
├── 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
├── 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, job options, XML processors, and serialization options
are also available. ncclient is the default backend; select plugin scrapli
to use Scrapli NETCONF.
Python API Reference¤
Discard uncommitted candidate changes and restore candidate from running.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
NorFab job metadata. |
required |
plugin
|
str
|
NETCONF backend: ncclient (default) or scrapli. |
'ncclient'
|
**kwargs
|
Any
|
Common host filters, processors, retries, XML processors, to_dict and add_details serialization options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
XML replies under discard_changes for ncclient or discard for Scrapli, normally an ok reply. Requires candidate support. Discards all pending candidate changes, including other users' edits. Does not undo running changes or cancel a confirmed commit. RPC and connection errors mark hosts failed; unmatched hosts return status no_match. to_dict=False returns serialized records. |
Source code in norfab\workers\nornir_worker\netconf_task.py
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | |