Skip to content

get_config

nornir_scrapli.tasks.netconf_get_config

netconf_get_config(task: Task, source: str = 'running', filter_: Optional[Union[str, List[str]]] = None, filter_type: str = 'subtree') -> Result

Get config from the device with scrapli_netconf

Parameters:

Name Type Description Default
task Task

nornir task object

required
source str

configuration source to get; typically one of running|startup|candidate

'running'
filter_ Optional[Union[str, List[str]]]

string of filter(s) to apply to configuration

None
filter_type str

type of filter; subtree|xpath

'subtree'

Returns:

Name Type Description
Result Result

nornir result object with Result.result value set the string result of the get_config operation

Source code in tasks/netconf/get_config.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def netconf_get_config(
    task: Task,
    source: str = "running",
    filter_: Optional[Union[str, List[str]]] = None,
    filter_type: str = "subtree",
) -> Result:
    """
    Get config from the device with scrapli_netconf

    Args:
        task: nornir task object
        source: configuration source to get; typically one of running|startup|candidate
        filter_: string of filter(s) to apply to configuration
        filter_type: type of filter; subtree|xpath

    Returns:
        Result: nornir result object with Result.result value set the string result of the
            get_config operation

    Raises:
        N/A

    """
    scrapli_conn = task.host.get_connection("scrapli_netconf", task.nornir.config)
    scrapli_response = scrapli_conn.get_config(
        source=source, filter_=filter_, filter_type=filter_type
    )

    result = ScrapliResult(
        host=task.host,
        result=process_command_result(scrapli_response=scrapli_response),
        scrapli_response=scrapli_response,
        changed=False,
    )
    return result