Skip to content

get_config

nornir_scrapli.tasks.cfg_get_config

cfg_get_config(task: Task, source: str = 'running') -> Result

Get device config with scrapli-cfg

Parameters:

Name Type Description Default
task Task

nornir task object

required
source str

config source to get

'running'

Returns:

Name Type Description
Result Result

nornir result object with Result.result value set to current prompt

Source code in tasks/cfg/get_config.py
 7
 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
def cfg_get_config(task: Task, source: str = "running") -> Result:
    """
    Get device config with scrapli-cfg

    Args:
        task: nornir task object
        source: config source to get

    Returns:
        Result: nornir result object with Result.result value set to current prompt

    Raises:
        N/A

    """
    scrapli_cfg_conn = ScrapliConfig.get_connection(task=task)

    scrapli_response = scrapli_cfg_conn.get_config(source=source)

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

    return result