NETCONF Delete Configuration¤
Use netconf_delete_config to delete configuration from a non-running datastore.
Use Cases¤
Remove saved startup configuration when preparing a device for reprovisioning, if the device supports NETCONF deletion.
How It Works¤
The target is required and accepts startup or candidate, subject to device support. Running is forbidden. This deletes configuration rather than restoring candidate from running; use netconf_discard_changes to abandon candidate edits. Deleting startup configuration affects the next boot. The task does not make a backup.
Output¤
Each host's XML reply appears under delete_config. Successful datastore operations
normally return <ok/>; RPC replies depend on the operation. 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 delete-config target startup 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_delete_config",
kwargs={'target': 'startup', 'FL': ['router-1']},
)
print(result)
Task Command Shell Reference¤
nf# man tree nornir.netconf.delete_config
R - required field, M - supports multiline input, D - dynamic key
root
└── nornir: Nornir service
└── netconf: Manage devices using NETCONF
└── delete-config: Delete a non-running NETCONF configuration
├── 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'
└── target (R): Datastore to delete; running is forbidden
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¤
Delete configuration from a non-running datastore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
NorFab job metadata. |
required |
target
|
str
|
Datastore to delete: candidate or startup. Required to avoid an implicit destructive target. Running is forbidden by NETCONF. The device must support deletion of the selected datastore. |
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 delete_config, normally an ok reply. Deletes the selected configuration; it does not discard candidate changes back to running. Does not back up, lock, or restore data. Deleting startup configuration can affect the next device boot. RPC and connection errors mark hosts failed; unmatched hosts return status no_match. to_dict=False returns serialized records. Repeated deletion may fail if configuration no longer exists. |
Source code in norfab\workers\nornir_worker\netconf_task.py
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | |