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 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 method

  • kwargs – (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, *args, **kwargs)

Helper function to return NETCONF server capabilities

connected

nornir_salt.plugins.tasks.scrapli_netconf_call._call_connected(conn, *args, **kwargs)

Helper function to return connection status

locked

nornir_salt.plugins.tasks.scrapli_netconf_call._call_locked(conn, *args, **kwargs)

Helper function to run this edit-config flow:

  1. Lock target configuration/datastore

  2. Discard previous changes if any

  3. Run edit config

  4. Validate new confiugration if server supports it

  5. Commit configuration

  6. Unlock target configuration/datastore

If any of steps 3, 4, 5 fails, all changes discarded

Parameters
  • target – (str) name of datastore to edit configuration for

  • config – (str) configuration to apply

Returns result

(list) list of steps performed with details

Returns failed

(bool) status indicator if change failed