scrapli_netconf_call
Dependencies: Scrapli Netconf need to be installed
Scrapli Netconf is a library to interact with devices using NETCONF. scrapli_netconf_call
task
plugin is a wrapper around Scrapli Netconf connection object.
NETCONF protocol has a specific set of RPC calls available for use, rather
than coding separate task for each of them, scrapli_netconf_call
made to execute
any arbitrary method supported by Scrapli Netconf connection object plus a set
of additional helper methods for extended functionality.
Sample code to run scrapli_netconf_call
task:
from nornir import InitNornir
from nornir_salt.plugins.tasks import scrapli_netconf_call
nr = InitNornir(config_file="config.yaml")
output = nr.run(
task=scrapli_netconf_call,
call="get_config",
source="running"
)
API Reference
- nornir_salt.plugins.tasks.scrapli_netconf_call.scrapli_netconf_call(task: nornir.core.task.Task, call: str, *args, **kwargs) nornir.core.task.Result
Dispatcher function to call one of the supported scrapli_netconf methods or one of helper functions.
- Parameters
call – (str) Scrapli Netconf connection object method to call
arg – (list) any
*args
to use with call methodkwargs – (dict) any
**kwargs
to use with call method
- Returns
result of scrapli-netconf connection method call
Additional Call Methods Reference
dir
- nornir_salt.plugins.tasks.scrapli_netconf_call._call_dir(conn, *args, **kwargs)
Helper function to return a list of supported tasks
help
- nornir_salt.plugins.tasks.scrapli_netconf_call._call_help(conn, *args, **kwargs)
Helper function to return docstring for requested method
- Parameters
method_name – (str) name of method or function to return docstring for
server_capabilities
- nornir_salt.plugins.tasks.scrapli_netconf_call._call_server_capabilities(conn, capab_filter=None, *args, **kwargs)
Helper function to return NETCONF server capabilities
- Parameters
capa_filter – (str) glob filter to filter capabilities
connected
- nornir_salt.plugins.tasks.scrapli_netconf_call._call_connected(conn, *args, **kwargs)
Helper function to return connection status
transaction
- nornir_salt.plugins.tasks.scrapli_netconf_call._call_transaction(conn, *args, **kwargs)
Function to edit device configuration in a reliable fashion using capabilities advertised by NETCONF server.
- Parameters
target – (str) name of datastore to edit configuration for, if no
target
argument provided and device supports candidate datastore usescandidate
datastore, usesrunning
datastore otherwiseconfig – (str) configuration to apply
confirmed – (bool) if True (default) uses commit confirmed
confirm_delay – (int) device commit confirmed rollback delay, default 60 seconds
commit_final_delay – (int) time to wait before doing final commit after commit confirmed, default is 1 second
validate – (bool) if True (default) validates candidate configuration before commit
- Returns result
(list) list of steps performed with details
Function work flow:
Lock target configuration datastore
If server supports it - Discard previous changes if any
Perform configuration edit
If server supports it - validate configuration if
validate
argument is TrueDo commit operation:
If server supports it - do normal commit if
confirmed
argument is FalseIf server supports it - do commit confirmed if
confirmed
argument is True usingconfirm_delay
timerIf confirmed commit requested, wait for
commit_final_delay
timer before sending final commit
Unlock target configuration datastore
If server supports it - discard all changes if any of steps 3, 4, 5 or 6 fail
Return results list of dictionaries keyed by step name
Warning
Scrapli-Netconf supports commit confirmed feature starting with version 2022.07.30. Moreover, only RFC6241 compatible devices supported. For example Juniper Junos uses proprietary RPC for commit operation, as a result commit confirmed not supported for Junos.